diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-07-04 09:26:41 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-07-13 13:20:31 +0000 |
commit | ef0a60deb046c5bf5ed1a6209493dfde6a6457a9 (patch) | |
tree | 3e92ffecd8579cfb0ddabef80dee5586c695eda1 /participant/participant-impl/participant-impl-http/src/test | |
parent | 51ef04415186a0de3e50339b7fca04fb5ef079c9 (diff) |
Add restart support inside participants
Issue-ID: POLICY-4747
Change-Id: I09ca3e373f8271fbfe612c031920058b744cf413
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-http/src/test')
-rw-r--r-- | participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/handler/AcElementHandlerTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
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"); + } } |