diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-05-16 15:24:54 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-05-17 09:32:57 +0000 |
commit | db6eb3fc07398e31dfa664992117f33fa8489cec (patch) | |
tree | f492919cd5b1c2973e91b4866e49e1deb36f524b /runtime-acm/src/test/java/org/onap | |
parent | 722523f568a682f1e48f6998c24c945802fec782 (diff) |
Add extend instance deletion support in ACM
Extend the functionality of deletion step to also inform the participant of instance deletion. This allow the participant to take any necessary steps that might result from instance deletion.
Issue-ID: POLICY-4686
Change-Id: Ibeb44d472da20ad98dafa9ddd7ded28398f4ed10
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test/java/org/onap')
3 files changed, 32 insertions, 6 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java index 9f39d8dc6..faf356c22 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java @@ -95,8 +95,9 @@ class AutomationCompositionInstantiationProviderTest { var compositionId = acDefinition.getCompositionId(); when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition)); var acProvider = mock(AutomationCompositionProvider.class); - var instantiationProvider = - new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, null, null); + var supervisionAcHandler = mock(SupervisionAcHandler.class); + var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, acDefinitionProvider, + null, supervisionAcHandler); var automationCompositionCreate = InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud"); automationCompositionCreate.setCompositionId(compositionId); @@ -136,7 +137,7 @@ class AutomationCompositionInstantiationProviderTest { instantiationProvider.deleteAutomationComposition(automationCompositionCreate.getCompositionId(), automationCompositionCreate.getInstanceId()); - verify(acProvider).deleteAutomationComposition(automationCompositionCreate.getInstanceId()); + verify(supervisionAcHandler).delete(any(), any()); } @Test @@ -146,9 +147,10 @@ class AutomationCompositionInstantiationProviderTest { var acProvider = mock(AutomationCompositionProvider.class); var acDefinitionProvider = mock(AcDefinitionProvider.class); + var supervisionAcHandler = mock(SupervisionAcHandler.class); var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, - acDefinitionProvider, null, null); + acDefinitionProvider, null, supervisionAcHandler); when(acProvider.getAutomationComposition(automationComposition.getInstanceId())) .thenReturn(automationComposition); @@ -168,6 +170,7 @@ class AutomationCompositionInstantiationProviderTest { when(acProvider.deleteAutomationComposition(instanceId)).thenReturn(automationComposition); instantiationProvider.deleteAutomationComposition(compositionId, instanceId); + verify(supervisionAcHandler).delete(any(), any()); } private void assertThatDeleteThrownBy(AutomationComposition automationComposition, diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java index fe0a477f9..5380d67a6 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java @@ -42,6 +42,7 @@ import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; @@ -268,7 +269,8 @@ class InstantiationControllerTest extends CommonRestController { var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions(compositionId, automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion()); - assertThat(automationCompositionsFromDb.getAutomationCompositionList()).isEmpty(); + assertEquals(DeployState.DELETING, + automationCompositionsFromDb.getAutomationCompositionList().get(0).getDeployState()); } @Test diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java index 032468a56..8ead9a7c0 100644 --- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java +++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java @@ -101,7 +101,28 @@ class SupervisionScannerTest { acRuntimeParameterGroup); supervisionScanner.run(false); - verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class)); + verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class)); + } + + @Test + void testScannerDelete() { + var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud"); + automationComposition.setDeployState(DeployState.DELETING); + automationComposition.setLockState(LockState.NONE); + var automationCompositionProvider = mock(AutomationCompositionProvider.class); + when(automationCompositionProvider.getAcInstancesByCompositionId(compositionId)) + .thenReturn(List.of(automationComposition)); + + var automationCompositionDeployPublisher = mock(AutomationCompositionDeployPublisher.class); + var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class); + var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner"); + + var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider, + automationCompositionStateChangePublisher, automationCompositionDeployPublisher, + acRuntimeParameterGroup); + supervisionScanner.run(false); + + verify(automationCompositionProvider).deleteAutomationComposition(automationComposition.getInstanceId()); } @Test |