diff options
author | 2024-06-14 14:10:58 +0100 | |
---|---|---|
committer | 2024-06-17 09:04:18 +0000 | |
commit | ca2ee94054c580827fcfc7f07c9db641301d6b9a (patch) | |
tree | 837edef253934aa10a09ecafa5819035b9ca0097 /participant/participant-impl/participant-impl-a1pms | |
parent | b52e095b34ee7c576f7ee83df05e2a09366a8c8a (diff) |
Remove restarting implementation from participants
Remove restarting implementation from participants and
Remove local Map from a1pms and kserve participants.
Issue-ID: POLICY-5046
Change-Id: I9cc2a33d603751c60007475414b45ca54f0aac25
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms')
3 files changed, 86 insertions, 260 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java index 75f3edb0a..47870ea39 100644 --- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java @@ -23,26 +23,21 @@ package org.onap.policy.clamp.acm.participant.a1pms.handler; import jakarta.validation.Validation; import jakarta.validation.ValidationException; import java.lang.invoke.MethodHandles; +import java.util.HashMap; import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import lombok.AccessLevel; -import lombok.Getter; import org.apache.http.HttpStatus; import org.onap.policy.clamp.acm.participant.a1pms.exception.A1PolicyServiceException; import org.onap.policy.clamp.acm.participant.a1pms.models.ConfigurationEntity; import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient; +import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto; +import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1; -import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; +import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV2; import org.onap.policy.clamp.models.acm.concepts.DeployState; -import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; -import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.base.PfModelException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -51,7 +46,7 @@ import org.springframework.stereotype.Component; * This class handles implementation of automationCompositionElement updates. */ @Component -public class AutomationCompositionElementHandler extends AcElementListenerV1 { +public class AutomationCompositionElementHandler extends AcElementListenerV2 { private static final Coder CODER = new StandardCoder(); @@ -59,10 +54,6 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 { private final AcA1PmsClient acA1PmsClient; - // Map of acElement Id and A1PMS services - @Getter(AccessLevel.PACKAGE) - private final Map<UUID, ConfigurationEntity> configRequestMap = new ConcurrentHashMap<>(); - public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, AcA1PmsClient acA1PmsClient) { super(intermediaryApi); @@ -72,20 +63,21 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 { /** * Handle a automation composition element state change. * - * @param automationCompositionId the ID of the automation composition - * @param automationCompositionElementId the ID of the automation composition element + * @param compositionElement the information of the Automation Composition Definition Element + * @param instanceElement the information of the Automation Composition Instance Element * @throws A1PolicyServiceException in case of a model exception */ @Override - public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) + public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws A1PolicyServiceException { - var configurationEntity = configRequestMap.get(automationCompositionElementId); + Map<String, Object> properties = new HashMap<>(compositionElement.inProperties()); + properties.putAll(instanceElement.inProperties()); + var configurationEntity = getConfigurationEntity(properties); if (configurationEntity != null && acA1PmsClient.isPmsHealthy()) { acA1PmsClient.deleteService(configurationEntity.getPolicyServiceEntities()); - configRequestMap.remove(automationCompositionElementId); - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, - "Undeployed"); + intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), + instanceElement.elementId(), DeployState.UNDEPLOYED, null, + StateChangeResult.NO_ERROR, "Undeployed"); } else { LOGGER.warn("Failed to connect with A1PMS. Service configuration is: {}", configurationEntity); throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE, "Unable to connect with A1PMS"); @@ -95,60 +87,45 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 { /** * Callback method to handle an update on an automation composition element. * - * @param automationCompositionId the ID of the automation composition - * @param element the information on the automation composition element - * @param properties properties Map + * @param compositionElement the information of the Automation Composition Definition Element + * @param instanceElement the information of the Automation Composition Instance Element + * @throws A1PolicyServiceException in case of a model exception */ @Override - public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties) + public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws A1PolicyServiceException { + Map<String, Object> properties = new HashMap<>(compositionElement.inProperties()); + properties.putAll(instanceElement.inProperties()); try { - var configurationEntity = CODER.convert(properties, ConfigurationEntity.class); - var violations = Validation.buildDefaultValidatorFactory().getValidator().validate(configurationEntity); - if (violations.isEmpty()) { - if (acA1PmsClient.isPmsHealthy()) { - acA1PmsClient.createService(configurationEntity.getPolicyServiceEntities()); - configRequestMap.put(element.getId(), configurationEntity); + var configurationEntity = getConfigurationEntity(properties); + if (acA1PmsClient.isPmsHealthy()) { + acA1PmsClient.createService(configurationEntity.getPolicyServiceEntities()); - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - } else { - LOGGER.error("Failed to connect with A1PMS"); - throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE, - "Unable to connect with A1PMS"); - } + intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(), + instanceElement.elementId(), DeployState.DEPLOYED, null, + StateChangeResult.NO_ERROR, "Deployed"); } else { - LOGGER.error("Violations found in the config request parameters: {}", violations); - throw new ValidationException("Constraint violations in the config request"); + LOGGER.error("Failed to connect with A1PMS"); + throw new A1PolicyServiceException(HttpStatus.SC_SERVICE_UNAVAILABLE, "Unable to connect with A1PMS"); } - } catch (ValidationException | CoderException | A1PolicyServiceException e) { + } catch (ValidationException | A1PolicyServiceException e) { throw new A1PolicyServiceException(HttpStatus.SC_BAD_REQUEST, "Invalid Configuration", e); } } - @Override - public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element, - Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException { - if (DeployState.DEPLOYING.equals(deployState)) { - deploy(automationCompositionId, element, properties); - return; - } - if (DeployState.UNDEPLOYING.equals(deployState) || DeployState.DEPLOYED.equals(deployState) - || DeployState.UPDATING.equals(deployState)) { - try { - var configurationEntity = CODER.convert(properties, ConfigurationEntity.class); - configRequestMap.put(element.getId(), configurationEntity); - } catch (ValidationException | CoderException e) { - throw new A1PolicyServiceException(HttpStatus.SC_BAD_REQUEST, "Invalid Configuration", e); + private ConfigurationEntity getConfigurationEntity(Map<String, Object> properties) throws A1PolicyServiceException { + try { + var configurationEntity = CODER.convert(properties, ConfigurationEntity.class); + try (var validatorFactory = Validation.buildDefaultValidatorFactory()) { + var violations = validatorFactory.getValidator().validate(configurationEntity); + if (!violations.isEmpty()) { + LOGGER.error("Violations found in the config request parameters: {}", violations); + throw new ValidationException("Constraint violations in the config request"); + } } + return configurationEntity; + } catch (CoderException e) { + throw new A1PolicyServiceException(HttpStatus.SC_BAD_REQUEST, "Invalid Configuration", e); } - if (DeployState.UNDEPLOYING.equals(deployState)) { - undeploy(automationCompositionId, element.getId()); - return; - } - deployState = AcmUtils.deployCompleted(deployState); - lockState = AcmUtils.lockCompleted(deployState, lockState); - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState, - lockState, StateChangeResult.NO_ERROR, "Restarted"); } } diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java index 1d3a262d6..37b102d48 100644 --- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AcElementHandlerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,9 +27,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.List; import java.util.Map; -import java.util.UUID; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -38,11 +36,8 @@ import org.onap.policy.clamp.acm.participant.a1pms.utils.CommonTestData; import org.onap.policy.clamp.acm.participant.a1pms.utils.ToscaUtils; import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.DeployState; -import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; -import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; class AcElementHandlerTest { @@ -72,23 +67,22 @@ class AcElementHandlerTest { var automationCompositionElementHandler = new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - var automationCompositionId = commonTestData.getAutomationCompositionId(); - var element = commonTestData.getAutomationCompositionElement(); - var automationCompositionElementId = element.getId(); - var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element, + var compositionElement = commonTestData.getCompositionElement( nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); + var element = commonTestData.getAutomationCompositionElement(); + + automationCompositionElementHandler.deploy(compositionElement, element); + verify(participantIntermediaryApi).updateAutomationCompositionElementState(element.instanceId(), + element.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - automationCompositionElementHandler.undeploy(automationCompositionId, automationCompositionElementId); - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); + automationCompositionElementHandler.undeploy(compositionElement, element); + verify(participantIntermediaryApi).updateAutomationCompositionElementState(element.instanceId(), + element.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE); - assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler - .undeploy(automationCompositionId, automationCompositionElementId)); + assertThrows(A1PolicyServiceException.class, + () -> automationCompositionElementHandler.undeploy(compositionElement, element)); } @Test @@ -97,12 +91,14 @@ class AcElementHandlerTest { var automationCompositionElementHandler = new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - var element = commonTestData.getAutomationCompositionElement(); var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element, + var compositionElement = commonTestData.getCompositionElement( nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); + var element = commonTestData.getAutomationCompositionElement(); + + automationCompositionElementHandler.deploy(compositionElement, element); verify(participantIntermediaryApi).updateAutomationCompositionElementState( - commonTestData.getAutomationCompositionId(), element.getId(), DeployState.DEPLOYED, null, + element.instanceId(), element.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); } @@ -112,13 +108,14 @@ class AcElementHandlerTest { var automationCompositionElementHandler = new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); + var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + var compositionElement = commonTestData.getCompositionElement( + nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); var element = commonTestData.getAutomationCompositionElement(); when(acA1PmsClient.isPmsHealthy()).thenReturn(Boolean.FALSE); - var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); assertThrows(A1PolicyServiceException.class, - () -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties())); + () -> automationCompositionElementHandler.deploy(compositionElement, element)); } @Test @@ -127,167 +124,9 @@ class AcElementHandlerTest { var automationCompositionElementHandler = new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); + var compositionElement = commonTestData.getCompositionElement(Map.of()); var element = commonTestData.getAutomationCompositionElement(); - assertThrows(A1PolicyServiceException.class, () -> automationCompositionElementHandler - .deploy(commonTestData.getAutomationCompositionId(), element, Map.of())); - } - - @Test - void testLock() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var elementId = UUID.randomUUID(); - automationCompositionElementHandler.lock(automationCompositionId, elementId); - - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, elementId, - null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked"); - } - - @Test - void testUnlock() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var elementId = UUID.randomUUID(); - automationCompositionElementHandler.unlock(automationCompositionId, elementId); - - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, elementId, - null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked"); - } - - @Test - void testUpdate() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var element = commonTestData.getAutomationCompositionElement(); - automationCompositionElementHandler.update(automationCompositionId, element, Map.of()); - - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - element.getId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Update not supported"); - } - - @Test - void testDelete() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var elementId = UUID.randomUUID(); - automationCompositionElementHandler.delete(automationCompositionId, elementId); - - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, elementId, - DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted"); - } - - @Test - void testPrime() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var compositionId = UUID.randomUUID(); - automationCompositionElementHandler.prime(compositionId, List.of()); - - verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, "Primed"); - } - - @Test - void testDeprime() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var compositionId = UUID.randomUUID(); - automationCompositionElementHandler.deprime(compositionId); - - verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED, - StateChangeResult.NO_ERROR, "Deprimed"); - } - - @Test - void testHandleRestartComposition() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var compositionId = UUID.randomUUID(); - automationCompositionElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMED); - - verify(participantIntermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, "Restarted"); - } - - @Test - void testHandleRestartInstanceDeploying() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var element = commonTestData.getAutomationCompositionElement(); - var automationCompositionElementId = element.getId(); - var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.handleRestartInstance(automationCompositionId, element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties(), DeployState.DEPLOYING, - LockState.NONE); - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - } - - @Test - void testHandleRestartInstanceDeployed() throws PfModelException { - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(intermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var element = commonTestData.getAutomationCompositionElement(); - var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.handleRestartInstance(automationCompositionId, element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties(), DeployState.DEPLOYED, - LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted"); - } - - @Test - void testHandleRestartInstanceUndeployed() throws PfModelException { - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(intermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var element = commonTestData.getAutomationCompositionElement(); - var automationCompositionElementId = element.getId(); - var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.handleRestartInstance(automationCompositionId, element, - nodeTemplatesMap.get(A1_AUTOMATION_COMPOSITION_ELEMENT).getProperties(), DeployState.UNDEPLOYING, - LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); - } - - @Test - void testMigrate() throws PfModelException { - var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(participantIntermediaryApi, acA1PmsClient); - - var automationCompositionId = UUID.randomUUID(); - var element = commonTestData.getAutomationCompositionElement(); - automationCompositionElementHandler.migrate(automationCompositionId, element, UUID.randomUUID(), Map.of()); - - verify(participantIntermediaryApi).updateAutomationCompositionElementState(automationCompositionId, - element.getId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated"); + assertThrows(A1PolicyServiceException.class, + () -> automationCompositionElementHandler.deploy(compositionElement, element)); } } diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java index d31e81fe8..89e834390 100644 --- a/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java +++ b/participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonTestData.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * Modifications Copyright (C) 2022 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,11 @@ package org.onap.policy.clamp.acm.participant.a1pms.utils; import java.util.List; +import java.util.Map; import java.util.UUID; import org.onap.policy.clamp.acm.participant.a1pms.models.A1PolicyServiceEntity; -import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; -import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; +import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto; +import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class CommonTestData { @@ -34,16 +35,25 @@ public class CommonTestData { private static final List<UUID> AC_ID_LIST = List.of(UUID.randomUUID(), UUID.randomUUID()); /** - * Get a automationComposition Element. + * Get a new InstanceElement. * - * @return automationCompositionElement object + * @return InstanceElementDto object */ - public AcElementDeploy getAutomationCompositionElement() { - var element = new AcElementDeploy(); - element.setId(UUID.randomUUID()); - element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1")); - element.setOrderedState(DeployOrder.DEPLOY); - return element; + public InstanceElementDto getAutomationCompositionElement() { + return new InstanceElementDto( + getAutomationCompositionId(), UUID.randomUUID(), null, Map.of(), Map.of()); + } + + /** + * Get a new CompositionElement. + * + * @param properties common properties from service template + * @return CompositionElementDto object + */ + public CompositionElementDto getCompositionElement(Map<String, Object> properties) { + return new CompositionElementDto(UUID.randomUUID(), + new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"), + properties, Map.of()); } /** |