diff options
Diffstat (limited to 'runtime-acm/src/test/java')
9 files changed, 124 insertions, 57 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 d7c79bc3b..5c26ea3bd 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 @@ -35,6 +35,7 @@ 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.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantPrimePublisher; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; @@ -59,8 +60,10 @@ class CommissioningProviderTest { void testGetAutomationCompositionDefinitions() { var acProvider = mock(AutomationCompositionProvider.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); + var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class); - var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null); + var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, + acRuntimeParameterGroup); var serviceTemplates = provider.getAutomationCompositionDefinitions(null, null); assertThat(serviceTemplates.getServiceTemplates()).isEmpty(); @@ -84,13 +87,16 @@ class CommissioningProviderTest { acmDefinition.setCompositionId(UUID.randomUUID()); acmDefinition.setServiceTemplate(serviceTemplate); var acDefinitionProvider = mock(AcDefinitionProvider.class); - when(acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate)).thenReturn(acmDefinition); + when(acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate, + CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME)).thenReturn(acmDefinition); var acProvider = mock(AutomationCompositionProvider.class); - var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null); + var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, + CommonTestData.getTestParamaterGroup()); var affectedDefinitions = provider.createAutomationCompositionDefinition(serviceTemplate) .getAffectedAutomationCompositionDefinitions(); - verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate); + verify(acDefinitionProvider).createAutomationCompositionDefinition(serviceTemplate, + CommonTestData.TOSCA_ELEMENT_NAME, CommonTestData.TOSCA_COMP_NAME); // Response should return the number of node templates present in the service template assertThat(affectedDefinitions).hasSize(7); } @@ -105,7 +111,7 @@ class CommissioningProviderTest { var acDefinitionProvider = mock(AcDefinitionProvider.class); var acProvider = mock(AutomationCompositionProvider.class); - var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null); + var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null); var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); when(acDefinitionProvider.getServiceTemplateList(null, null)).thenReturn(List.of(serviceTemplate)); @@ -122,7 +128,7 @@ class CommissioningProviderTest { var compositionId = UUID.randomUUID(); when(acProvider.getAcInstancesByCompositionId(compositionId)).thenReturn(List.of(new AutomationComposition())); - var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null); + var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null); assertThatThrownBy(() -> provider.deleteAutomationCompositionDefinition(compositionId)) .hasMessageMatching("Delete instances, to commission automation composition definitions"); @@ -142,7 +148,7 @@ class CommissioningProviderTest { when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var acProvider = mock(AutomationCompositionProvider.class); - var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null); + var provider = new CommissioningProvider(acDefinitionProvider, acProvider, null, null, null, null); provider.deleteAutomationCompositionDefinition(compositionId); @@ -159,12 +165,13 @@ class CommissioningProviderTest { var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(AcmParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher); + mock(AcmParticipantProvider.class), new AcTypeStateResolver(), participantPrimePublisher, + CommonTestData.getTestParamaterGroup()); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.PRIME); provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate); - verify(acDefinitionProvider).updateAcDefinition(acmDefinition); + verify(acDefinitionProvider).updateAcDefinition(acmDefinition, CommonTestData.TOSCA_COMP_NAME); verify(participantPrimePublisher, timeout(1000).times(1)).sendPriming(any(), any(), any()); } @@ -179,7 +186,8 @@ class CommissioningProviderTest { var participantPrimePublisher = mock(ParticipantPrimePublisher.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - acmParticipantProvider, new AcTypeStateResolver(), participantPrimePublisher); + acmParticipantProvider, new AcTypeStateResolver(), participantPrimePublisher, + CommonTestData.getTestParamaterGroup()); var acTypeStateUpdate = new AcTypeStateUpdate(); acTypeStateUpdate.setPrimeOrder(PrimeOrder.DEPRIME); @@ -193,7 +201,8 @@ class CommissioningProviderTest { void testBadRequest() { var acProvider = mock(AutomationCompositionProvider.class); var provider = new CommissioningProvider(mock(AcDefinitionProvider.class), acProvider, - mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class)); + mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); var compositionId = UUID.randomUUID(); when(acProvider.getAcInstancesByCompositionId(compositionId)).thenReturn(List.of(new AutomationComposition())); @@ -216,7 +225,8 @@ class CommissioningProviderTest { when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class)); + mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); assertThatThrownBy(() -> provider.updateCompositionDefinition(compositionId, toscaServiceTemplate)) .hasMessageMatching("ACM not in COMMISSIONED state, Update of ACM Definition not allowed"); @@ -235,7 +245,8 @@ class CommissioningProviderTest { when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acmDefinition); var provider = new CommissioningProvider(acDefinitionProvider, mock(AutomationCompositionProvider.class), - mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class)); + mock(AcmParticipantProvider.class), new AcTypeStateResolver(), mock(ParticipantPrimePublisher.class), + mock(AcRuntimeParameterGroup.class)); var acTypeStateUpdate = new AcTypeStateUpdate(); assertThatThrownBy(() -> provider.compositionDefinitionPriming(compositionId, acTypeStateUpdate)) diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java index 2aab744ad..b2e151126 100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/commissioning/rest/CommissioningControllerTest.java @@ -38,18 +38,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; -import org.onap.policy.clamp.models.acm.concepts.Participant; -import org.onap.policy.clamp.models.acm.concepts.ParticipantState; -import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse; import org.onap.policy.clamp.models.acm.messages.rest.commissioning.PrimeOrder; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider; -import org.onap.policy.clamp.models.acm.utils.AcmUtils; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -230,7 +226,9 @@ class CommissioningControllerTest extends CommonRestController { private UUID createEntryInDB(String name) { var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate); serviceTemplateCreate.setName(name); - var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplateCreate); + var acmDefinition = acDefinitionProvider + .createAutomationCompositionDefinition(serviceTemplateCreate, CommonTestData.TOSCA_ELEMENT_NAME, + CommonTestData.TOSCA_COMP_NAME); return acmDefinition.getCompositionId(); } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java index a59872f0a..308eed5da 100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java @@ -35,6 +35,8 @@ import java.util.Optional; import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters; import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; @@ -101,7 +103,8 @@ class AutomationCompositionInstantiationProviderTest { var supervisionAcHandler = mock(SupervisionAcHandler.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - null, supervisionAcHandler, acmParticipantProvider); + null, supervisionAcHandler, acmParticipantProvider, + CommonTestData.getTestParamaterGroup()); var automationCompositionCreate = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); automationCompositionCreate.setCompositionId(compositionId); @@ -166,7 +169,8 @@ class AutomationCompositionInstantiationProviderTest { var supervisionAcHandler = mock(SupervisionAcHandler.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - null, supervisionAcHandler, acmParticipantProvider); + null, supervisionAcHandler, acmParticipantProvider, + CommonTestData.getTestParamaterGroup()); var instantiationResponse = instantiationProvider.updateAutomationComposition( automationCompositionUpdate.getCompositionId(), automationCompositionUpdate); @@ -187,7 +191,8 @@ class AutomationCompositionInstantiationProviderTest { var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), null, - mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class)); + mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class), + mock(AcRuntimeParameterGroup.class)); var compositionId = automationCompositionUpdate.getCompositionId(); assertThatThrownBy( @@ -209,7 +214,8 @@ class AutomationCompositionInstantiationProviderTest { var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), null, - mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class)); + mock(SupervisionAcHandler.class), mock(AcmParticipantProvider.class), + mock(AcRuntimeParameterGroup.class)); var compositionId = automationCompositionUpdate.getCompositionId(); assertThatThrownBy( @@ -246,7 +252,8 @@ class AutomationCompositionInstantiationProviderTest { var supervisionAcHandler = mock(SupervisionAcHandler.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - null, supervisionAcHandler, acmParticipantProvider); + null, supervisionAcHandler, acmParticipantProvider, + mock(AcRuntimeParameterGroup.class)); assertThatThrownBy( () -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate)) .hasMessageMatching("\"AutomationComposition\" INVALID, item has status INVALID\n" @@ -263,9 +270,10 @@ class AutomationCompositionInstantiationProviderTest { var acDefinitionProvider = mock(AcDefinitionProvider.class); var supervisionAcHandler = mock(SupervisionAcHandler.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); + var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - null, supervisionAcHandler, acmParticipantProvider); + null, supervisionAcHandler, acmParticipantProvider, acRuntimeParameterGroup); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); @@ -295,9 +303,11 @@ class AutomationCompositionInstantiationProviderTest { automationComposition.setLockState(lockState); var acProvider = mock(AutomationCompositionProvider.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); + var acRuntimeParamaterGroup = mock(AcRuntimeParameterGroup.class); var instantiationProvider = - new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null); + new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null, + acRuntimeParamaterGroup); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); @@ -326,7 +336,8 @@ class AutomationCompositionInstantiationProviderTest { var acmParticipantProvider = mock(AcmParticipantProvider.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - null, null, acmParticipantProvider); + null, null, acmParticipantProvider, + CommonTestData.getTestParamaterGroup()); var instantiationResponse = instantiationProvider.createAutomationComposition( automationCompositionCreate.getCompositionId(), automationCompositionCreate); @@ -353,7 +364,7 @@ class AutomationCompositionInstantiationProviderTest { var acProvider = mock(AutomationCompositionProvider.class); var provider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, - acmParticipantProvider); + acmParticipantProvider, CommonTestData.getTestParamaterGroup()); assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition)) .hasMessageMatching(AC_ELEMENT_NAME_NOT_FOUND); @@ -374,7 +385,8 @@ class AutomationCompositionInstantiationProviderTest { when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); var provider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), - null, null, null); + null, null, null, + mock(AcRuntimeParameterGroup.class)); var compositionId = automationComposition.getCompositionId(); assertThatThrownBy(() -> provider.createAutomationComposition(compositionId, automationComposition)) @@ -393,7 +405,8 @@ class AutomationCompositionInstantiationProviderTest { when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); var provider = new AutomationCompositionInstantiationProvider(acProvider, mock(AcDefinitionProvider.class), - null, null, null); + null, null, null, + mock(AcRuntimeParameterGroup.class)); var compositionId = automationComposition.getCompositionId(); var wrongCompositionId = UUID.randomUUID(); @@ -419,7 +432,8 @@ class AutomationCompositionInstantiationProviderTest { when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition)); var acProvider = mock(AutomationCompositionProvider.class); var provider = - new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null); + new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null, null, + null); var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); @@ -448,7 +462,8 @@ class AutomationCompositionInstantiationProviderTest { var supervisionAcHandler = mock(SupervisionAcHandler.class); var acmParticipantProvider = mock(AcmParticipantProvider.class); var provider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, - new AcInstanceStateResolver(), supervisionAcHandler, acmParticipantProvider); + new AcInstanceStateResolver(), supervisionAcHandler, acmParticipantProvider, + mock(AcRuntimeParameterGroup.class)); var acInstanceStateUpdate = new AcInstanceStateUpdate(); acInstanceStateUpdate.setDeployOrder(DeployOrder.DEPLOY); diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java index 985d9a0c3..1e5aa6c89 100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java @@ -74,6 +74,8 @@ class InstantiationControllerTest extends CommonRestController { private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(); + private static final String NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition"; + @Autowired private AcDefinitionProvider acDefinitionProvider; @@ -338,7 +340,7 @@ class InstantiationControllerTest extends CommonRestController { var serviceTemplateCreate = new ToscaServiceTemplate(serviceTemplate); serviceTemplateCreate.setName(name); var acmDefinition = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED); - acDefinitionProvider.updateAcDefinition(acmDefinition); + acDefinitionProvider.updateAcDefinition(acmDefinition, NODE_TYPE); saveDummyParticipantInDb(); return acmDefinition.getCompositionId(); } 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 9ce63b005..e1c6127d4 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 @@ -29,6 +29,7 @@ import static org.onap.policy.clamp.acm.runtime.util.CommonTestData.TOSCA_SERVIC import java.util.Optional; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.acm.runtime.instantiation.InstantiationUtils; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.util.CommonTestData; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; @@ -44,7 +45,8 @@ class SupervisionHandlerTest { participantPrimeAckMessage.setParticipantId(CommonTestData.getParticipantId()); participantPrimeAckMessage.setState(ParticipantState.ON_LINE); var acDefinitionProvider = mock(AcDefinitionProvider.class); - var handler = new SupervisionHandler(acDefinitionProvider); + var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class); + var handler = new SupervisionHandler(acDefinitionProvider, acRuntimeParameterGroup); handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); @@ -63,8 +65,9 @@ class SupervisionHandlerTest { var acDefinitionProvider = mock(AcDefinitionProvider.class); when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId())) .thenReturn(Optional.of(acDefinition)); + var acRuntimeParameterGroup = mock(AcRuntimeParameterGroup.class); - var handler = new SupervisionHandler(acDefinitionProvider); + var handler = new SupervisionHandler(acDefinitionProvider, acRuntimeParameterGroup); handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); @@ -86,11 +89,11 @@ class SupervisionHandlerTest { when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId())) .thenReturn(Optional.of(acDefinition)); - var handler = new SupervisionHandler(acDefinitionProvider); + var handler = new SupervisionHandler(acDefinitionProvider, CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); - verify(acDefinitionProvider).updateAcDefinition(any()); + verify(acDefinitionProvider).updateAcDefinition(any(), any()); } @Test @@ -110,10 +113,10 @@ class SupervisionHandlerTest { when(acDefinitionProvider.findAcDefinition(acDefinition.getCompositionId())) .thenReturn(Optional.of(acDefinition)); - var handler = new SupervisionHandler(acDefinitionProvider); + var handler = new SupervisionHandler(acDefinitionProvider, CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantPrimeAckMessage); verify(acDefinitionProvider).findAcDefinition(any()); - verify(acDefinitionProvider).updateAcDefinition(any()); + verify(acDefinitionProvider).updateAcDefinition(any(), any()); } } diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java index 670806f65..cfef1a5ee 100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java @@ -21,6 +21,7 @@ package org.onap.policy.clamp.acm.runtime.supervision; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -32,6 +33,7 @@ import java.util.Set; 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.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher; import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRestartPublisher; @@ -71,7 +73,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher, mock(AutomationCompositionProvider.class), - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class)); + mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantDeregisterMessage); @@ -91,7 +94,8 @@ class SupervisionParticipantHandlerTest { var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class); var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class), - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class)); + mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantRegisterMessage); verify(participantProvider).saveParticipant(any()); @@ -141,11 +145,12 @@ class SupervisionParticipantHandlerTest { var participantRestartPublisher = mock(ParticipantRestartPublisher.class); var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher, mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, acDefinitionProvider, - participantRestartPublisher); + participantRestartPublisher, CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantRegisterMessage); verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId); - verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class)); + verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class), + eq(CommonTestData.TOSCA_COMP_NAME)); verify(participantRestartPublisher).send(any(), any(AutomationCompositionDefinition.class), any()); } @@ -159,7 +164,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class)); + mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), + mock(AcRuntimeParameterGroup.class)); var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId()); when(participantProvider.findParticipant(CommonTestData.getParticipantId())) .thenReturn(Optional.of(participant)); @@ -194,10 +200,11 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), mock(AutomationCompositionProvider.class), - acDefinitionProvider, mock(ParticipantRestartPublisher.class)); + acDefinitionProvider, mock(ParticipantRestartPublisher.class), + CommonTestData.getTestParamaterGroup()); handler.handleParticipantMessage(participantStatusMessage); - verify(acDefinitionProvider).updateAcDefinition(acDefinition); + verify(acDefinitionProvider).updateAcDefinition(acDefinition, CommonTestData.TOSCA_COMP_NAME); } @Test @@ -210,7 +217,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class)); + mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), + mock(AcRuntimeParameterGroup.class)); handler.handleParticipantMessage(participantStatusMessage); verify(participantProvider).saveParticipant(any()); @@ -227,7 +235,8 @@ class SupervisionParticipantHandlerTest { var handler = new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider, - mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class)); + mock(AcDefinitionProvider.class), mock(ParticipantRestartPublisher.class), + mock(AcRuntimeParameterGroup.class)); var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId()); participant.setParticipantState(ParticipantState.OFF_LINE); when(participantProvider.findParticipant(CommonTestData.getParticipantId())) 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 9b596c89a..5fe4f4c25 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 @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.supervision; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -80,7 +81,8 @@ class SupervisionScannerTest { mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), acRuntimeParameterGroup); supervisionScanner.run(); - verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class)); + verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class), + eq(CommonTestData.TOSCA_COMP_NAME)); } @Test @@ -91,14 +93,16 @@ class SupervisionScannerTest { mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), acRuntimeParameterGroup); supervisionScanner.run(); - verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class)); + verify(acDefinitionProvider, times(0)).updateAcDefinition(any(AutomationCompositionDefinition.class), + eq(CommonTestData.TOSCA_COMP_NAME)); acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1); supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider, mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class), acRuntimeParameterGroup); supervisionScanner.run(); - verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class)); + verify(acDefinitionProvider).updateAcDefinition(any(AutomationCompositionDefinition.class), + eq(CommonTestData.TOSCA_COMP_NAME)); } @Test 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 06684d863..85444ed2f 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 @@ -35,6 +35,7 @@ import java.util.Map; 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.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler; @@ -67,6 +68,8 @@ class SupervisionMessagesTest { private static final CommInfrastructure INFRA = CommInfrastructure.NOOP; private static final String TOPIC = "my-topic"; + private static final String TOSCA_ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement"; + @Test void testSendParticipantRegisterAck() { var acRegisterAckPublisher = new ParticipantRegisterAckPublisher(); @@ -146,7 +149,7 @@ class SupervisionMessagesTest { @Test void testParticipantPrimePublisherDecommissioning() { var publisher = new ParticipantPrimePublisher(mock(ParticipantProvider.class), - mock(AcmParticipantProvider.class)); + mock(AcmParticipantProvider.class), mock(AcRuntimeParameterGroup.class)); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); publisher.sendDepriming(UUID.randomUUID()); @@ -167,7 +170,8 @@ class SupervisionMessagesTest { participantId); var participantProvider = mock(ParticipantProvider.class); when(participantProvider.getSupportedElementMap()).thenReturn(supportedElementMap); - var publisher = new ParticipantPrimePublisher(participantProvider, mock(AcmParticipantProvider.class)); + var publisher = new ParticipantPrimePublisher(participantProvider, mock(AcmParticipantProvider.class), + CommonTestData.getTestParamaterGroup()); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML); @@ -176,7 +180,8 @@ class SupervisionMessagesTest { var acmDefinition = new AutomationCompositionDefinition(); acmDefinition.setCompositionId(UUID.randomUUID()); acmDefinition.setServiceTemplate(serviceTemplate); - var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate); + var acElements = AcmUtils + .extractAcElementsFromServiceTemplate(serviceTemplate, TOSCA_ELEMENT_NAME); acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.COMMISSIONED)); var preparation = publisher.prepareParticipantPriming(acmDefinition); publisher.sendPriming(preparation, acmDefinition.getCompositionId(), null); @@ -223,7 +228,7 @@ class SupervisionMessagesTest { @Test void testParticipantRestartPublisher() { - var publisher = new ParticipantRestartPublisher(); + var publisher = new ParticipantRestartPublisher(CommonTestData.getTestParamaterGroup()); var topicSink = mock(TopicSink.class); publisher.active(List.of(topicSink)); @@ -233,7 +238,8 @@ class SupervisionMessagesTest { var acmDefinition = new AutomationCompositionDefinition(); acmDefinition.setCompositionId(UUID.randomUUID()); acmDefinition.setServiceTemplate(serviceTemplate); - var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate); + var acElements = AcmUtils + .extractAcElementsFromServiceTemplate(serviceTemplate, ""); acmDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.PRIMED)); var automationComposition = diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java index 0620b05a3..54d312477 100755 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/CommonTestData.java @@ -24,6 +24,7 @@ import jakarta.ws.rs.core.Response.Status; import java.util.List; import java.util.UUID; import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; @@ -45,6 +46,9 @@ public class CommonTestData { private static final Coder CODER = new StandardCoder(); public static final String TOSCA_SERVICE_TEMPLATE_YAML = "clamp/acm/pmsh/funtional-pmsh-usecase.yaml"; + public static final String TOSCA_COMP_NAME = "org.onap.policy.clamp.acm.AutomationComposition"; + public static final String TOSCA_ELEMENT_NAME = "org.onap.policy.clamp.acm.AutomationCompositionElement"; + /** * Gets the standard automation composition parameters. * @@ -127,7 +131,8 @@ public class CommonTestData { acDefinition.setCompositionId(UUID.randomUUID()); acDefinition.setState(state); acDefinition.setServiceTemplate(serviceTemplate); - var acElements = AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate); + var acElements = AcmUtils + .extractAcElementsFromServiceTemplate(serviceTemplate, TOSCA_ELEMENT_NAME); acDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, state)); if (AcTypeState.PRIMED.equals(state)) { for (var element : acDefinition.getElementStateMap().values()) { @@ -137,4 +142,18 @@ public class CommonTestData { return acDefinition; } + /** + * Create a new Test parameter group. + * + * @return a new AutomationCompositionDefinition + */ + public static AcRuntimeParameterGroup getTestParamaterGroup() { + var acRuntimeParameterGroup = new AcRuntimeParameterGroup(); + AcmParameters acmParameters = new AcmParameters(); + acmParameters.setToscaCompositionName(TOSCA_COMP_NAME); + acmParameters.setToscaElementName(TOSCA_ELEMENT_NAME); + acRuntimeParameterGroup.setAcmParameters(acmParameters); + return acRuntimeParameterGroup; + } + } |