Fix duplicate thresholds 77/48177/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Fri, 18 May 2018 13:52:02 +0000 (15:52 +0200)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Fri, 18 May 2018 13:52:02 +0000 (15:52 +0200)
Fix issue detected when publishing multiple thresholds in the TCA UI

Issue-ID: CLAMP-165
Change-Id: I748f145c275a9e084effee451379e8c0615201d2
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
src/test/resources/example/tca-policy-req/blueprint-expected.yaml
src/test/resources/example/tca-policy-req/tca-policy-expected.json

index 35c438d..1478342 100644 (file)
@@ -157,10 +157,9 @@ public class TcaRequestFormatter {
     private static void addThresholds(ClampProperties refProp, String service, ObjectNode appendToNode, TcaItem tcaItem,
             ModelProperties modelProperties) {
         ArrayNode tcaNodes = appendToNode.withArray("thresholds");
-        ObjectNode tcaNode;
         try {
-            tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
             for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
+                ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
                 tcaNode.put("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
                 tcaNode.put("fieldPath", tcaThreshold.getFieldPath());
                 tcaNode.put("thresholdValue", tcaThreshold.getThreshold());
index 4116b97..a35557c 100644 (file)
@@ -30,7 +30,7 @@ node_templates:
         subscriberMessageLimit: '-1', subscriberPollingInterval: '20000', subscriberProtocol: https,
         subscriberTimeoutMS: '-1', subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub,
         subscriberUserName: m00502@tca.af.dcae.onap.org, subscriberUserPassword: Te5021abc,
-        tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"example_model01.ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_TCA_1jy9to4","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"}]}]}'}
+        tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"example_model01.ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_TCA_1jy9to4","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_null","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":123,"direction":"GREATER_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"}]}]}'}
       artifact_name: dcae-analytics-tca
       artifact_version: 1.0.0
       connections:
index 5bf007b..6e302dd 100644 (file)
@@ -28,9 +28,9 @@
               "version": "1.0.2",
               "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
               "thresholdValue": 123,
-              "direction": "GREATER_OR_EQUAL",
+              "direction": "LESS_OR_EQUAL",
               "severity": "MAJOR",
-              "closedLoopEventStatus": "ONSET"
+              "closedLoopEventStatus": "ABATED"
             },
             {
               "closedLoopControlName": "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf_0",