aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-04-09 18:10:32 +0200
committersebdet <sebastien.determe@intl.att.com>2019-04-09 18:10:32 +0200
commiteb71d70552c827e1d8405862f73e8cbd827c6e48 (patch)
tree947b3c8d6bb26f6d966875e285beef883a1ba920 /src/test
parentfb35c3e3c80bd17308abfd34964e854ad9975342 (diff)
PDP Group support
Add support to push all policies to pdp group + log Issue-ID: CLAMP-303 Change-Id: Ie53b1dfd11ef8db9c2b5ccca0511e6f6343fb70a Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopToJsonTest.java24
-rw-r--r--src/test/resources/tosca/pdp-group-policy-payload.json16
2 files changed, 38 insertions, 2 deletions
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 0e03e1b06..dcad1a516 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -29,15 +29,18 @@ import static org.junit.Assert.assertNotNull;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
+import java.io.IOException;
import java.util.HashSet;
import java.util.Random;
import org.junit.Test;
import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.skyscreamer.jsonassert.JSONAssert;
public class LoopToJsonTest {
@@ -74,10 +77,11 @@ public class LoopToJsonTest {
}
@Test
- public void LoopGsonTest() {
+ public void LoopGsonTest() throws IOException {
Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
"123456789", "https://dcaetest.org", "UUID-blueprint");
- OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest");
+ OperationalPolicy opPolicy = this.getOperationalPolicy(
+ ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest");
loopTest.addOperationalPolicy(opPolicy);
MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "",
"{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
@@ -103,4 +107,20 @@ public class LoopToJsonTest {
assertThat((LoopLog) loopTestDeserialized.getLoopLogs().toArray()[0]).isEqualToIgnoringGivenFields(loopLog,
"loop");
}
+
+ @Test
+ public void createPoliciesPayloadPdpGroupTest() throws IOException {
+ Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
+ "123456789", "https://dcaetest.org", "UUID-blueprint");
+ OperationalPolicy opPolicy = this.getOperationalPolicy(
+ ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), "GuardOpPolicyTest");
+ loopTest.addOperationalPolicy(opPolicy);
+ MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "",
+ "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0",
+ "{\"param1\":\"value1\"}", true);
+ loopTest.addMicroServicePolicy(microServicePolicy);
+
+ JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json"),
+ loopTest.createPoliciesPayloadPdpGroup(), false);
+ }
}
diff --git a/src/test/resources/tosca/pdp-group-policy-payload.json b/src/test/resources/tosca/pdp-group-policy-payload.json
new file mode 100644
index 000000000..bf941e516
--- /dev/null
+++ b/src/test/resources/tosca/pdp-group-policy-payload.json
@@ -0,0 +1,16 @@
+{
+ "policies": [
+ {
+ "policy-id": "GuardOpPolicyTest"
+ },
+ {
+ "policy-id": "guard2"
+ },
+ {
+ "policy-id": "guard1"
+ },
+ {
+ "policy-id": "configPolicyTest"
+ }
+ ]
+} \ No newline at end of file