Create SVG in UI
[clamp.git] / src / test / java / org / onap / clamp / loop / LoopServiceTestItCase.java
index 5eca90c..15cf59f 100644 (file)
@@ -46,7 +46,6 @@ import org.onap.clamp.policy.operational.OperationalPolicy;
 import org.onap.clamp.policy.operational.OperationalPolicyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.Commit;
 import org.springframework.test.context.junit4.SpringRunner;
 
 @RunWith(SpringRunner.class)
@@ -79,8 +78,7 @@ public class LoopServiceTestItCase {
     public void shouldCreateEmptyLoop() {
         // given
         String loopBlueprint = "blueprint";
-        String loopSvg = "representation";
-        Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, loopBlueprint, loopSvg);
+        Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, loopBlueprint);
         testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
         testLoop.setLastComputedState(LoopState.DESIGN);
 
@@ -91,7 +89,6 @@ public class LoopServiceTestItCase {
         assertThat(actualLoop).isNotNull();
         assertThat(actualLoop).isEqualTo(loopsRepository.findById(actualLoop.getName()).get());
         assertThat(actualLoop.getName()).isEqualTo(EXAMPLE_LOOP_NAME);
-        assertThat(actualLoop.getSvgRepresentation()).isEqualTo(loopSvg);
         assertThat(actualLoop.getGlobalPropertiesJson().getAsJsonPrimitive("testName").getAsString())
                 .isEqualTo("testValue");
     }
@@ -102,7 +99,7 @@ public class LoopServiceTestItCase {
         // given
         saveTestLoopToDb();
         OperationalPolicy operationalPolicy = new OperationalPolicy("policyName", null,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
 
         // when
         Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
@@ -130,7 +127,7 @@ public class LoopServiceTestItCase {
                 "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyModel1");
         policyModelsService.saveOrUpdatePolicyModel(policyModel);
         MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel,
-                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
 
         // when
         Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
@@ -160,11 +157,11 @@ public class LoopServiceTestItCase {
                 "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName");
         policyModelsService.saveOrUpdatePolicyModel(policyModel2);
         MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1, false,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
 
         loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
         MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2, false,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
 
         // when
         firstMicroServicePolicy
@@ -184,7 +181,7 @@ public class LoopServiceTestItCase {
     }
 
     private void saveTestLoopToDb() {
-        Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation");
+        Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint");
         testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
         LoopTemplate template = new LoopTemplate();
         template.setName("testTemplate");
@@ -204,11 +201,11 @@ public class LoopServiceTestItCase {
                 "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName");
         policyModelsService.saveOrUpdatePolicyModel(policyModel2);
         MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1,
-                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
         loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy));
 
         MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2,
-                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
 
         // when
         Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
@@ -233,11 +230,11 @@ public class LoopServiceTestItCase {
         JsonObject newJsonConfiguration = JsonUtils.GSON.fromJson("{}", JsonObject.class);
 
         OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
         loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
 
         OperationalPolicy secondOperationalPolicy = new OperationalPolicy("secondPolicyName", null,
-                newJsonConfiguration, null);
+                newJsonConfiguration, null, null, null, null);
 
         // when
         firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration);
@@ -264,11 +261,11 @@ public class LoopServiceTestItCase {
         saveTestLoopToDb();
 
         OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
         loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy));
 
         OperationalPolicy secondOperationalPolicy = new OperationalPolicy("policyName", null,
-                JsonUtils.GSON.fromJson("{}", JsonObject.class), null);
+                JsonUtils.GSON.fromJson("{}", JsonObject.class), null, null, "pdpGroup1", "pdpSubgroup1");
 
         // when
         Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME,
@@ -320,7 +317,7 @@ public class LoopServiceTestItCase {
         loop = loopService.saveOrUpdateLoop(loop);
         // Add op policy
         OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null, null);
         loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy));
 
         PolicyModel policyModel = new PolicyModel("org.policies.microPolicy",
@@ -328,7 +325,7 @@ public class LoopServiceTestItCase {
         policyModelsService.saveOrUpdatePolicyModel(policyModel);
         // Add Micro service policy
         MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", policyModel,
-                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
         loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy));
 
         // Verify it's there
@@ -372,12 +369,12 @@ public class LoopServiceTestItCase {
                 "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyName");
         policyModelsService.saveOrUpdatePolicyModel(policyModel);
         MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel,
-                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+                false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
         loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy);
         assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
     }
 
-    private Loop createTestLoop(String loopName, String loopBlueprint, String loopSvg) {
-        return new Loop(loopName, loopSvg);
+    private Loop createTestLoop(String loopName, String loopBlueprint) {
+        return new Loop(loopName);
     }
 }
\ No newline at end of file