aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-policy/src/test
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-08-31 11:25:34 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-01 16:48:18 +0100
commit83b5318e545fbc72e3612c4300c4d738b0b577de (patch)
treec4429d0f64b16f510ca00160cd1eb49d91657b45 /participant/participant-impl/participant-impl-policy/src/test
parentbd376e1dd5e8ccb1893ef244dcd9e4b1a0686150 (diff)
Send ToscaServiceTemplateFragment with policies, policy-types
ToscaServiceTemplateFragment contains policies, policy-types and respective datatypes to be sent to Policy participant, and there on to Policy Framework to create new policies or policy-types that doesnot exist in the database. https://wiki.onap.org/display/DW/The+CLAMP+Policy+Framework+Participant Issue-ID: POLICY-3607 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: I2b98d7dc6946b0c27763f1a150d1bf4adca90a2f
Diffstat (limited to 'participant/participant-impl/participant-impl-policy/src/test')
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
index 4c87e0875..52ec98ea2 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/utils/TestListenerUtils.java
@@ -50,6 +50,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,6 +61,8 @@ public class TestListenerUtils {
static CommonTestData commonTestData = new CommonTestData();
private static final Logger LOGGER = LoggerFactory.getLogger(TestListenerUtils.class);
private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement";
+ private static final String POLICY_TYPE_ID = "policy_type_id";
+ private static final String POLICY_ID = "policy_id";
private TestListenerUtils() {}
@@ -147,6 +150,7 @@ public class TestListenerUtils {
Map<UUID, ControlLoopElement> elements = new LinkedHashMap<>();
ToscaServiceTemplate toscaServiceTemplate = testControlLoopRead();
+ TestListenerUtils.addPoliciesToToscaServiceTemplate(toscaServiceTemplate);
Map<String, ToscaNodeTemplate> nodeTemplatesMap =
toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : nodeTemplatesMap.entrySet()) {
@@ -176,12 +180,38 @@ public class TestListenerUtils {
List<ParticipantUpdates> participantUpdates = new ArrayList<>();
for (ControlLoopElement element : elements.values()) {
+ populateToscaNodeTemplateFragment(element, toscaServiceTemplate);
prepareParticipantUpdateForControlLoop(element, participantUpdates);
}
clUpdateMsg.setParticipantUpdatesList(participantUpdates);
return clUpdateMsg;
}
+ private static void populateToscaNodeTemplateFragment(ControlLoopElement clElement,
+ ToscaServiceTemplate toscaServiceTemplate) {
+ ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate
+ .getToscaTopologyTemplate().getNodeTemplates().get(clElement.getDefinition().getName());
+ // If the ControlLoopElement has policy_type_id or policy_id, identify it as a PolicyControlLoopElement
+ // and pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment
+ if ((toscaNodeTemplate.getProperties().get(POLICY_TYPE_ID) != null)
+ || (toscaNodeTemplate.getProperties().get(POLICY_ID) != null)) {
+ // ControlLoopElement for policy framework, send policies and policyTypes to participants
+ if ((toscaServiceTemplate.getPolicyTypes() != null)
+ || (toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() != null)) {
+ ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate();
+ toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes());
+
+ ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies());
+ toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate);
+
+ toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes());
+
+ clElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
+ }
+ }
+ }
+
private static void prepareParticipantUpdateForControlLoop(ControlLoopElement clElement,
List<ParticipantUpdates> participantUpdates) {
if (participantUpdates.isEmpty()) {
@@ -248,7 +278,6 @@ public class TestListenerUtils {
}
participantUpdateMsg.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- participantUpdateMsg.setToscaServiceTemplate(toscaServiceTemplate);
return participantUpdateMsg;
}