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-intermediary/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-intermediary/src/test')
5 files changed, 39 insertions, 39 deletions
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java index 440958e33..4458f0bfa 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java @@ -75,9 +75,9 @@ class ParticipantIntermediaryApiImplTest { var idType = new ToscaConceptIdentifier(ID_NAME_TYPE, ID_VERSION_TYPE); assertEquals(idType, element.getParticipantType()); - var acElement = - apiImpl.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED, - AutomationCompositionState.PASSIVE, ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); + var acElement = apiImpl.updateAutomationCompositionElementState(UUID.randomUUID(), uuid, + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK); assertEquals(AutomationCompositionOrderedState.UNINITIALISED, acElement.getOrderedState()); assertEquals(uuid, acElement.getId()); diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java index 95f16d3e2..06700fcce 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandlerTest.java @@ -63,7 +63,7 @@ class AutomationCompositionHandlerTest { var element = new AutomationCompositionElement(); element.setId(elementId1); element.setDefinition( - new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1")); + new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "1.0.1")); element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); @@ -78,10 +78,10 @@ class AutomationCompositionHandlerTest { var ach = commonTestData.getMockAutomationCompositionHandler(); assertNull(ach.updateAutomationCompositionElementState(null, null, - AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); assertNull(ach.updateAutomationCompositionElementState(null, id, - AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE)); } @Test @@ -93,19 +93,19 @@ class AutomationCompositionHandlerTest { var key = ach.getElementsOnThisParticipant().keySet().iterator().next(); var value = ach.getElementsOnThisParticipant().get(key); assertEquals(AutomationCompositionState.UNINITIALISED, value.getState()); - ach.updateAutomationCompositionElementState(id, uuid, AutomationCompositionOrderedState.UNINITIALISED, - AutomationCompositionState.PASSIVE); + ach.updateAutomationCompositionElementState(CommonTestData.AC_ID_1, uuid, + AutomationCompositionOrderedState.UNINITIALISED, AutomationCompositionState.PASSIVE); assertEquals(AutomationCompositionState.PASSIVE, value.getState()); ach.getAutomationCompositionMap().values().iterator().next().getElements().putIfAbsent(key, value); - ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.RUNNING); + ach.updateAutomationCompositionElementState(CommonTestData.AC_ID_1, key, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.RUNNING); assertEquals(AutomationCompositionState.RUNNING, value.getState()); ach.getElementsOnThisParticipant().remove(key, value); ach.getAutomationCompositionMap().values().iterator().next().getElements().clear(); - assertNull(ach.updateAutomationCompositionElementState(id, key, AutomationCompositionOrderedState.PASSIVE, - AutomationCompositionState.RUNNING)); + assertNull(ach.updateAutomationCompositionElementState(CommonTestData.AC_ID_1, key, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.RUNNING)); } @@ -115,19 +115,19 @@ class AutomationCompositionHandlerTest { var id = CommonTestData.getParticipantId(); var stateChange = getStateChange(id, uuid, AutomationCompositionOrderedState.RUNNING); var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); - assertDoesNotThrow( - () -> ach.handleAutomationCompositionStateChange(mock(AutomationCompositionStateChange.class), List.of())); + assertDoesNotThrow(() -> ach + .handleAutomationCompositionStateChange(mock(AutomationCompositionStateChange.class), List.of())); ach.handleAutomationCompositionStateChange(stateChange, List.of()); var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChange.setAutomationCompositionId(newid); + stateChange.setAutomationCompositionId(UUID.randomUUID()); stateChange.setParticipantId(newid); assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChange, List.of())); var acd = new AutomationCompositionElementDefinition(); acd.setAcElementDefinitionId(id); var updateMsg = new AutomationCompositionUpdate(); - updateMsg.setAutomationCompositionId(id); + updateMsg.setAutomationCompositionId(UUID.randomUUID()); updateMsg.setMessageId(uuid); updateMsg.setParticipantId(id); updateMsg.setStartPhase(0); @@ -140,7 +140,7 @@ class AutomationCompositionHandlerTest { updateMsg.setStartPhase(0); assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); - updateMsg.setAutomationCompositionId(new ToscaConceptIdentifier("new", "0.0.1")); + updateMsg.setAutomationCompositionId(UUID.randomUUID()); updateMsg.setParticipantUpdatesList(List.of(mock(ParticipantUpdates.class))); assertDoesNotThrow(() -> ach.handleAutomationCompositionUpdate(updateMsg, acElementDefinitions)); @@ -170,7 +170,7 @@ class AutomationCompositionHandlerTest { var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of()); var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChangeUninitialised.setAutomationCompositionId(newid); + stateChangeUninitialised.setAutomationCompositionId(UUID.randomUUID()); stateChangeUninitialised.setParticipantId(newid); assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangeUninitialised, List.of())); } @@ -185,15 +185,15 @@ class AutomationCompositionHandlerTest { var ach = commonTestData.setTestAutomationCompositionHandler(id, uuid); ach.handleAutomationCompositionStateChange(stateChangePassive, List.of()); var newid = new ToscaConceptIdentifier("id", "1.2.3"); - stateChangePassive.setAutomationCompositionId(newid); + stateChangePassive.setAutomationCompositionId(UUID.randomUUID()); stateChangePassive.setParticipantId(newid); assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangePassive, List.of())); } private AutomationCompositionStateChange getStateChange(ToscaConceptIdentifier id, UUID uuid, - AutomationCompositionOrderedState state) { + AutomationCompositionOrderedState state) { var stateChange = new AutomationCompositionStateChange(); - stateChange.setAutomationCompositionId(id); + stateChange.setAutomationCompositionId(UUID.randomUUID()); stateChange.setParticipantId(id); stateChange.setMessageId(uuid); stateChange.setOrderedState(state); diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java index a87d8e1aa..fd0b54f5e 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java @@ -80,7 +80,7 @@ class ParticipantHandlerTest { var participantHandler = commonTestData.getMockParticipantHandler(); var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); - participantUpdateMsg.setAutomationCompositionId(id); + participantUpdateMsg.setAutomationCompositionId(CommonTestData.AC_ID_1); participantUpdateMsg.setParticipantId(id); participantUpdateMsg.setParticipantType(id); participantUpdateMsg.setMessageId(UUID.randomUUID()); @@ -160,9 +160,8 @@ class ParticipantHandlerTest { @Test void getAutomationCompositionInfoListTest() throws CoderException { var participantHandler = commonTestData.getParticipantHandlerAutomationCompositions(); - var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION); participantHandler.sendHeartbeat(); - assertEquals(id, participantHandler.makeHeartbeat(false) + assertEquals(CommonTestData.AC_ID_1, participantHandler.makeHeartbeat(false) .getAutomationCompositionInfoList() .get(0) .getAutomationCompositionId()); diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java index 91552ee34..01a8f3c28 100644 --- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java +++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java @@ -55,6 +55,8 @@ public class CommonTestData { public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams()); public static final Coder CODER = new StandardCoder(); private static final Object lockit = new Object(); + public static final UUID AC_ID_0 = UUID.randomUUID(); + public static final UUID AC_ID_1 = UUID.randomUUID(); /** * Get ParticipantIntermediaryParameters. @@ -64,7 +66,7 @@ public class CommonTestData { public ParticipantIntermediaryParameters getParticipantIntermediaryParameters() { try { return CODER.convert(getIntermediaryParametersMap(PARTICIPANT_GROUP_NAME), - ParticipantIntermediaryParameters.class); + ParticipantIntermediaryParameters.class); } catch (final CoderException e) { throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e); } @@ -195,9 +197,9 @@ public class CommonTestData { public ParticipantHandler getParticipantHandlerAutomationCompositions() throws CoderException { var automationCompositionHandler = Mockito.mock(AutomationCompositionHandler.class); Mockito.doReturn(getTestAutomationCompositions()).when(automationCompositionHandler) - .getAutomationCompositions(); + .getAutomationCompositions(); Mockito.doReturn(getTestAutomationCompositionMap()).when(automationCompositionHandler) - .getAutomationCompositionMap(); + .getAutomationCompositionMap(); var publisher = new ParticipantMessagePublisher(); publisher.active(Collections.singletonList(Mockito.mock(TopicSink.class))); var parameters = getParticipantParameters(); @@ -218,12 +220,11 @@ public class CommonTestData { * * @throws CoderException if there is an error with .json file. */ - public Map<ToscaConceptIdentifier, AutomationComposition> getTestAutomationCompositionMap() throws CoderException { + public Map<UUID, AutomationComposition> getTestAutomationCompositionMap() throws CoderException { var automationCompositions = getTestAutomationCompositions(); var automationComposition = automationCompositions.getAutomationCompositionList().get(1); - var id = getParticipantId(); - Map<ToscaConceptIdentifier, AutomationComposition> automationCompositionMap = new LinkedHashMap<>(); - automationCompositionMap.put(id, automationComposition); + Map<UUID, AutomationComposition> automationCompositionMap = new LinkedHashMap<>(); + automationCompositionMap.put(automationComposition.getInstanceId(), automationComposition); return automationCompositionMap; } @@ -235,8 +236,11 @@ public class CommonTestData { * @throws CoderException if there is an error with .json file. */ public AutomationCompositions getTestAutomationCompositions() throws CoderException { - return new StandardCoder().decode(new File("src/test/resources/providers/TestAutomationCompositions.json"), - AutomationCompositions.class); + var automationCompositions = new StandardCoder().decode( + new File("src/test/resources/providers/TestAutomationCompositions.json"), AutomationCompositions.class); + automationCompositions.getAutomationCompositionList().get(1).setInstanceId(AC_ID_0); + automationCompositions.getAutomationCompositionList().get(1).setInstanceId(AC_ID_1); + return automationCompositions; } /** @@ -246,7 +250,7 @@ public class CommonTestData { * @return a map suitable for elementsOnThisParticipant */ public Map<UUID, AutomationCompositionElement> setAutomationCompositionElementTest(UUID uuid, - ToscaConceptIdentifier id) { + ToscaConceptIdentifier id) { var acElement = new AutomationCompositionElement(); acElement.setId(uuid); acElement.setParticipantId(id); @@ -265,7 +269,7 @@ public class CommonTestData { * @return a AutomationCompositionHander with elements */ public AutomationCompositionHandler setTestAutomationCompositionHandler(ToscaConceptIdentifier id, UUID uuid) - throws CoderException { + throws CoderException { var ach = getMockAutomationCompositionHandler(); var key = getTestAutomationCompositionMap().keySet().iterator().next(); diff --git a/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json index 10ed6d187..9f2eed066 100644 --- a/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json +++ b/participant/participant-intermediary/src/test/resources/providers/TestAutomationCompositions.json @@ -35,10 +35,7 @@ }, "709c62b3-8918-41b9-a747-e21eb79c6c22": { "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", - "definition": { - "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement", - "version": "1.2.3" - }, + "compositionId": "709c62b3-8918-41b9-a747-d21eb79c6c40", "participantType": { "name": "org.onap.policy.acm.PolicyAutomationCompositionParticipant", "version": "2.3.1" |