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-policy/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-policy/src/test')
-rw-r--r-- | participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java index 84ddeed74..16530d69f 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java @@ -218,4 +218,53 @@ class AutomationCompositionElementHandlerTest { verify(intermediaryApi).updateCompositionState(AC_ID, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR, "Deprimed"); } + + @Test + void testHandleRestartComposition() throws PfModelException { + var intermediaryApi = mock(ParticipantIntermediaryApi.class); + var automationCompositionElementHandler = + new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); + + var compositionId = UUID.randomUUID(); + automationCompositionElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMED); + + verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, + StateChangeResult.NO_ERROR, "Restarted"); + } + + @Test + void testHandleRestartInstanceDeploying() throws PfModelException { + // Mock success scenario for policy creation and deployment + var api = mock(PolicyApiHttpClient.class); + doReturn(Response.ok().build()).when(api).createPolicyType(any()); + doReturn(Response.ok().build()).when(api).createPolicy(any()); + + var pap = mock(PolicyPapHttpClient.class); + doReturn(Response.accepted().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any()); + + var intermediaryApi = mock(ParticipantIntermediaryApi.class); + var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); + var element = getTestingAcElement(); + + handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.DEPLOYING, LockState.NONE); + verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, + DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); + + handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.UNDEPLOYING, LockState.LOCKED); + verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, + DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); + } + + @Test + void testHandleRestartInstanceDeployed() throws PfModelException { + var api = mock(PolicyApiHttpClient.class); + var pap = mock(PolicyPapHttpClient.class); + var intermediaryApi = mock(ParticipantIntermediaryApi.class); + var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); + var element = getTestingAcElement(); + handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKED); + verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, + DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted"); + } } |