diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-10-22 10:24:57 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-10-22 13:37:05 +0100 |
commit | c5b350ae7a06977e5d35d9372e7b762be1bd24c9 (patch) | |
tree | 2daf37483aa0e478cd4527683e1b14ab12191a84 | |
parent | 20ad241b626db4d44bffd08ca0e5d6f2d8f4be4d (diff) |
Fix outProperties message in participant simulator
Issue-ID: POLICY-5145
Change-Id: I1a597ad17aeda4dcdcd863da97bb61eeb0bdaa09
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
5 files changed, 17 insertions, 14 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java index 534b01b32..839ae3c1d 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java @@ -20,6 +20,7 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -99,6 +100,7 @@ public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 { Map<String, Object> properties) { LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}", instanceId, element, compositionTargetId, properties); - simulatorService.migrate(instanceId, element.getId(), 0, Map.of()); + + simulatorService.migrate(instanceId, element.getId(), 0, properties, new HashMap<>()); } } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java index 82602c1e1..154d559d9 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java @@ -126,7 +126,7 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 { simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId()); } else { simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId(), - 0, compositionElementTarget.inProperties()); + 0, compositionElementTarget.inProperties(), instanceElementMigrate.outProperties()); } } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java index e406a6127..8ffca7e4f 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java @@ -20,8 +20,6 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler; -import java.util.ArrayList; -import java.util.List; import lombok.Getter; import lombok.Setter; import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto; @@ -131,13 +129,7 @@ public class AutomationCompositionElementHandlerV3 extends AcElementListenerV3 { simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId()); } else { simulatorService.migrate(instanceElementMigrate.instanceId(), instanceElementMigrate.elementId(), stage, - compositionElementTarget.inProperties()); - instanceElementMigrate.outProperties().putIfAbsent("stage", new ArrayList<>()); - @SuppressWarnings("unchecked") - var stageList = (List<Integer>) instanceElementMigrate.outProperties().get("stage"); - stageList.add(stage); - intermediaryApi.sendAcElementInfo(instanceElementMigrate.instanceId(), instanceElementMigrate.elementId(), - null, null, instanceElementMigrate.outProperties()); + compositionElementTarget.inProperties(), instanceElementMigrate.outProperties()); } } diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java index b0006f711..284aa0e5a 100644 --- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java +++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java @@ -21,6 +21,7 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler; import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.UUID; import lombok.Getter; @@ -330,7 +331,8 @@ public class SimulatorService { * @param elementId the elementId * @param stage the stage */ - public void migrate(UUID instanceId, UUID elementId, int stage, Map<String, Object> compositionInProperties) { + public void migrate(UUID instanceId, UUID elementId, int stage, Map<String, Object> compositionInProperties, + Map<String, Object> instanceOutProperties) { if (!execution(getConfig().getMigrateTimerMs(), "Current Thread migrate is Interrupted during execution {}", elementId)) { return; @@ -344,6 +346,11 @@ public class SimulatorService { nextStage = Math.min(s, nextStage); } } + instanceOutProperties.putIfAbsent("stage", new ArrayList<>()); + @SuppressWarnings("unchecked") + var stageList = (List<Integer>) instanceOutProperties.get("stage"); + stageList.add(stage); + intermediaryApi.sendAcElementInfo(instanceId, elementId, null, null, instanceOutProperties); if (nextStage == 1000) { intermediaryApi.updateAutomationCompositionElementState( instanceId, elementId, diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java index f3a1839f0..e89a82696 100644 --- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java +++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2Test.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import java.util.HashMap; import java.util.Map; import java.util.UUID; import org.junit.jupiter.api.Test; @@ -208,7 +209,7 @@ class AutomationCompositionElementHandlerV2Test { Map.of(), Map.of()); var instanceElementMigrated = new InstanceElementDto( INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(), - null, Map.of("key", "value"), Map.of()); + null, Map.of("key", "value"), new HashMap<>()); acElementHandler .migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated); verify(intermediaryApi).updateAutomationCompositionElementState( @@ -240,7 +241,8 @@ class AutomationCompositionElementHandlerV2Test { var compoElTargetAdd = new CompositionElementDto( UUID.randomUUID(), new ToscaConceptIdentifier(), Map.of(), Map.of(), ElementState.NEW); var inElMigratedAdd = new InstanceElementDto( - instanceElement.instanceId(), instanceElement.elementId(), null, Map.of(), Map.of(), ElementState.NEW); + instanceElement.instanceId(), instanceElement.elementId(), null, + Map.of(), new HashMap<>(), ElementState.NEW); acElementHandler .migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd); verify(intermediaryApi).updateAutomationCompositionElementState( |