diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-19 14:43:11 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2022-12-20 10:35:32 +0000 |
commit | c71863696d729286502f951a64c3d2193c6641e7 (patch) | |
tree | 024363ddde071c3f59d7468bdc9ddfd011d3701e /runtime-acm/src/test/java/org | |
parent | 66208f7d9ec65d859803ed347c3fdecd2d99022f (diff) |
Add compositionId into Messages between ACM and Participants
Issue-ID: POLICY-4489
Change-Id: I1fb8c04eacee040d5c944c522ca59a2a9a50376b
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test/java/org')
5 files changed, 25 insertions, 58 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java index 792cb4a75..fe0180a74 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProviderTest.java @@ -90,7 +90,7 @@ class CommissioningProviderTest { var affectedDefinitions = provider .createAutomationCompositionDefinitions(serviceTemplate).getAffectedAutomationCompositionDefinitions(); verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate); - verify(supervisionHandler).handleSendCommissionMessage(serviceTemplate.getName(), serviceTemplate.getVersion()); + verify(supervisionHandler).handleSendCommissionMessage(acmDefinition); // Response should return the number of node templates present in the service template assertThat(affectedDefinitions).hasSize(7); } @@ -148,7 +148,7 @@ class CommissioningProviderTest { provider.deleteAutomationCompositionDefinition(compositionId); - verify(supervisionHandler).handleSendDeCommissionMessage(); + verify(supervisionHandler).handleSendDeCommissionMessage(compositionId); verify(acDefinitionProvider).deleteAcDefintion(compositionId); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java index 84b756816..abc3ccb1a 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java @@ -25,11 +25,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; -import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; class SupervisionAspectTest { @@ -70,32 +67,4 @@ class SupervisionAspectTest { verify(supervisionScanner, timeout(500)).handleParticipantStatus(PARTICIPANT_ID); } } - - @Test - void testHandleParticipantUpdateAck() throws Exception { - var updateAckMessage = new ParticipantUpdateAck(); - updateAckMessage.setParticipantId(PARTICIPANT_ID); - updateAckMessage.setParticipantType(PARTICIPANT_TYPE); - - var supervisionScanner = mock(SupervisionScanner.class); - try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { - supervisionAspect.handleParticipantUpdateAck(updateAckMessage); - verify(supervisionScanner, timeout(500)) - .handleParticipantUpdateAck(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE)); - } - } - - @Test - void testHandleParticipantRegister() throws Exception { - var participantRegister = new ParticipantRegister(); - participantRegister.setParticipantId(PARTICIPANT_ID); - participantRegister.setParticipantType(PARTICIPANT_TYPE); - - var supervisionScanner = mock(SupervisionScanner.class); - try (var supervisionAspect = new SupervisionAspect(supervisionScanner)) { - supervisionAspect.handleParticipantRegister(participantRegister, true); - verify(supervisionScanner, timeout(500)) - .handleParticipantRegister(new ImmutablePair<>(PARTICIPANT_ID, PARTICIPANT_TYPE)); - } - } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java index 832d25da0..2da869072 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java @@ -43,6 +43,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAck import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.clamp.models.acm.concepts.Participant; @@ -365,10 +366,10 @@ class SupervisionHandlerTest { mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); - handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion()); + var acmDefinition = new AutomationCompositionDefinition(); + handler.handleSendCommissionMessage(acmDefinition); - verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(), - participantId.getVersion()); + verify(participantUpdatePublisher).sendComissioningBroadcast(acmDefinition); } @Test @@ -379,9 +380,9 @@ class SupervisionHandlerTest { mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class), participantUpdatePublisher, AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.UNINITIALISED); - handler.handleSendDeCommissionMessage(); + handler.handleSendDeCommissionMessage(identifier); - verify(participantUpdatePublisher).sendDecomisioning(); + verify(participantUpdatePublisher).sendDecomisioning(identifier); } private SupervisionHandler createSupervisionHandler(AutomationCompositionProvider automationCompositionProvider, diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java index 1455e9246..a6d4d3b0d 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -31,14 +31,12 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC import java.util.List; import java.util.Objects; import java.util.UUID; -import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionStateChangePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.AutomationCompositionUpdatePublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher; -import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantUpdatePublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; @@ -84,7 +82,6 @@ class SupervisionScannerTest { var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); var participantProvider = mock(ParticipantProvider.class); var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); @@ -93,7 +90,7 @@ class SupervisionScannerTest { var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + participantStatusReqPublisher, acRuntimeParameterGroup); supervisionScanner.run(false); verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class)); @@ -112,12 +109,11 @@ class SupervisionScannerTest { var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); var participantProvider = mock(ParticipantProvider.class); var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + participantStatusReqPublisher, acRuntimeParameterGroup); supervisionScanner.run(false); verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class)); @@ -139,12 +135,11 @@ class SupervisionScannerTest { var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + participantStatusReqPublisher, acRuntimeParameterGroup); supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); supervisionScanner.run(true); @@ -176,12 +171,11 @@ class SupervisionScannerTest { var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + participantStatusReqPublisher, acRuntimeParameterGroup); supervisionScanner.run(false); @@ -212,21 +206,16 @@ class SupervisionScannerTest { var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class); var participantStatusReqPublisher = mock(ParticipantStatusReqPublisher.class); var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); - var participantUpdatePublisher = mock(ParticipantUpdatePublisher.class); var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider, - participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup); + participantStatusReqPublisher, acRuntimeParameterGroup); - supervisionScanner - .handleParticipantRegister(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE)); supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier()); supervisionScanner.run(true); verify(participantStatusReqPublisher).send(any(ToscaConceptIdentifier.class)); verify(participantProvider).saveParticipant(any()); - supervisionScanner - .handleParticipantUpdateAck(new ImmutablePair<>(participant.getKey().asIdentifier(), PARTICIPANT_TYPE)); supervisionScanner.run(true); verify(participantProvider, times(2)).saveParticipant(any()); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java index 2cfe7eb3c..b545fd957 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java @@ -24,15 +24,17 @@ package org.onap.policy.clamp.acm.runtime.supervision.comm; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVICE_TEMPLATE_YAML; import java.util.Collections; import java.util.List; import java.util.UUID; import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister; @@ -133,7 +135,7 @@ class SupervisionMessagesTest { var publisher = new ParticipantUpdatePublisher(mock(AcDefinitionProvider.class)); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); - publisher.sendDecomisioning(); + publisher.sendDecomisioning(UUID.randomUUID()); verify(topicSink).send(anyString()); } @@ -142,8 +144,14 @@ class SupervisionMessagesTest { var publisher = new ParticipantUpdatePublisher(mock(AcDefinitionProvider.class)); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); - publisher.sendComissioningBroadcast("NAME", "1.0.0"); - verify(topicSink, times(0)).send(anyString()); + var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); + serviceTemplate.setName("Name"); + serviceTemplate.setVersion("1.0.0"); + var acmDefinition = new AutomationCompositionDefinition(); + acmDefinition.setCompositionId(UUID.randomUUID()); + acmDefinition.setServiceTemplate(serviceTemplate); + publisher.sendComissioningBroadcast(acmDefinition); + verify(topicSink).send(anyString()); } @Test |