From c5b350ae7a06977e5d35d9372e7b762be1bd24c9 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Tue, 22 Oct 2024 10:24:57 +0100 Subject: Fix outProperties message in participant simulator Issue-ID: POLICY-5145 Change-Id: I1a597ad17aeda4dcdcd863da97bb61eeb0bdaa09 Signed-off-by: FrancescoFioraEst --- .../main/handler/AutomationCompositionElementHandlerV1.java | 4 +++- .../main/handler/AutomationCompositionElementHandlerV2.java | 2 +- .../main/handler/AutomationCompositionElementHandlerV3.java | 10 +--------- .../acm/participant/sim/main/handler/SimulatorService.java | 9 ++++++++- .../handler/AutomationCompositionElementHandlerV2Test.java | 6 ++++-- 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 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) 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 compositionInProperties) { + public void migrate(UUID instanceId, UUID elementId, int stage, Map compositionInProperties, + Map 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) 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( -- cgit 1.2.3-korg