summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorxuegao <xg353y@intl.att.com>2020-02-21 15:28:30 +0100
committersebdet <sebastien.determe@intl.att.com>2020-03-03 01:43:10 -0800
commit492a5ddfdd09ce0a046a61abd6e76a69d9cf477a (patch)
tree8ddda219ddf698166109b10fc3d60fa7ce044f3a /src/test/java
parentd2a4df0b62b6a32c42bac45b4bee344016faa8fb (diff)
Rework the activate pdp group payload
Rework the payload which triggers the activate pdp group policy API based on the new requirement. Issue-ID: CLAMP-646 Change-Id: I9bd7e3f2d1907c7e22c5435c792910b8245780b2 Signed-off-by: xuegao <xg353y@intl.att.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopToJsonTest.java23
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyComponentTest.java41
2 files changed, 39 insertions, 25 deletions
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 34d524a6..6c6fb0c8 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -37,7 +37,6 @@ 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.components.external.PolicyComponent;
import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.loop.service.Service;
@@ -46,7 +45,6 @@ import org.onap.clamp.loop.template.LoopTemplate;
import org.onap.clamp.loop.template.PolicyModel;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
-import org.skyscreamer.jsonassert.JSONAssert;
public class LoopToJsonTest {
@@ -173,25 +171,4 @@ public class LoopToJsonTest {
assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest2, "modelService", "svgRepresentation",
"blueprint", "components");
}
-
- /**
- * This tests the GSON encode/decode of pdpGroup.
- *
- * @throws IOException In case of issues
- */
- @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"),
- PolicyComponent.createPoliciesPayloadPdpGroup(loopTest), false);
- }
}
diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
index e822dfb1..52e10d2d 100644
--- a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java
@@ -24,15 +24,20 @@
package org.onap.clamp.loop;
import static org.assertj.core.api.Assertions.assertThat;
-
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
import java.io.IOException;
-
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.clamp.loop.components.external.ExternalComponentState;
import org.onap.clamp.loop.components.external.PolicyComponent;
+import org.onap.clamp.loop.template.LoopTemplate;
+import org.onap.clamp.loop.template.PolicyModel;
+import org.onap.clamp.policy.microservice.MicroServicePolicy;
+import org.onap.clamp.policy.operational.OperationalPolicy;
public class PolicyComponentTest {
@@ -243,4 +248,36 @@ public class PolicyComponentTest {
assertThat(state4.getStateName()).isEqualTo("IN_ERROR");
}
+
+ /**
+ * Test the create policies payload PdpGroup test.
+ */
+ @Test
+ public void createPoliciesPayloadPdpGroupTest() throws IOException {
+ Loop loopTest = new Loop("ControlLoopTest", "<xml></xml>");
+ PolicyModel policyModel1 = new PolicyModel("onap.policies.monitoring.test", null, "1.0.0");
+
+ MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", policyModel1, true,
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null);
+ microServicePolicy.setPdpGroup("pdpGroup1");
+ microServicePolicy.setPdpSubGroup("pdpSubgroup1");
+
+ loopTest.addMicroServicePolicy(microServicePolicy);
+
+ PolicyModel policyModel2 = new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0");
+ OperationalPolicy opPolicy = new OperationalPolicy("opPolicy", loopTest,
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), policyModel2, null);
+ opPolicy.setPdpGroup("pdpGroup2");
+ opPolicy.setPdpSubGroup("pdpSubgroup2");
+
+ loopTest.addOperationalPolicy(opPolicy);
+
+ LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null);
+ loopTemplate.setDcaeBlueprintId("UUID-blueprint");
+ loopTest.setLoopTemplate(loopTemplate);
+
+ String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest);
+ String expectedRes = ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json");
+ assertThat(payload).isEqualTo(expectedRes);
+ }
}