diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-09-28 14:52:56 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-09-28 13:56:15 +0000 |
commit | aea5fd0812915d824887c9c304253859853d568b (patch) | |
tree | 59710589a236cfa5ea4eb533b51795524d379ec8 /participant/participant-impl/participant-impl-simulator/src/test/java | |
parent | bceec3f67b8d6fa79cc3594f7672924b27e39984 (diff) |
Add migration support in ACM participant simulator
Issue-ID: POLICY-4826
Change-Id: Idf492cc8941ce6b2800d1ea88789cca103a33b2c
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/test/java')
-rwxr-xr-x | participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java index ed3f0745b..d7c9e17ad 100755 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java @@ -162,7 +162,7 @@ class AutomationCompositionElementHandlerTest { } @Test - void testgetAutomationComposition() throws PfModelException { + void testgetAutomationCompositions() throws PfModelException { var intermediaryApi = mock(ParticipantIntermediaryApi.class); var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi); @@ -173,6 +173,17 @@ class AutomationCompositionElementHandlerTest { } @Test + void testgetAutomationComposition() throws PfModelException { + var intermediaryApi = mock(ParticipantIntermediaryApi.class); + var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi); + + var instance = CommonTestData.getTestAutomationCompositionMap().values().iterator().next(); + when(intermediaryApi.getAutomationComposition(instance.getInstanceId())).thenReturn(instance); + var result = acElementHandler.getAutomationComposition(instance.getInstanceId()); + assertEquals(instance, result); + } + + @Test void testsetOutProperties() { var intermediaryApi = mock(ParticipantIntermediaryApi.class); var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi); @@ -334,4 +345,24 @@ class AutomationCompositionElementHandlerTest { acElementHandler.setCompositionOutProperties(compositionId, null, Map.of()); verify(intermediaryApi).sendAcDefinitionInfo(compositionId, null, Map.of()); } + + @Test + void testMigrate() throws PfModelException { + var config = new SimConfig(); + config.setUpdateTimerMs(1); + var intermediaryApi = mock(ParticipantIntermediaryApi.class); + var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi); + acElementHandler.setConfig(config); + var instanceId = UUID.randomUUID(); + var element = new AcElementDeploy(); + element.setId(UUID.randomUUID()); + acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of()); + verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), + DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated"); + + config.setMigrateSuccess(false); + acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of()); + verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), + DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!"); + } } |