Fix Acmr to send outProperties in the Prime request 47/141847/3
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>
Thu, 14 Aug 2025 20:56:58 +0000 (21:56 +0100)
committerRamesh Murugan Iyer <ramesh.murugan.iyer@est.tech>
Tue, 19 Aug 2025 08:55:10 +0000 (08:55 +0000)
Issue-ID: POLICY-5448
Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech>
Change-Id: I72d04c0beb150eb7c0fbdf5323e0e1c2416a2ed7

models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantPrimePublisher.java

index cb99613..dfe213f 100644 (file)
@@ -112,7 +112,8 @@ public final class AcmUtils {
      * @param supportedElementMap supported Element Map
      */
     public static List<ParticipantDefinition> prepareParticipantPriming(
-            List<Entry<String, ToscaNodeTemplate>> acElements, Map<ToscaConceptIdentifier, UUID> supportedElementMap) {
+            List<Entry<String, ToscaNodeTemplate>> acElements, Map<ToscaConceptIdentifier, UUID> supportedElementMap,
+            AutomationCompositionDefinition acmDefinition) {
 
         Map<UUID, List<AutomationCompositionElementDefinition>> map = new HashMap<>();
         for (var elementEntry : acElements) {
@@ -126,6 +127,10 @@ public final class AcmUtils {
             acElementDefinition.setAcElementDefinitionId(
                     new ToscaConceptIdentifier(elementEntry.getKey(), elementEntry.getValue().getVersion()));
             acElementDefinition.setAutomationCompositionElementToscaNodeTemplate(elementEntry.getValue());
+            var nodeTemplateState = acmDefinition.getElementStateMap()
+                    .get(acElementDefinition.getAcElementDefinitionId().getName());
+            acElementDefinition.setOutProperties(nodeTemplateState.getOutProperties());
+
             map.putIfAbsent(participantId, new ArrayList<>());
             map.get(participantId).add(acElementDefinition);
         }
@@ -522,16 +527,7 @@ public final class AcmUtils {
                 elementList.add(elementEntry);
             }
         }
-        var list = prepareParticipantPriming(elementList, supportedElementMap);
-        for (var participantDefinition : list) {
-            for (var elementDe : participantDefinition.getAutomationCompositionElementDefinitionList()) {
-                var state = acmDefinition.getElementStateMap().get(elementDe.getAcElementDefinitionId().getName());
-                if (state != null) {
-                    elementDe.setOutProperties(state.getOutProperties());
-                }
-            }
-        }
-        return list;
+        return prepareParticipantPriming(elementList, supportedElementMap, acmDefinition);
     }
 
     /**
index f7f379e..ea5c850 100644 (file)
@@ -104,9 +104,17 @@ class AcmUtilsTest {
 
         var acElements =
                 AcmUtils.extractAcElementsFromServiceTemplate(serviceTemplate, AUTOMATION_COMPOSITION_ELEMENT);
+        var acDefinition = new AutomationCompositionDefinition();
+        acDefinition.setState(AcTypeState.PRIMED);
+        acDefinition.setServiceTemplate(serviceTemplate);
+        acDefinition.setCompositionId(UUID.randomUUID());
+        acDefinition.setElementStateMap(AcmUtils.createElementStateMap(acElements, AcTypeState.PRIMED));
+        acDefinition.getElementStateMap().values().forEach(nodeTemplateState
+                -> nodeTemplateState.setOutProperties(Map.of("outProperty", "testProperty")));
+
         Map<ToscaConceptIdentifier, UUID> map = new HashMap<>();
         var participantId = UUID.randomUUID();
-        assertThatThrownBy(() -> AcmUtils.prepareParticipantPriming(acElements, map)).hasMessageMatching(
+        assertThatThrownBy(() -> AcmUtils.prepareParticipantPriming(acElements, map, acDefinition)).hasMessageMatching(
                 "Element Type org.onap.policy.clamp.acm.PolicyAutomationCompositionElement 1.0.0 not supported");
         map.put(new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyAutomationCompositionElement", "1.0.0"),
                 participantId);
@@ -114,8 +122,12 @@ class AcmUtilsTest {
                 "1.0.0"), participantId);
         map.put(new ToscaConceptIdentifier("org.onap.policy.clamp.acm.HttpAutomationCompositionElement", "1.0.0"),
                 participantId);
-        var result = AcmUtils.prepareParticipantPriming(acElements, map);
+        var result = AcmUtils.prepareParticipantPriming(acElements, map, acDefinition);
         assertThat(result).isNotEmpty().hasSize(1);
+        for (var participantDefList : result) {
+            assertTrue(participantDefList.getAutomationCompositionElementDefinitionList().stream()
+                    .allMatch(element -> "testProperty".equals(element.getOutProperties().get("outProperty"))));
+        }
     }
 
     @Test
index 34bcb01..dfc0386 100644 (file)
@@ -118,7 +118,7 @@ public class ParticipantPrimePublisher extends AbstractParticipantPublisher<Part
             }
         }
         participantProvider.verifyParticipantState(participantIds);
-        return AcmUtils.prepareParticipantPriming(acElements, supportedElementMap);
+        return AcmUtils.prepareParticipantPriming(acElements, supportedElementMap, acmDefinition);
     }
 
     /**