aboutsummaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-08-08 14:12:15 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2024-08-08 14:06:01 +0000
commit3f7d3771a0e5a5d8f186a966963d28528250fc6f (patch)
treee1062471e2cf14e29fa594b7e2cc4eae49616611 /participant
parenta2477d552ad3993989a4f8b7a7adac6686719cf3 (diff)
Update participant simulator to test migration stage
Issue-ID: POLICY-5092 Change-Id: I82eb7b9b6f102abefd68f3de6d8c3837cda60d51 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java10
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java12
2 files changed, 15 insertions, 7 deletions
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 3e9db9031..e406a6127 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,6 +20,8 @@
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;
@@ -128,8 +130,14 @@ public class AutomationCompositionElementHandlerV3 extends AcElementListenerV3 {
simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
} else {
- simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId(), stage,
+ 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());
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
index 12703c7d4..d2d3d5c7e 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3Test.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.List;
import java.util.Map;
import java.util.UUID;
@@ -209,7 +210,7 @@ class AutomationCompositionElementHandlerV3Test {
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, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(
@@ -233,9 +234,8 @@ class AutomationCompositionElementHandlerV3Test {
simulatorService.setConfig(config);
var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
Map.of("stage", List.of(1, 2)), Map.of());
- var instanceElementMigrated = new InstanceElementDto(
- INSTANCE_ELEMENT.instanceId(), INSTANCE_ELEMENT.elementId(),
- null, Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(INSTANCE_ELEMENT.instanceId(),
+ INSTANCE_ELEMENT.elementId(), null, Map.of(), new HashMap<>());
acElementHandler
.migrate(COMPOSITION_ELEMENT, compositionElementTarget, INSTANCE_ELEMENT, instanceElementMigrated, 1);
verify(intermediaryApi).updateAutomationCompositionElementStage(
@@ -258,8 +258,8 @@ class AutomationCompositionElementHandlerV3Test {
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);
+ var inElMigratedAdd = new InstanceElementDto(instanceElement.instanceId(), instanceElement.elementId(),
+ null, Map.of(), new HashMap<>(), ElementState.NEW);
acElementHandler
.migrate(compositionElement, compoElTargetAdd, instanceElement, inElMigratedAdd, 0);
verify(intermediaryApi).updateAutomationCompositionElementState(