Create SVG in UI
[clamp.git] / src / test / java / org / onap / clamp / loop / LoopRepositoriesItCase.java
index fa4909c..9815575 100644 (file)
@@ -31,7 +31,6 @@ import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonObject;
 import java.time.Instant;
-import java.util.HashSet;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.Application;
@@ -91,7 +90,8 @@ public class LoopRepositoriesItCase {
     }
 
     private OperationalPolicy getOperationalPolicy(String configJson, String name, PolicyModel policyModel) {
-        return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class), policyModel);
+        return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class), policyModel,
+                null, null, null);
     }
 
     private LoopElementModel getLoopElementModel(String yaml, String name, String policyType, String createdBy,
@@ -106,32 +106,33 @@ public class LoopRepositoriesItCase {
         return new PolicyModel(policyType, policyModelTosca, version, policyAcronym);
     }
 
-    private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation, String createdBy,
-                                         Integer maxInstancesAllowed) {
-        LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null);
+    private LoopTemplate getLoopTemplates(String name, String blueprint, String createdBy,
+                                          Integer maxInstancesAllowed) {
+        LoopTemplate template = new LoopTemplate(name, blueprint, maxInstancesAllowed, null);
         template.addLoopElementModel(getLoopElementModel("yaml", "microService1", "org.onap.policy.drools", createdBy,
                 getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools")));
+        template.addLoopElementModel(getLoopElementModel("yaml", "oppolicy1", "org.onap.policy.drools.legacy",
+                createdBy, getPolicyModel("org.onap.policy.drools.legacy", "yaml", "1.0.0", "DroolsLegacy")));
         loopTemplateRepository.save(template);
         return template;
     }
 
-    private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson,
+    private Loop getLoop(String name, String blueprint, String globalPropertiesJson,
                          String dcaeId, String dcaeUrl, String dcaeBlueprintId) {
         Loop loop = new Loop();
         loop.setName(name);
-        loop.setSvgRepresentation(svgRepresentation);
         loop.setGlobalPropertiesJson(new Gson().fromJson(globalPropertiesJson, JsonObject.class));
         loop.setLastComputedState(LoopState.DESIGN);
         loop.setDcaeDeploymentId(dcaeId);
         loop.setDcaeDeploymentStatusUrl(dcaeUrl);
-        loop.setLoopTemplate(getLoopTemplate("templateName", "yaml", "svg", "toto", 1));
+        loop.setLoopTemplate(getLoopTemplates("templateName", "yaml", "toto", 1));
         return loop;
     }
 
     private MicroServicePolicy getMicroServicePolicy(String name, String jsonRepresentation, String jsonProperties,
                                                      boolean shared, PolicyModel policyModel) {
         MicroServicePolicy microService = new MicroServicePolicy(name, policyModel, shared,
-                gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>());
+                gson.fromJson(jsonRepresentation, JsonObject.class), null, null, null);
         microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class));
         return microService;
     }
@@ -147,10 +148,10 @@ public class LoopRepositoriesItCase {
     @Transactional
     public void crudTest() {
         // Setup
-        Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}",
+        Loop loopTest = getLoop("ControlLoopTest", "yamlcontent", "{\"testname\":\"testvalue\"}",
                 "123456789", "https://dcaetest.org", "UUID-blueprint");
         OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest",
-                getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools"));
+                getPolicyModel("org.onap.policy.drools.legacy", "yaml", "1.0.0", "DroolsLegacy"));
         loopTest.addOperationalPolicy(opPolicy);
         MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "{\"configtype\":\"json\"}",
                 "{\"param1\":\"value1\"}", true, getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools"));
@@ -215,7 +216,7 @@ public class LoopRepositoriesItCase {
 
         // Attempt an update
         ((LoopLog) loopInDbRetrieved.getLoopLogs().toArray()[0]).setLogInstant(Instant.now());
-        loopInDbRetrieved.setSvgRepresentation("");
+        loopInDbRetrieved.setLastComputedState(LoopState.RUNNING);
         Loop loopInDbRetrievedUpdated = loopRepository.saveAndFlush(loopInDbRetrieved);
         // Loop loopInDbRetrievedUpdated =
         // loopRepository.findById(loopTest.getName()).get();