From c6917dc3b68748ac0f201a56a9f5b83231e151c1 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 9 Apr 2019 11:16:42 +0200 Subject: Remove the license issue Remove license issue in csar that was generated by SDC Issue-ID: CLAMP-338 Change-Id: Iad23cd23b7c5ad79d2443188f461614b169f8d85 Signed-off-by: sebdet --- .../example/sdc/service-Vloadbalancerms-csar.csar | Bin 112273 -> 110668 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'src') diff --git a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar index b3479ba96..b5fe39d31 100755 Binary files a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar and b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar differ -- cgit 1.2.3-korg From ea77586a744fe9f69293e27d9e3553497f46c2a2 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 9 Apr 2019 13:08:10 +0200 Subject: Add logs Add logs entries in loop database so that we can track what is going on Issue-ID: CLAMP-303 Change-Id: If69e3ebbb9f96e4bc3a95b06e61eaa301bd32007 Signed-off-by: sebdet --- .../resources/clds/camel/rest/clamp-api-v2.xml | 2 ++ .../resources/clds/camel/routes/flexible-flow.xml | 25 ++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 76f45881a..810c9d205 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -106,6 +106,8 @@ + diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml index 15a247b5d..33419c219 100644 --- a/src/main/resources/clds/camel/routes/flexible-flow.xml +++ b/src/main/resources/clds/camel/routes/flexible-flow.xml @@ -118,9 +118,11 @@ + message="Endpoint to create microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> + @@ -139,9 +141,11 @@ + message="Endpoint to delete microservice policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> + @@ -165,9 +169,11 @@ + message="Endpoint to create operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> + @@ -186,10 +192,11 @@ + message="Endpoint to delete operational policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> - + @@ -213,9 +220,11 @@ + message="Endpoint to create guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> + @@ -234,9 +243,11 @@ + message="Endpoint to delete guard policy: ${header.CamelHttpMethod} ${header.CamelHttpUri}"> + \ No newline at end of file -- cgit 1.2.3-korg From fb35c3e3c80bd17308abfd34964e854ad9975342 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 9 Apr 2019 13:09:37 +0200 Subject: Fix guard payload Fix guard payload nullpointerException when guard list is empty or null Issue-ID: CLAMP-303 Change-Id: I6f714a877036cbc531dd35505202dde227cc224a Signed-off-by: sebdet --- .../policy/operational/OperationalPolicy.java | 14 +++++---- .../microservice/OperationalPolicyPayloadTest.java | 17 +++++++++-- .../operational-policy-no-guard-properties.json | 35 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 src/test/resources/tosca/operational-policy-no-guard-properties.json (limited to 'src') diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index 1859a4d6e..1e35ad6c4 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -183,18 +183,20 @@ public class OperationalPolicy implements Serializable, Policy { /** * Return a map containing all Guard policies indexed by Guard policy Name. - * + * * @return The Guards map */ public Map createGuardPolicyPayloads() { Map result = new HashMap<>(); - JsonObject guard = new JsonObject(); JsonElement guardsList = this.getConfigurationsJson().get("guard_policies"); - for (Entry guardElem : guardsList.getAsJsonObject().entrySet()) { - guard.addProperty("policy-id", guardElem.getKey()); - guard.add("contents", guardElem.getValue()); - result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard)); + if (guardsList != null) { + for (Entry guardElem : guardsList.getAsJsonObject().entrySet()) { + JsonObject guard = new JsonObject(); + guard.addProperty("policy-id", guardElem.getKey()); + guard.add("contents", guardElem.getValue()); + result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard)); + } } return result; } diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java index 739708ca7..76e29c31f 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java @@ -47,18 +47,29 @@ public class OperationalPolicyPayloadTest { .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml")); } + @Test + public void testGuardPolicyEmptyPayloadConstruction() throws IOException { + JsonObject jsonConfig = new GsonBuilder().create().fromJson( + ResourceFileUtil.getResourceAsString("tosca/operational-policy-no-guard-properties.json"), + JsonObject.class); + OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig); + Map guardsMap = policy.createGuardPolicyPayloads(); + assertThat(guardsMap).isEmpty(); + assertThat(guardsMap.entrySet()).isEmpty(); + } + @Test public void testGuardPolicyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig); - Map guardsList = policy.createGuardPolicyPayloads(); + Map guardsMap = policy.createGuardPolicyPayloads(); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/guard1-policy-payload.json"), - guardsList.get("guard1"), false); + guardsMap.get("guard1"), false); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/guard2-policy-payload.json"), - guardsList.get("guard2"), false); + guardsMap.get("guard2"), false); } } diff --git a/src/test/resources/tosca/operational-policy-no-guard-properties.json b/src/test/resources/tosca/operational-policy-no-guard-properties.json new file mode 100644 index 000000000..30c044044 --- /dev/null +++ b/src/test/resources/tosca/operational-policy-no-guard-properties.json @@ -0,0 +1,35 @@ +{ + "operational_policy": { + "controlLoop": { + "trigger_policy": "new", + "timeout": "0", + "abatement": "on", + "controlLoopName": "LOOP_iYTIP_v1_0_ResourceInstanceName1_tca" + }, + "policies": [ + { + "id": "new", + "recipe": "Restart", + "retry": "10", + "timeout": "10", + "actor": "SO", + "payload": "", + "success": "", + "failure": "", + "failure_timeout": "", + "failure_retries": "", + "failure_exception": "", + "failure_guard": "", + "target": { + "type": "VM", + "resourceId": "", + "modelInvariantId": "", + "modelVersionId": "", + "modelName": "", + "modelVersion": "", + "modelCustomizationId": "" + } + } + ] + } +} \ No newline at end of file -- cgit 1.2.3-korg