From df19466321c94e4ec2c4e5ca5c8bf462602f2538 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 18 May 2018 15:52:02 +0200 Subject: [PATCH] Fix duplicate thresholds Fix issue detected when publishing multiple thresholds in the TCA UI Issue-ID: CLAMP-165 Change-Id: I748f145c275a9e084effee451379e8c0615201d2 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java | 3 +-- src/test/resources/example/tca-policy-req/blueprint-expected.yaml | 2 +- src/test/resources/example/tca-policy-req/tca-policy-expected.json | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java index 35c438d9..1478342c 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java +++ b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java @@ -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()); diff --git a/src/test/resources/example/tca-policy-req/blueprint-expected.yaml b/src/test/resources/example/tca-policy-req/blueprint-expected.yaml index 4116b979..a35557cc 100644 --- a/src/test/resources/example/tca-policy-req/blueprint-expected.yaml +++ b/src/test/resources/example/tca-policy-req/blueprint-expected.yaml @@ -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: diff --git a/src/test/resources/example/tca-policy-req/tca-policy-expected.json b/src/test/resources/example/tca-policy-req/tca-policy-expected.json index 5bf007bc..6e302dd6 100644 --- a/src/test/resources/example/tca-policy-req/tca-policy-expected.json +++ b/src/test/resources/example/tca-policy-req/tca-policy-expected.json @@ -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", -- 2.16.6