X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Fclamp%2Floop%2FLoopToJsonTest.java;h=6c7836e50ef1ad82142d3ce64ab1bec1be9a0687;hb=897a3e004a858ef68d989dad15dde91a69e151a5;hp=052b9712458c19de215a94543a4638a9ceabda38;hpb=b9a6531c7a5cfc5a9a544a21fe8c47914be9699b;p=clamp.git
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index 052b9712..6c7836e5 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -32,11 +32,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
-
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;
@@ -56,24 +53,26 @@ public class LoopToJsonTest {
private Gson gson = new Gson();
private OperationalPolicy getOperationalPolicy(String configJson, String name) {
- return new OperationalPolicy(name, null, gson.fromJson(configJson, JsonObject.class));
+ return new OperationalPolicy(name, null, gson.fromJson(configJson, JsonObject.class),
+ getPolicyModel("org.onap.policy.drools.legacy", "yaml", "1.0.0", "Drools", "type1"), null,null,null);
}
private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson,
- String dcaeId, String dcaeUrl, String dcaeBlueprintId) throws JsonSyntaxException, IOException {
+ String dcaeId, String dcaeUrl, String dcaeBlueprintId)
+ throws JsonSyntaxException, IOException {
Loop loop = new Loop(name, svgRepresentation);
loop.setGlobalPropertiesJson(new Gson().fromJson(globalPropertiesJson, JsonObject.class));
loop.setLastComputedState(LoopState.DESIGN);
loop.setDcaeDeploymentId(dcaeId);
loop.setDcaeDeploymentStatusUrl(dcaeUrl);
- loop.setDcaeBlueprintId(dcaeBlueprintId);
return loop;
}
private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation,
- String policyTosca, String jsonProperties, boolean shared) {
- MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared,
- gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>());
+ String policyTosca, String jsonProperties, boolean shared) {
+ MicroServicePolicy microService = new MicroServicePolicy(name, new PolicyModel(modelType, policyTosca, "1.0.0"),
+ shared,
+ gson.fromJson(jsonRepresentation, JsonObject.class), null, null, null);
microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class));
return microService;
}
@@ -88,12 +87,12 @@ public class LoopToJsonTest {
}
private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
- String policyVariant) {
+ String policyVariant) {
return new PolicyModel(policyType, policyModelTosca, version, policyAcronym);
}
private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation,
- Integer maxInstancesAllowed) {
+ Integer maxInstancesAllowed) {
LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null);
template.addLoopElementModel(getLoopElementModel("yaml", "microService1",
getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1")));
@@ -106,6 +105,10 @@ public class LoopToJsonTest {
return log;
}
+ /**
+ * This tests a GSON encode/decode.
+ * @throws IOException In case of failure
+ */
@Test
public void loopGsonTest() throws IOException {
Loop loopTest = getLoop("ControlLoopTest", "", "yamlcontent", "{\"testname\":\"testvalue\"}",
@@ -146,6 +149,11 @@ public class LoopToJsonTest {
assertThat(loopTestDeserialized.getLoopTemplate()).isEqualTo(loopTemplate);
}
+ /**
+ * This tests the service object GSON encode/decode.
+ *
+ * @throws IOException In case of issues
+ */
@Test
public void loopServiceTest() throws IOException {
Loop loopTest2 = getLoop("ControlLoopTest", "", "yamlcontent", "{\"testname\":\"testvalue\"}",
@@ -165,20 +173,4 @@ public class LoopToJsonTest {
assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest2, "modelService", "svgRepresentation",
"blueprint", "components");
}
-
- @Test
- public void createPoliciesPayloadPdpGroupTest() throws IOException {
- Loop loopTest = getLoop("ControlLoopTest", "", "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);
- }
}