aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
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 0e03e1b0..dcad1a51 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 00000000..bf941e51
--- /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