diff options
Diffstat (limited to 'runtime-acm/src')
22 files changed, 218 insertions, 73 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java index 3400b2e60..dd0ddaae9 100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java @@ -26,8 +26,8 @@ import java.util.HashSet; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; +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.models.acm.concepts.AcTypeState; @@ -52,13 +52,13 @@ import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class CommissioningProvider { - public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition"; private final AcDefinitionProvider acDefinitionProvider; private final AutomationCompositionProvider acProvider; private final AcmParticipantProvider acmParticipantProvider; private final AcTypeStateResolver acTypeStateResolver; private final ParticipantPrimePublisher participantPrimePublisher; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; private final ExecutorService executor = Executors.newFixedThreadPool(1); @@ -87,7 +87,9 @@ public class CommissioningProvider { @Transactional public CommissioningResponse createAutomationCompositionDefinition(ToscaServiceTemplate serviceTemplate) { - var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate); + var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate, + acRuntimeParameterGroup.getAcmParameters().getToscaElementName(), + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); serviceTemplate = acmDefinition.getServiceTemplate(); return createCommissioningResponse(acmDefinition.getCompositionId(), serviceTemplate); } @@ -110,7 +112,9 @@ public class CommissioningProvider { throw new PfModelRuntimeException(Status.BAD_REQUEST, "ACM not in COMMISSIONED state, Update of ACM Definition not allowed"); } - acDefinitionProvider.updateServiceTemplate(compositionId, serviceTemplate); + acDefinitionProvider.updateServiceTemplate(compositionId, serviceTemplate, + acRuntimeParameterGroup.getAcmParameters().getToscaElementName(), + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); return createCommissioningResponse(compositionId, serviceTemplate); } @@ -208,7 +212,8 @@ public class CommissioningProvider { private void prime(AutomationCompositionDefinition acmDefinition) { acmDefinition.setStateChangeResult(StateChangeResult.NO_ERROR); var preparation = participantPrimePublisher.prepareParticipantPriming(acmDefinition); - acDefinitionProvider.updateAcDefinition(acmDefinition); + acDefinitionProvider.updateAcDefinition(acmDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); executor.execute( () -> participantPrimePublisher.sendPriming(preparation, acmDefinition.getCompositionId(), null)); @@ -228,7 +233,8 @@ public class CommissioningProvider { acmParticipantProvider.verifyParticipantState(participantIds); } acmDefinition.setState(AcTypeState.DEPRIMING); - acDefinitionProvider.updateAcDefinition(acmDefinition); + acDefinitionProvider.updateAcDefinition(acmDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); executor.execute(() -> participantPrimePublisher.sendDepriming(acmDefinition.getCompositionId())); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index f8d5894b3..977708ee1 100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -27,6 +27,7 @@ import jakarta.ws.rs.core.Response.Status; import java.util.UUID; import java.util.stream.Collectors; import lombok.AllArgsConstructor; +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.models.acm.concepts.AcTypeState; @@ -63,6 +64,7 @@ public class AutomationCompositionInstantiationProvider { private final AcInstanceStateResolver acInstanceStateResolver; private final SupervisionAcHandler supervisionAcHandler; private final AcmParticipantProvider acmParticipantProvider; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Create automation composition. @@ -207,7 +209,8 @@ public class AutomationCompositionInstantiationProvider { acmParticipantProvider.verifyParticipantState(participantIds); result.addResult(AcmUtils.validateAutomationComposition(automationComposition, - acDefinitionOpt.get().getServiceTemplate())); + acDefinitionOpt.get().getServiceTemplate(), + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName())); if (result.isValid()) { for (var element : automationComposition.getElements().values()) { diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java index 87aa92386..a30b531a4 100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcRuntimeParameterGroup.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021,2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,4 +46,8 @@ public class AcRuntimeParameterGroup { @NotNull @ParameterGroupConstraint private TopicParameterGroup topicParameterGroup; + + @Valid + @NotNull + private AcmParameters acmParameters = new AcmParameters(); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java new file mode 100644 index 000000000..3ae21e5fb --- /dev/null +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/AcmParameters.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.runtime.main.parameters; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.validation.annotation.Validated; + +/** + * Parameters for ac element name and ac node type. + */ +@Getter +@Setter +@Validated +public class AcmParameters { + + // Default values for the element name and composition name + private String toscaElementName = "org.onap.policy.clamp.acm.AutomationCompositionElement"; + + private String toscaCompositionName = "org.onap.policy.clamp.acm.AutomationComposition"; + +} diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java index 4f58801c3..6090c644c 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.runtime.supervision; import io.micrometer.core.annotation.Timed; import lombok.AllArgsConstructor; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; @@ -42,6 +43,7 @@ public class SupervisionHandler { private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionHandler.class); private final AcDefinitionProvider acDefinitionProvider; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Handle a ParticipantPrimeAck message from a participant. @@ -101,7 +103,8 @@ public class SupervisionHandler { if (!restarting) { acDefinition.setRestarting(null); } - acDefinitionProvider.updateAcDefinition(acDefinition); + acDefinitionProvider.updateAcDefinition(acDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java index ebccc2f66..4c136c478 100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.UUID; import lombok.AllArgsConstructor; import org.apache.commons.collections4.MapUtils; +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; @@ -63,6 +64,7 @@ public class SupervisionParticipantHandler { private final AutomationCompositionProvider automationCompositionProvider; private final AcDefinitionProvider acDefinitionProvider; private final ParticipantRestartPublisher participantRestartPublisher; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Handle a ParticipantRegister message from a participant. @@ -153,7 +155,8 @@ public class SupervisionParticipantHandler { } } } - acDefinitionProvider.updateAcDefinition(acDefinition); + acDefinitionProvider.updateAcDefinition(acDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); } private void checkOnline(Participant participant) { @@ -196,7 +199,8 @@ public class SupervisionParticipantHandler { acDefinition.setStateChangeResult(StateChangeResult.NO_ERROR); } acDefinition.setRestarting(true); - acDefinitionProvider.updateAcDefinition(acDefinition); + acDefinitionProvider.updateAcDefinition(acDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); participantRestartPublisher.send(participantId, acDefinition, automationCompositions); } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java index 0ccdaed3e..15283609a 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java @@ -56,6 +56,7 @@ public class SupervisionScanner { private final AcDefinitionProvider acDefinitionProvider; private final AutomationCompositionStateChangePublisher automationCompositionStateChangePublisher; private final AutomationCompositionDeployPublisher automationCompositionDeployPublisher; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Constructor for instantiating SupervisionScanner. @@ -75,6 +76,7 @@ public class SupervisionScanner { this.acDefinitionProvider = acDefinitionProvider; this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher; this.automationCompositionDeployPublisher = automationCompositionDeployPublisher; + this.acRuntimeParameterGroup = acRuntimeParameterGroup; acTimeout.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs()); } @@ -227,7 +229,8 @@ public class SupervisionScanner { LOGGER.debug("Report timeout for the ac definition {}", acDefinition.getCompositionId()); acTimeout.setTimeout(compositionId); acDefinition.setStateChangeResult(StateChangeResult.TIMEOUT); - acDefinitionProvider.updateAcDefinition(acDefinition); + acDefinitionProvider.updateAcDefinition(acDefinition, + acRuntimeParameterGroup.getAcmParameters().getToscaCompositionName()); } } diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java index 539a992ff..f3fcfe67a 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import lombok.AllArgsConstructor; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition; @@ -53,6 +54,7 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part private final ParticipantProvider participantProvider; private final AcmParticipantProvider acmParticipantProvider; + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Send ParticipantPrime to Participant @@ -83,7 +85,8 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part */ public List<ParticipantDefinition> prepareParticipantPriming(AutomationCompositionDefinition acmDefinition) { acmDefinition.setState(AcTypeState.PRIMING); - var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate()); + var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate(), + acRuntimeParameterGroup.getAcmParameters().getToscaElementName()); Map<ToscaConceptIdentifier, UUID> supportedElementMap = new HashMap<>(); var participantIds = new HashSet<UUID>(); if (AcTypeState.PRIMED.equals(acmDefinition.getState())) { diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java index c00116e3b..163d3299d 100755 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.UUID; import lombok.AllArgsConstructor; +import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup; 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.ParticipantDefinition; @@ -46,6 +47,7 @@ import org.springframework.stereotype.Component; public class ParticipantRestartPublisher extends AbstractParticipantPublisher<ParticipantRestart> { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRestartPublisher.class); + private final AcRuntimeParameterGroup acRuntimeParameterGroup; /** * Send Restart to Participant. @@ -86,7 +88,8 @@ public class ParticipantRestartPublisher extends AbstractParticipantPublisher<Pa private List<ParticipantDefinition> prepareParticipantRestarting(UUID participantId, AutomationCompositionDefinition acmDefinition) { - var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate()); + var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate(), + acRuntimeParameterGroup.getAcmParameters().getToscaElementName()); // list of entry entry filtered by participantId List<Entry<String, ToscaNodeTemplate>> elementList = new ArrayList<>(); diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml index 6a0213720..84ddcfc76 100755 --- a/runtime-acm/src/main/resources/application.yaml +++ b/runtime-acm/src/main/resources/application.yaml @@ -61,6 +61,9 @@ runtime: servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap + acmParameters: + toscaElementName: org.onap.policy.clamp.acm.AutomationCompositionElement + toscaCompositionName: org.onap.policy.clamp.acm.AutomationComposition management: endpoints: diff --git a/runtime-acm/src/main/resources/openapi/openapi.yaml b/runtime-acm/src/main/resources/openapi/openapi.yaml index 74f1d4874..988b9d164 100644 --- a/runtime-acm/src/main/resources/openapi/openapi.yaml +++ b/runtime-acm/src/main/resources/openapi/openapi.yaml @@ -1011,12 +1011,12 @@ paths: schema: $ref: '#/components/schemas/AutomationCompositions' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstancesResponse.json' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getAllCompositionInstancesResponse.json' application/yaml: schema: $ref: '#/components/schemas/AutomationCompositions' example: - externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getCompositionInstancesResponse.yaml' + externalValue: 'https://raw.githubusercontent.com/onap/policy-clamp/master/runtime-acm/src/main/resources/openapi/examples/getAllCompositionInstancesResponse.yaml' 401: description: Authentication Error, returns an instance of [SimpleResponse](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/SimpleResponse.java) 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; + } + } diff --git a/runtime-acm/src/test/resources/application-test.yaml b/runtime-acm/src/test/resources/application-test.yaml index e6fed2475..aa4044534 100644 --- a/runtime-acm/src/test/resources/application-test.yaml +++ b/runtime-acm/src/test/resources/application-test.yaml @@ -38,3 +38,6 @@ runtime: servers: - localhost topic: POLICY-ACRUNTIME-PARTICIPANT + acmParameters: + acElementName: org.onap.policy.clamp.acm.AutomationCompositionElement + acNodeType: org.onap.policy.clamp.acm.AutomationComposition diff --git a/runtime-acm/src/test/resources/parameters/TestParameters.json b/runtime-acm/src/test/resources/parameters/TestParameters.json index c44e92e4d..92e81d29e 100644 --- a/runtime-acm/src/test/resources/parameters/TestParameters.json +++ b/runtime-acm/src/test/resources/parameters/TestParameters.json @@ -40,5 +40,10 @@ "topicCommInfrastructure": "dmaap" } ] + }, + "acmParameters": { + "toscaElementName": "org.onap.policy.clamp.acm.AutomationCompositionElement", + "toscaCompositionName": "org.onap.policy.clamp.acm.AutomationComposition" } + } |