diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-13 13:57:47 +0000 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2022-12-13 16:45:51 +0000 |
commit | a01c89adfa3a6fe0918d77282759295a7f0514e5 (patch) | |
tree | f5885152f94b408e3b3634ab600471e035d72da0 /participant/participant-impl/participant-impl-a1pms/src/test | |
parent | 04ffb73ae3fcd3c666030d5c867febd88ef6537c (diff) |
Replace ToscaConceptIdentifier with UUID in Participant Messages ACM
Replace in all messages the reference to Automation Composition
ToscaConceptIdentifier(name, version) with instanceId(UUID).
Issue-ID: POLICY-4479
Change-Id: I7bc9a7494103b9c1752a1e2c6f6d5a527196913d
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms/src/test')
2 files changed, 46 insertions, 42 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 635b77486..ce775b616 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 @@ -39,10 +39,8 @@ import org.onap.policy.clamp.acm.participant.a1pms.utils.CommonTestData; import org.onap.policy.clamp.acm.participant.a1pms.utils.ToscaUtils; import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -54,14 +52,13 @@ class AcElementHandlerTest { @InjectMocks @Spy private AutomationCompositionElementHandler automationCompositionElementHandler = - new AutomationCompositionElementHandler(acA1PmsClient); - + new AutomationCompositionElementHandler(acA1PmsClient); private final CommonTestData commonTestData = new CommonTestData(); private static ToscaServiceTemplate serviceTemplate; private static final String A1_AUTOMATION_COMPOSITION_ELEMENT = - "org.onap.domain.database.A1PMSAutomationCompositionElement"; + "org.onap.domain.database.A1PMSAutomationCompositionElement"; @BeforeAll static void init() { @@ -81,22 +78,22 @@ class AcElementHandlerTest { var element = commonTestData.getAutomationCompositionElement(); var automationCompositionElementId = element.getId(); - Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.automationCompositionElementUpdate( - commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT)); + var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + automationCompositionElementHandler + .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.PASSIVE)); + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.PASSIVE)); assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.UNINITIALISED)); + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.UNINITIALISED)); assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.RUNNING)); + automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, + AutomationCompositionOrderedState.RUNNING)); when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE); assertThrows(A1PolicyServiceException.class, @@ -107,35 +104,30 @@ class AcElementHandlerTest { @Test void test_AutomationCompositionElementUpdate() { - AutomationCompositionElement element = commonTestData.getAutomationCompositionElement(); + var element = commonTestData.getAutomationCompositionElement(); - Map<String, ToscaNodeTemplate> nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate( - commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT))); + var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + assertDoesNotThrow(() -> automationCompositionElementHandler + .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties())); } @Test void test_AutomationCompositionElementUpdateWithUnhealthyA1pms() { - AutomationCompositionElement element = commonTestData.getAutomationCompositionElement(); + var 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))); + var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler + .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties())); } @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)); + var element = commonTestData.getAutomationCompositionElement(); + assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler + .automationCompositionElementUpdate(commonTestData.getAutomationCompositionId(), element, + Map.of())); } } diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java index be573cb37..b68faa692 100755 --- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java +++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java @@ -31,6 +31,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class CommonTestData { private static final String TEST_KEY_NAME = "org.onap.domain.database.A1PMSAutomationCompositionElement"; + private static final List<UUID> AC_ID_LIST = List.of(UUID.randomUUID(), UUID.randomUUID()); /** * Get a automationComposition Element. @@ -38,7 +39,7 @@ public class CommonTestData { * @return automationCompositionElement object */ public AutomationCompositionElement getAutomationCompositionElement() { - AutomationCompositionElement element = new AutomationCompositionElement(); + var element = new AutomationCompositionElement(); element.setId(UUID.randomUUID()); element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1")); element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); @@ -48,30 +49,41 @@ public class CommonTestData { /** * Get automation composition id. * + * @param instanceNo Identifier instance no * @return ToscaConceptIdentifier automationCompositionId */ - public ToscaConceptIdentifier getAutomationCompositionId() { + public ToscaConceptIdentifier getA1PolicyServiceId(int instanceNo) { + return new ToscaConceptIdentifier("A1PMSInstance" + instanceNo, "1.0.0"); + } + + /** + * Get automation composition id. + * + * @return UUID automationCompositionId + */ + public UUID getAutomationCompositionId() { return getAutomationCompositionId(0); } /** * Get automation composition id. + * * @param instanceNo Identifier instance no - * @return ToscaConceptIdentifier automationCompositionId + * @return UUID automationCompositionId */ - public ToscaConceptIdentifier getAutomationCompositionId(int instanceNo) { - return new ToscaConceptIdentifier("A1PMSInstance" + instanceNo, "1.0.0"); + public UUID getAutomationCompositionId(int instanceNo) { + return AC_ID_LIST.get(instanceNo); } - /** * Get valid policy entities. + * * @return List of policy entities */ public List<A1PolicyServiceEntity> getValidPolicyEntities() { - A1PolicyServiceEntity a1PolicyServiceEntity1 = new A1PolicyServiceEntity(getAutomationCompositionId(0), + var a1PolicyServiceEntity1 = new A1PolicyServiceEntity(getA1PolicyServiceId(0), "testService1", "http://localhost", 0); - A1PolicyServiceEntity a1PolicyServiceEntity2 = new A1PolicyServiceEntity(getAutomationCompositionId(1), + var a1PolicyServiceEntity2 = new A1PolicyServiceEntity(getA1PolicyServiceId(1), "testService2", "http://127.0.0.1", 0); return List.of(a1PolicyServiceEntity1, a1PolicyServiceEntity2); } |