diff options
author | 2023-06-07 14:25:33 +0100 | |
---|---|---|
committer | 2023-06-12 08:47:50 +0100 | |
commit | 31090c9fbc6c29477acd784a6c9f03766b5cc981 (patch) | |
tree | 85b23dd0714707629ba11d190f2237b3ecf7061c /participant/participant-impl/participant-impl-policy/src/test | |
parent | 5ccedbf315e6879005e1748baaccbfda9e81097e (diff) |
Add failure handling support in Intermediary
Add Failure handling support in Intermediary,
and refactor the communication between Participant and Intermediary.
Issue-ID: POLICY-4707
Change-Id: Ica22e0e820efda372886d6d8da9c3526633321e2
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 | 51 |
1 files changed, 21 insertions, 30 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 ec55c178f..84ddeed74 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 @@ -57,10 +57,9 @@ class AutomationCompositionElementHandlerTest { @Test void testHandlerUndeployNoPolicy() throws PfModelException { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.undeploy(AC_ID, automationCompositionElementId); verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, @@ -90,9 +89,8 @@ class AutomationCompositionElementHandlerTest { var pap = mock(PolicyPapHttpClient.class); doReturn(Response.accepted().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any()); - var handler = new AutomationCompositionElementHandler(api, pap); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); handler.deploy(AC_ID, getTestingAcElement(), Map.of()); verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, @@ -105,10 +103,9 @@ class AutomationCompositionElementHandlerTest { @Test void testDeployNoPolicy() throws PfModelException { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); var acElement = getTestingAcElement(); acElement.getToscaServiceTemplateFragment().setToscaTopologyTemplate(null); @@ -126,9 +123,9 @@ class AutomationCompositionElementHandlerTest { var pap = mock(PolicyPapHttpClient.class); doReturn(Response.accepted().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any()); - var handler = new AutomationCompositionElementHandler(api, pap); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); + var element = getTestingAcElement(); // Mock failure in policy type creation @@ -147,9 +144,9 @@ class AutomationCompositionElementHandlerTest { var pap = mock(PolicyPapHttpClient.class); doReturn(Response.serverError().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any()); - var handler = new AutomationCompositionElementHandler(api, pap); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); + var element = getTestingAcElement(); assertThatThrownBy(() -> handler.deploy(AC_ID, element, Map.of())) .hasMessageMatching("Deploy of Policy failed."); @@ -157,10 +154,9 @@ class AutomationCompositionElementHandlerTest { @Test void testUpdate() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); var acElement = getTestingAcElement(); acElement.getToscaServiceTemplateFragment().setToscaTopologyTemplate(null); @@ -171,10 +167,9 @@ class AutomationCompositionElementHandlerTest { @Test void testLock() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.lock(AC_ID, automationCompositionElementId); verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, null, @@ -183,10 +178,9 @@ class AutomationCompositionElementHandlerTest { @Test void testUnlock() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.unlock(AC_ID, automationCompositionElementId); verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, null, @@ -195,10 +189,9 @@ class AutomationCompositionElementHandlerTest { @Test void testDelete() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.delete(AC_ID, automationCompositionElementId); verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, @@ -207,10 +200,9 @@ class AutomationCompositionElementHandlerTest { @Test void testPrime() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.prime(AC_ID, List.of()); verify(intermediaryApi).updateCompositionState(AC_ID, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed"); @@ -218,10 +210,9 @@ class AutomationCompositionElementHandlerTest { @Test void testDeprime() throws Exception { - var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class)); var intermediaryApi = mock(ParticipantIntermediaryApi.class); - handler.setIntermediaryApi(intermediaryApi); + var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), + mock(PolicyPapHttpClient.class), intermediaryApi); handler.deprime(AC_ID); verify(intermediaryApi).updateCompositionState(AC_ID, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR, |