Update UI to define Pdp Group
[clamp.git] / src / test / java / org / onap / clamp / loop / LoopControllerTestItCase.java
index ad37bcc..f017dd8 100644 (file)
@@ -30,15 +30,15 @@ import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-
 import java.util.Set;
-
 import javax.transaction.Transactional;
-
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.clamp.clds.Application;
 import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.loop.template.LoopTemplate;
+import org.onap.clamp.loop.template.PolicyModel;
+import org.onap.clamp.loop.template.PolicyModelsService;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 import org.onap.clamp.policy.microservice.MicroServicePolicyService;
 import org.onap.clamp.policy.operational.OperationalPolicy;
@@ -62,12 +62,18 @@ public class LoopControllerTestItCase {
     @Autowired
     MicroServicePolicyService microServicePolicyService;
 
+    @Autowired
+    PolicyModelsService policyModelsService;
+
     @Autowired
     LoopController loopController;
 
     private void saveTestLoopToDb() {
         Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation");
         testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class));
+        LoopTemplate template =  new LoopTemplate();
+        template.setName("testTemplate");
+        testLoop.setLoopTemplate(template);
         loopService.saveOrUpdateLoop(testLoop);
     }
 
@@ -125,9 +131,11 @@ public class LoopControllerTestItCase {
     @Transactional
     public void testUpdateMicroservicePolicy() {
         saveTestLoopToDb();
-        MicroServicePolicy policy = new MicroServicePolicy("policyName", "",
-                "tosca_definitions_version: tosca_simple_yaml_1_0_0", false,
-                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null);
+        PolicyModel policyModel = new PolicyModel("",
+                "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0");
+        policyModelsService.saveOrUpdatePolicyModel(policyModel);
+        MicroServicePolicy policy = new MicroServicePolicy("policyName", policyModel, false,
+                JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null, null, null);
         loopController.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, policy);
         assertThat(microServicePolicyService.isExisting("policyName")).isTrue();
     }