aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-http
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-http')
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java23
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java44
2 files changed, 67 insertions, 0 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 e3ebf3bef..9d4718bea 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
@@ -39,6 +39,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDef
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;
@@ -156,4 +157,26 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
"Deprimed");
}
+
+ @Override
+ public void handleRestartComposition(UUID compositionId,
+ List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
+ throws PfModelException {
+ var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
+ : AcTypeState.COMMISSIONED;
+ intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
+ }
+
+ @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;
+ }
+ 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-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 f0f991302..de0d21e6d 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
@@ -196,4 +196,48 @@ class AcElementHandlerTest {
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, mock(AcHttpClient.class));
+
+ 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 serviceTemplate = ToscaUtils.readAutomationCompositionFromTosca();
+ var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+ var map = new HashMap<>(nodeTemplatesMap.get(HTTP_AUTOMATION_COMPOSITION_ELEMENT).getProperties());
+ var element = commonTestData.getAutomationCompositionElement();
+ map.putAll(element.getProperties());
+ var instanceId = commonTestData.getAutomationCompositionId();
+ var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
+
+ automationCompositionElementHandler.handleRestartInstance(instanceId, element, map, DeployState.DEPLOYING,
+ LockState.NONE);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ }
+
+ @Test
+ void testHandleRestartInstanceDeployed() throws PfModelException {
+ var element = commonTestData.getAutomationCompositionElement();
+ var instanceId = commonTestData.getAutomationCompositionId();
+ var participantIntermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var automationCompositionElementHandler =
+ new AutomationCompositionElementHandler(participantIntermediaryApi, mock(AcHttpClient.class));
+
+ automationCompositionElementHandler.handleRestartInstance(instanceId, element, element.getProperties(),
+ DeployState.DEPLOYED, LockState.LOCKED);
+ verify(participantIntermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted");
+ }
}