Create SVG in UI
[clamp.git] / src / test / java / org / onap / clamp / loop / DcaeComponentTest.java
index fa9cc06..022d10e 100644 (file)
@@ -27,11 +27,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
-
 import java.io.IOException;
-import java.util.HashSet;
 import java.util.List;
-
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.json.simple.parser.ParseException;
@@ -42,31 +39,39 @@ import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse;
 import org.onap.clamp.loop.components.external.DcaeComponent;
 import org.onap.clamp.loop.components.external.ExternalComponentState;
 import org.onap.clamp.loop.template.LoopTemplate;
+import org.onap.clamp.loop.template.PolicyModel;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 
 public class DcaeComponentTest {
 
     private Loop createTestLoop() {
-        Loop loopTest = new Loop("ControlLoopTest", "<xml></xml>");
+        Loop loopTest = new Loop("ControlLoopTest");
         loopTest.setGlobalPropertiesJson(
-                new Gson().fromJson("{\"dcaeDeployParameters\":" + "{\"policy_id\": \"name\"}}", JsonObject.class));
+                new Gson().fromJson(
+                        "{\"dcaeDeployParameters\":{\"uniqueBlueprintParameters\": {\"policy_id\": \"name\"}}}",
+                        JsonObject.class));
         loopTest.setLastComputedState(LoopState.DESIGN);
         loopTest.setDcaeDeploymentId("123456789");
         loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085");
 
-        MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "",
-                "tosca_definitions_version: tosca_simple_yaml_1_0_0", true,
-                new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>());
+        MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", new PolicyModel("policy1",
+                "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0"), true,
+                new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, null, null);
         microServicePolicy.setConfigurationsJson(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class));
 
         loopTest.addMicroServicePolicy(microServicePolicy);
-        LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null);
+        LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", 1, null);
         loopTemplate.setDcaeBlueprintId("UUID-blueprint");
         loopTest.setLoopTemplate(loopTemplate);
 
         return loopTest;
     }
 
+    /**
+     * Test the DcaeReponse roughly.
+     *
+     * @throws IOException In case of issues
+     */
     @Test
     public void convertDcaeResponseTest() throws IOException {
         String dcaeFakeResponse = "{'requestId':'testId','operationType':'install','status':'state',"
@@ -99,6 +104,11 @@ public class DcaeComponentTest {
         assertThat(unDeploymentPayload).isEqualTo(expectedPayload);
     }
 
+    /**
+     * Test the computeState method of the DcaeComponent roughly.
+     *
+     * @throws IOException In case of issues
+     */
     @Test
     public void computeStateTest() throws IOException {
         Exchange exchange = Mockito.mock(Exchange.class);
@@ -157,6 +167,12 @@ public class DcaeComponentTest {
         assertThat(state9.getStateName()).isEqualTo("IN_ERROR");
     }
 
+    /**
+     * Test the Converter to DcaeInventoryResponse method.
+     *
+     * @throws IOException    In case of failure
+     * @throws ParseException In case of failure
+     */
     @Test
     public void convertToDcaeInventoryResponseTest() throws IOException, ParseException {
         String dcaeFakeResponse = "{\n" + "  \"links\": {\n" + "    \"previousLink\": {\n"