aboutsummaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2022-12-07 15:30:54 +0000
committerGerrit Code Review <gerrit@onap.org>2022-12-07 15:30:54 +0000
commitf3d20cee5f876ba547bbc57acf316bc43ab3afed (patch)
treeade28670d367837641f04ebe70f9e402f42f3da3 /participant
parent988daeffb244656076d24f4007f1841166345759 (diff)
parentccb8bb7deb86001c5d88e07a344a6fb518efba9c (diff)
Merge "A1pms: Fix Code smells and coverage"
Diffstat (limited to 'participant')
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java6
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java31
2 files changed, 32 insertions, 5 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
index 072d14475..9b942b961 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
@@ -145,12 +145,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
LOGGER.error("Violations found in the config request parameters: {}", violations);
throw new ValidationException("Constraint violations in the config request");
}
- } catch (ValidationException | CoderException e) {
- LOGGER.error("Error invoking the A1PMS request for the config ", e);
+ } catch (ValidationException | CoderException | A1PolicyServiceException e) {
throw new A1PolicyServiceException(HttpStatus.SC_BAD_REQUEST, "Invalid Configuration", e);
- } catch (A1PolicyServiceException e) {
- LOGGER.error("Error invoking the A1PMS request for the config ", e);
- throw e;
}
}
}
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));
+ }
}