* @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) {
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);
}
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);
}
/**
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);
"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
}
}
participantProvider.verifyParticipantState(participantIds);
- return AcmUtils.prepareParticipantPriming(acElements, supportedElementMap);
+ return AcmUtils.prepareParticipantPriming(acElements, supportedElementMap, acmDefinition);
}
/**