From f2d71ebde9dcd13d3181ba343ad82e728b30bf73 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 30 Jan 2020 16:37:27 +0100 Subject: Remove blueprintId in loop Remove the blueprint Id for DCAE in loop object as now the one in loop template will be used. Issue-ID: CLAMP-592 Change-Id: Ie86f362451d58de07f7a715ae0bfc92566893e13 Signed-off-by: sebdet --- src/main/java/org/onap/clamp/loop/Loop.java | 12 --- .../loop/components/external/DcaeComponent.java | 12 ++- .../org/onap/clamp/loop/DcaeComponentTest.java | 118 +++++++-------------- .../org/onap/clamp/loop/DeployFlowTestItCase.java | 1 - .../onap/clamp/loop/LoopRepositoriesItCase.java | 1 - .../java/org/onap/clamp/loop/LoopToJsonTest.java | 1 - 6 files changed, 43 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 66fd56579..339812672 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -92,10 +92,6 @@ public class Loop extends AuditEntity implements Serializable { @Column(name = "dcae_deployment_status_url") private String dcaeDeploymentStatusUrl; - @Expose - @Column(name = "dcae_blueprint_id") - private String dcaeBlueprintId; - @Column(columnDefinition = "MEDIUMTEXT", name = "svg_representation") private String svgRepresentation; @@ -248,14 +244,6 @@ public class Loop extends AuditEntity implements Serializable { this.loopLogs.add(log); } - public String getDcaeBlueprintId() { - return dcaeBlueprintId; - } - - void setDcaeBlueprintId(String dcaeBlueprintId) { - this.dcaeBlueprintId = dcaeBlueprintId; - } - public Service getModelService() { return modelService; } diff --git a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java index acb7190f7..21960e387 100644 --- a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java +++ b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java @@ -24,16 +24,17 @@ package org.onap.clamp.loop.components.external; import com.google.gson.JsonObject; + import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.UUID; + import org.apache.camel.Exchange; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; - import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse; import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse; import org.onap.clamp.clds.util.JsonUtils; @@ -92,6 +93,7 @@ public class DcaeComponent extends ExternalComponent { return null; } } + /** * Generate the deployment id, it's random. * @@ -122,7 +124,7 @@ public class DcaeComponent extends ExternalComponent { JsonObject globalProp = loop.getGlobalPropertiesJson(); JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER); - String serviceTypeId = loop.getDcaeBlueprintId(); + String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId(); JsonObject rootObject = new JsonObject(); rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId); @@ -135,7 +137,7 @@ public class DcaeComponent extends ExternalComponent { /** * Return the deploy payload for DCAE. * - * @param loop The loop object + * @param loop The loop object * @param microServiceName The micro service name * @return The payload used to send deploy closed loop request */ @@ -143,7 +145,7 @@ public class DcaeComponent extends ExternalComponent { JsonObject globalProp = loop.getGlobalPropertiesJson(); JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServiceName); - String serviceTypeId = loop.getDcaeBlueprintId(); + String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId(); JsonObject rootObject = new JsonObject(); rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId); @@ -161,7 +163,7 @@ public class DcaeComponent extends ExternalComponent { */ public static String getUndeployPayload(Loop loop) { JsonObject rootObject = new JsonObject(); - rootObject.addProperty(DCAE_SERVICETYPE_ID, loop.getDcaeBlueprintId()); + rootObject.addProperty(DCAE_SERVICETYPE_ID, loop.getLoopTemplate().getDcaeBlueprintId()); return rootObject.toString(); } diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java index c7035efa0..03b35f1b4 100644 --- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java +++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java @@ -35,42 +35,42 @@ import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.json.simple.parser.ParseException; -import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse; 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.policy.microservice.MicroServicePolicy; public class DcaeComponentTest { private Loop createTestLoop() { - String yaml = "imports:\n" + " - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\n" - + "node_templates:\n" + " docker_service_host:\n" + " type: dcae.nodes.SelectedDockerHost"; - Loop loopTest = new Loop("ControlLoopTest", ""); loopTest.setGlobalPropertiesJson( - new Gson().fromJson("{\"dcaeDeployParameters\":" + "{\"policy_id\": \"name\"}}", JsonObject.class)); + new Gson().fromJson("{\"dcaeDeployParameters\":" + "{\"policy_id\": \"name\"}}", JsonObject.class)); loopTest.setLastComputedState(LoopState.DESIGN); loopTest.setDcaeDeploymentId("123456789"); loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085"); - loopTest.setDcaeBlueprintId("UUID-blueprint"); MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, - new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>()); + "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, + new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>()); microServicePolicy.setConfigurationsJson(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class)); loopTest.addMicroServicePolicy(microServicePolicy); + LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null); + loopTemplate.setDcaeBlueprintId("UUID-blueprint"); + loopTest.setLoopTemplate(loopTemplate); + return loopTest; } @Test public void convertDcaeResponseTest() throws IOException { String dcaeFakeResponse = "{'requestId':'testId','operationType':'install','status':'state','error':'errorMessage', " - + "'links':{'self':'selfUrl','uninstall':'uninstallUrl'}}"; + + "'links':{'self':'selfUrl','uninstall':'uninstallUrl'}}"; DcaeOperationStatusResponse responseObject = DcaeComponent.convertDcaeResponse(dcaeFakeResponse); assertThat(responseObject.getRequestId()).isEqualTo("testId"); assertThat(responseObject.getOperationType()).isEqualTo("install"); @@ -115,7 +115,7 @@ public class DcaeComponentTest { assertThat(state.getStateName()).isEqualTo("BLUEPRINT_DEPLOYED"); // OperationalType = install - DcaeOperationStatusResponse dcaeResponse = Mockito.mock(DcaeOperationStatusResponse.class); + DcaeOperationStatusResponse dcaeResponse = Mockito.mock(DcaeOperationStatusResponse.class); Mockito.when(dcaeResponse.getOperationType()).thenReturn("install"); Mockito.when(dcaeResponse.getStatus()).thenReturn("succeeded"); @@ -159,81 +159,35 @@ public class DcaeComponentTest { @Test public void convertToDcaeInventoryResponseTest() throws IOException, ParseException { - String dcaeFakeResponse = "{\n" - + " \"links\": {\n" - + " \"previousLink\": {\n" - + " \"title\": \"string\",\n" - + " \"rel\": \"string\",\n" - + " \"uri\": \"string\",\n" - + " \"uriBuilder\": {},\n" - + " \"rels\": [\n" - + " \"string\"\n" - + " ],\n" - + " \"params\": {\n" - + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" - + " \"additionalProp3\": \"string\"\n" - + " },\n" - + " \"type\": \"string\"\n" - + " },\n" - + " \"nextLink\": {\n" - + " \"title\": \"string\",\n" - + " \"rel\": \"string\",\n" - + " \"uri\": \"string\",\n" - + " \"uriBuilder\": {},\n" - + " \"rels\": [\n" - + " \"string\"\n" - + " ],\n" - + " \"params\": {\n" - + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" - + " \"additionalProp3\": \"string\"\n" - + " },\n" - + " \"type\": \"string\"\n" - + " }\n" - + " },\n" - + " \"totalCount\": 0,\n" - + " \"items\": [\n" - + " {\n" - + " \"owner\": \"testOwner\",\n" - + " \"application\": \"testApplication\",\n" - + " \"component\": \"testComponent\",\n" - + " \"typeName\": \"testTypeName\",\n" - + " \"typeVersion\": 0,\n" - + " \"blueprintTemplate\": \"testBlueprintTemplate\",\n" - + " \"serviceIds\": [\n" - + " \"serviceId1\", \"serviceId2\"\n" - + " ],\n" - + " \"vnfTypes\": [\n" - + " \"vnfType1\", \"vnfType2\"\n" - + " ],\n" - + " \"serviceLocations\": [\n" - + " \"serviceLocation1\", \"serviceLocation2\"\n" - + " ],\n" + String dcaeFakeResponse = "{\n" + " \"links\": {\n" + " \"previousLink\": {\n" + + " \"title\": \"string\",\n" + " \"rel\": \"string\",\n" + " \"uri\": \"string\",\n" + + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" + + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" + + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" + + " },\n" + " \"type\": \"string\"\n" + " },\n" + " \"nextLink\": {\n" + + " \"title\": \"string\",\n" + " \"rel\": \"string\",\n" + " \"uri\": \"string\",\n" + + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" + + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" + + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" + + " },\n" + " \"type\": \"string\"\n" + " }\n" + " },\n" + " \"totalCount\": 0,\n" + + " \"items\": [\n" + " {\n" + " \"owner\": \"testOwner\",\n" + + " \"application\": \"testApplication\",\n" + " \"component\": \"testComponent\",\n" + + " \"typeName\": \"testTypeName\",\n" + " \"typeVersion\": 0,\n" + + " \"blueprintTemplate\": \"testBlueprintTemplate\",\n" + " \"serviceIds\": [\n" + + " \"serviceId1\", \"serviceId2\"\n" + " ],\n" + " \"vnfTypes\": [\n" + + " \"vnfType1\", \"vnfType2\"\n" + " ],\n" + " \"serviceLocations\": [\n" + + " \"serviceLocation1\", \"serviceLocation2\"\n" + " ],\n" + " \"asdcServiceId\": \"testAsdcServiceId\",\n" + " \"asdcResourceId\": \"testAsdcResourceId\",\n" - + " \"asdcServiceURL\": \"testAsdcServiceURL\",\n" - + " \"typeId\": \"testTypeId\",\n" - + " \"selfLink\": {\n" - + " \"title\": \"selfLinkTitle\",\n" - + " \"rel\": \"selfLinkRel\",\n" - + " \"uri\": \"selfLinkUri\",\n" - + " \"uriBuilder\": {},\n" - + " \"rels\": [\n" - + " \"string\"\n" - + " ],\n" - + " \"params\": {\n" - + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" - + " \"additionalProp3\": \"string\"\n" - + " },\n" - + " \"type\": \"string\"\n" - + " },\n" + + " \"asdcServiceURL\": \"testAsdcServiceURL\",\n" + " \"typeId\": \"testTypeId\",\n" + + " \"selfLink\": {\n" + " \"title\": \"selfLinkTitle\",\n" + + " \"rel\": \"selfLinkRel\",\n" + " \"uri\": \"selfLinkUri\",\n" + + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" + + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" + + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" + + " },\n" + " \"type\": \"string\"\n" + " },\n" + " \"created\": \"2020-01-22T09:38:15.436Z\",\n" - + " \"deactivated\": \"2020-01-22T09:38:15.437Z\"\n" - + " }\n" - + " ]\n" - + "}"; + + " \"deactivated\": \"2020-01-22T09:38:15.437Z\"\n" + " }\n" + " ]\n" + "}"; List responseObject = DcaeComponent.convertToDcaeInventoryResponse(dcaeFakeResponse); assertThat(responseObject.get(0).getAsdcResourceId()).isEqualTo("testAsdcResourceId"); assertThat(responseObject.get(0).getAsdcServiceId()).isEqualTo("testAsdcServiceId"); diff --git a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java index e23dcf186..e1cee341b 100644 --- a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java @@ -177,7 +177,6 @@ public class DeployFlowTestItCase { Loop loop = new Loop(name, svgRepresentation); loop.setGlobalPropertiesJson(new Gson().fromJson(globalPropertiesJson, JsonObject.class)); loop.setLastComputedState(LoopState.DESIGN); - loop.setDcaeBlueprintId(dcaeBlueprintId); return loop; } diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java index 891d23b46..62b25605e 100644 --- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java @@ -125,7 +125,6 @@ public class LoopRepositoriesItCase { loop.setLastComputedState(LoopState.DESIGN); loop.setDcaeDeploymentId(dcaeId); loop.setDcaeDeploymentStatusUrl(dcaeUrl); - loop.setDcaeBlueprintId(dcaeBlueprintId); loop.setLoopTemplate(getLoopTemplate("templateName", "yaml", "svg", "toto", 1)); return loop; } diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java index 052b97124..ae4b2564e 100644 --- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java +++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java @@ -66,7 +66,6 @@ public class LoopToJsonTest { loop.setLastComputedState(LoopState.DESIGN); loop.setDcaeDeploymentId(dcaeId); loop.setDcaeDeploymentStatusUrl(dcaeUrl); - loop.setDcaeBlueprintId(dcaeBlueprintId); return loop; } -- cgit 1.2.3-korg