aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-a1pms/src/test/java
diff options
context:
space:
mode:
authoraravind.est <aravindhan.a@est.tech>2022-12-06 15:42:08 +0000
committeraravind.est <aravindhan.a@est.tech>2022-12-06 16:07:19 +0000
commitccb8bb7deb86001c5d88e07a344a6fb518efba9c (patch)
tree1bbb3bfaabf7c9ca4b953fb9bdc4ec5751f355ff /participant/participant-impl/participant-impl-a1pms/src/test/java
parent6f3447836b04f2fbea1fa4fca526d549bec42661 (diff)
A1pms: Fix Code smells and coverage
Issue-ID: CCSDK-3816 Signed-off-by: aravind.est <aravindhan.a@est.tech> Change-Id: Ifa9a5d538d13e59ec842edee6d3cbc43a0f0df1d
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms/src/test/java')
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
index 690f5f2f4..635b77486 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.acm.participant.a1pms.handler;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
@@ -96,6 +97,12 @@ class AcElementHandlerTest {
assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange(
automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
AutomationCompositionOrderedState.RUNNING));
+
+ when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
+ assertThrows(A1PolicyServiceException.class,
+ () -> automationCompositionElementHandler.automationCompositionElementStateChange(
+ automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE,
+ AutomationCompositionOrderedState.UNINITIALISED));
}
@Test
@@ -107,4 +114,28 @@ class AcElementHandlerTest {
commonTestData.getAutomationCompositionId(), element,
nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT)));
}
+
+ @Test
+ void test_AutomationCompositionElementUpdateWithUnhealthyA1pms() {
+ AutomationCompositionElement element = commonTestData.getAutomationCompositionElement();
+ when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE);
+
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ assertThrows(A1PolicyServiceException.class,
+ () -> automationCompositionElementHandler.automationCompositionElementUpdate(
+ commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT)));
+ }
+
+ @Test
+ void test_AutomationCompositionElementUpdateWithInvalidConfiguration() {
+ AutomationCompositionElement element = commonTestData.getAutomationCompositionElement();
+
+ Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ ToscaNodeTemplate toscaNodeTemplate = nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT);
+ toscaNodeTemplate.setProperties(Map.of());
+ assertThrows(A1PolicyServiceException.class,
+ () -> automationCompositionElementHandler.automationCompositionElementUpdate(
+ commonTestData.getAutomationCompositionId(), element, toscaNodeTemplate));
+ }
}