diff options
Diffstat (limited to 'participant/participant-impl/participant-impl-http')
3 files changed, 24 insertions, 58 deletions
diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java index 42b26c6a4..c62216dfc 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 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. @@ -38,10 +38,9 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient; import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; +import org.onap.policy.clamp.models.acm.concepts.DeployState; +import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -73,34 +72,13 @@ public class AutomationCompositionElementHandler implements AutomationCompositio * Handle a automation composition element state change. * * @param automationCompositionElementId the ID of the automation composition element - * @param currentState the current state of the automation composition element - * @param newState the state to which the automation composition element is changing to * @throws PfModelException in case of a model exception */ @Override - public void automationCompositionElementStateChange(UUID automationCompositionId, - UUID automationCompositionElementId, AutomationCompositionState currentState, - AutomationCompositionOrderedState newState) { - switch (newState) { - case UNINITIALISED: - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, - ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); - break; - case PASSIVE: - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, - ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); - break; - case RUNNING: - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, - automationCompositionElementId, newState, AutomationCompositionState.RUNNING, - ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); - break; - default: - LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); - break; - } + public void undeploy(UUID automationCompositionId, + UUID automationCompositionElementId) { + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, DeployState.UNDEPLOYED, LockState.NONE); } /** @@ -111,8 +89,8 @@ public class AutomationCompositionElementHandler implements AutomationCompositio * @param properties properties Map */ @Override - public void automationCompositionElementUpdate(UUID automationCompositionId, - AutomationCompositionElement element, Map<String, Object> properties) { + public void deploy(UUID automationCompositionId, + AcElementDeploy element, Map<String, Object> properties) { try { var configRequest = CODER.convert(properties, ConfigRequest.class); var violations = @@ -124,8 +102,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio .is2xxSuccessful()).collect(Collectors.toList()); if (failedResponseStatus.isEmpty()) { intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE, - ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + DeployState.DEPLOYED, LockState.LOCKED); } else { LOGGER.error("Error on Invoking the http request: {}", failedResponseStatus); } diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java index 8e77b2acc..857490ef5 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 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. @@ -38,8 +38,6 @@ import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest; import org.onap.policy.clamp.acm.participant.http.utils.CommonTestData; import org.onap.policy.clamp.acm.participant.http.utils.ToscaUtils; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -49,13 +47,13 @@ class AcElementHandlerTest { @InjectMocks @Spy private AutomationCompositionElementHandler automationCompositionElementHandler = - new AutomationCompositionElementHandler(); + new AutomationCompositionElementHandler(); private final CommonTestData commonTestData = new CommonTestData(); private static ToscaServiceTemplate serviceTemplate; private static final String HTTP_AUTOMATION_COMPOSITION_ELEMENT = - "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement"; + "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement"; @BeforeAll static void init() { @@ -76,17 +74,8 @@ class AcElementHandlerTest { var config = Mockito.mock(ConfigRequest.class); assertDoesNotThrow(() -> automationCompositionElementHandler.invokeHttpClient(config)); - assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( - automationCompositionId, automationCompositionElementId, AutomationCompositionState.PASSIVE, - AutomationCompositionOrderedState.RUNNING)); + assertDoesNotThrow(() -> automationCompositionElementHandler.undeploy( + automationCompositionId, automationCompositionElementId)); automationCompositionElementHandler.close(); } @@ -100,7 +89,7 @@ class AcElementHandlerTest { var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); map.putAll(element.getProperties()); - assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementUpdate( - commonTestData.getAutomationCompositionId(), element, map)); + assertDoesNotThrow(() -> automationCompositionElementHandler + .deploy(commonTestData.getAutomationCompositionId(), element, map)); } } diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java index 48b7bdcd7..7ae9b3359 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonTestData.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,8 +26,8 @@ import java.util.Map; import java.util.UUID; import org.onap.policy.clamp.acm.participant.http.main.models.ConfigurationEntity; import org.onap.policy.clamp.acm.participant.http.main.models.RestParams; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class CommonTestData { @@ -41,11 +41,11 @@ public class CommonTestData { * * @return automationCompositionElement object */ - public AutomationCompositionElement getAutomationCompositionElement() { - AutomationCompositionElement element = new AutomationCompositionElement(); + public AcElementDeploy getAutomationCompositionElement() { + var element = new AcElementDeploy(); element.setId(UUID.randomUUID()); element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1")); - element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + element.setOrderedState(DeployOrder.DEPLOY); return element; } |