aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2019-05-22 12:18:45 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-22 12:18:45 +0000
commitbebced5988018f7c3792e87796be62dbf94bb428 (patch)
treec7be59b2568c60028559d14a5a8905c71dcbb3b0
parentbae85ac9a2ea4cbc925fd60497083828980d51da (diff)
parentbe1075b1dd746bb8a7d5563ff11f985fddf3ad7f (diff)
Merge "Enhanced logic for multilevel list input"
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java110
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java341
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy2
3 files changed, 100 insertions, 353 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
index 18a46dda99..9d0b9e42cc 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
@@ -92,7 +92,7 @@ public class ResourceRequestBuilder {
*
* @param execution Execution context
*
- * @param currentResource The current Service Resource Object
+ * @param resource The current Service Resource Object
*
* @param uuiServiceParameters the service parameters passed from the API
*
@@ -103,19 +103,17 @@ public class ResourceRequestBuilder {
* @since ONAP Beijing Release
*/
@SuppressWarnings("unchecked")
- public static String buildResourceRequestParameters(Execution execution, Resource currentResource,
+ public static String buildResourceRequestParameters(Execution execution, Resource resource,
String uuiServiceParameters, Map<String, Object> currentVFData) {
List<String> resourceList = jsonUtil.StringArrayToList(execution,
(String) JsonUtils.getJsonValue(uuiServiceParameters, "resources"));
// Get the right location str for resource. default is an empty array.
String locationConstraints = "[]";
- String resourceInputsFromUui = "";
- if (currentResource.getResourceType() == ResourceType.VNF) {
- for (String resource : resourceList) {
- String resCusUuid = (String) JsonUtils.getJsonValue(resource, "resourceCustomizationUuid");
- if ((null != resCusUuid)
- && resCusUuid.equals(currentResource.getModelInfo().getModelCustomizationUuid())) {
- String resourceParameters = JsonUtils.getJsonValue(resource, "parameters");
+ if (resource.getResourceType() == ResourceType.VNF) {
+ for (String eachResource : resourceList) {
+ String resCusUuid = (String) JsonUtils.getJsonValue(eachResource, "resourceCustomizationUuid");
+ if ((null != resCusUuid) && resCusUuid.equals(resource.getModelInfo().getModelCustomizationUuid())) {
+ String resourceParameters = JsonUtils.getJsonValue(eachResource, "parameters");
locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints");
}
}
@@ -130,25 +128,9 @@ public class ResourceRequestBuilder {
if (uuiRequestInputs == null) {
uuiRequestInputs = new HashMap();
}
- String resourceInputStr = null;
- ResourceLevel resourceLevel = null;
- switch (currentResource.getResourceType()) {
- case VNF:
- resourceInputStr = ((VnfResource) currentResource).getResourceInput();
- resourceLevel = ResourceLevel.FIRST;
- break;
- case GROUP:
- resourceInputStr = ((GroupResource) currentResource).getVnfcs().get(0).getResourceInput();
- resourceLevel = ResourceLevel.SECOND;
- break;
- }
-
- Map<String, Object> resourceInputsAfterMerge = new HashMap<>();
- if (StringUtils.isNotEmpty(resourceInputStr) && (null != resourceLevel)) {
- resourceInputsAfterMerge =
- getResourceInput(resourceInputStr, uuiRequestInputs, resourceLevel, currentVFData);
- }
+ Map<String, Object> resourceInputsAfterMerge =
+ ResourceRequestBuilder.buildResouceRequest(resource, uuiRequestInputs, currentVFData);
String resourceInputsStr = getJsonString(resourceInputsAfterMerge);
String result = "{\n" + "\"locationConstraints\":" + locationConstraints + ",\n" + "\"requestInputs\":"
@@ -157,70 +139,34 @@ public class ResourceRequestBuilder {
}
@SuppressWarnings("unchecked")
- public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid,
- Map<String, Object> serviceInputs, Map<String, Object> currentVFData) {
+ public static Map<String, Object> buildResouceRequest(Resource resource, Map<String, Object> uuiRequestInputs,
+ Map<String, Object> currentVFData) {
try {
- Map<String, Object> serviceInstnace = getServiceInstnace(serviceUuid);
- // find match of customization uuid in vnf
- Map<String, Map<String, Object>> serviceResources =
- (Map<String, Map<String, Object>>) serviceInstnace.get("serviceResources");
-
- List<Map<String, Object>> serviceVnfCust = (List<Map<String, Object>>) serviceResources.get("serviceVnfs");
- Map<String, String> resourceInputData = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid);
-
- // find match in network resource
- if (resourceInputData.isEmpty()) {
- List<Map<String, Object>> serviceNetworkCust =
- (List<Map<String, Object>>) serviceResources.get("serviceNetworks");
- resourceInputData = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid);
-
- // find match in AR resource
- if (resourceInputData.isEmpty()) {
- List<Map<String, Object>> serviceArCust =
- (List<Map<String, Object>>) serviceResources.get("serviceAllottedResources");
- resourceInputData = getResourceInputStr(serviceArCust, resourceCustomizationUuid);
- }
- }
-
String resourceInputStr = null;
- ResourceLevel resourceLevel = null;
- if (!resourceInputData.isEmpty()) {
- resourceInputStr = resourceInputData.get("resourceInput");
- resourceLevel = ResourceLevel.valueOf(resourceInputData.get("nodeType"));
+ // Resource Level is considered as first level by default
+ ResourceLevel resourceLevel = ResourceLevel.FIRST;
+ switch (resource.getResourceType()) {
+ case VNF:
+ resourceInputStr = ((VnfResource) resource).getResourceInput();
+ resourceLevel = ResourceLevel.FIRST;
+ break;
+ case GROUP:
+ resourceInputStr = ((GroupResource) resource).getVnfcs().get(0).getResourceInput();
+ resourceLevel = ResourceLevel.SECOND;
+ break;
}
- if (resourceInputStr != null && !resourceInputStr.isEmpty() && resourceLevel != null) {
- return getResourceInput(resourceInputStr, serviceInputs, resourceLevel, currentVFData);
+ Map<String, Object> resourceInputsAfterMerge = new HashMap<>();
+ if (StringUtils.isNotEmpty(resourceInputStr)) {
+ return getResourceInput(resourceInputStr, uuiRequestInputs, resourceLevel, currentVFData);
}
} catch (Exception e) {
- logger.error("not able to retrieve service instance", e);
+ logger.error("not able to retrieve service resource input ", e);
}
return new HashMap();
}
- private static Map<String, String> getResourceInputStr(List<Map<String, Object>> resources,
- String resCustomizationUuid) {
-
- Map<String, String> resourceInputMap = new HashMap<>(2);
- for (Map<String, Object> resource : resources) {
- Map<String, String> modelInfo = (Map<String, String>) resource.get("modelInfo");
-
- if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) {
- resourceInputMap.put("resourceInput", (String) resource.get("resourceInput"));
- String nodeType = ResourceLevel.FIRST.toString();
- if (((String) resource.get("resourceType")).equalsIgnoreCase("VNF")) {
- nodeType = ResourceLevel.FIRST.toString();
- } else if (((String) resource.get("resourceType")).equals("GROUP")) {
- nodeType = ResourceLevel.SECOND.toString();
- }
- resourceInputMap.put("nodeType", nodeType);
- return resourceInputMap;
- }
- }
- return new HashMap<>();
- }
-
// this method combines resource input with service input
private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> uuiRequestInputs,
ResourceLevel resourceLevel, Map<String, Object> currentVFData) {
@@ -338,7 +284,7 @@ public class ResourceRequestBuilder {
levelKeyNameUpdated = true;
}
- if (uuiServiceInput.containsKey(keyName)) {
+ if ((null != uuiServiceInput) && (uuiServiceInput.containsKey(keyName))) {
Object vfcLevelObject = uuiServiceInput.get(keyName);
// it will be always list
if (vfcLevelObject instanceof List) {
@@ -369,7 +315,7 @@ public class ResourceRequestBuilder {
} else {
// if not a list type
- if (uuiServiceInput.containsKey(tmpKey)) {
+ if ((null != uuiServiceInput) && (uuiServiceInput.containsKey(tmpKey))) {
value = (String) uuiServiceInput.get(tmpKey);
} else {
if (split.length == 1) { // means value is empty e.g. "a":"key1|"
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
index 1350a4bcc0..557ae6df51 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
@@ -19,6 +19,7 @@
*/
package org.onap.so.bpmn.common.resource;
+import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -28,18 +29,24 @@ import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.bpmn.core.domain.GroupResource;
+import org.onap.so.bpmn.core.domain.Resource;
+import org.onap.so.bpmn.core.domain.ResourceType;
+import org.onap.so.bpmn.core.domain.VnfResource;
+import org.onap.so.bpmn.core.domain.VnfcResource;
import org.onap.so.bpmn.mock.FileUtil;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class ResourceRequestBuilderTest extends BaseTest {
private Map<String, Object> userInputMap = null;
- private String serviceInput = null;
+ private Map<String, Object> serviceInput = null;
@Before
public void initializeMockObjects() {
@@ -58,7 +65,9 @@ public class ResourceRequestBuilderTest extends BaseTest {
if (null == this.serviceInput) {
try {
- this.serviceInput = FileUtil.readResourceFile("__files/SERVICE-SO-REQ-INPUT.json");
+ ObjectMapper mapper = new ObjectMapper();
+ String serviceInputRequest = FileUtil.readResourceFile("__files/SERVICE-SO-REQ-INPUT.json");
+ this.serviceInput = mapper.readValue(serviceInputRequest, new TypeReference<Map<String, Object>>() {});
} catch (Exception e) {
Assert.fail(e.getMessage());
}
@@ -69,216 +78,34 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputTest() throws Exception {
-
-
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
- + "\t\t\"modelName\" : \"demoVFWCL\",\n"
- + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
- + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
- + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
- + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
- + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n"
- + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n"
- + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
- + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
- + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
- + "\t\t\"resourceType\" \t\t: \"VNF\",\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
- + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
- + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\t\t\"resourceType\" \t\t: \"VNF\",\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\","
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
- + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-
- // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ VnfResource resource = new VnfResource();
+ resource.setResourceType(ResourceType.VNF);
+ resource.setResourceInput("{\"a\":\"key|default_value\"}");
HashMap serviceInput = new HashMap();
serviceInput.put("key", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null);
assertEquals(stringObjectMap.get("a"), "value");
}
@Test
public void getResourceInputDefaultValueTest() throws Exception {
-
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
- + "\t\t\"modelName\" : \"demoVFWCL\",\n"
- + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
- + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
- + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
- + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
- + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
- + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
- + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
- + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
- + "\t\t\"nfType\" \t\t: null,\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
- + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
- + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\t\t\"resourceType\" \t\t: \"VNF\",\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\","
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
- + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-
- // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ VnfResource resource = new VnfResource();
+ resource.setResourceType(ResourceType.VNF);
+ resource.setResourceInput("{\"a\":\"key|default_value\"}");
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null);
assertEquals(stringObjectMap.get("a"), "default_value");
}
@Test
public void getResourceInputValueNoDefaultTest() throws Exception {
-
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
- + "\t\t\"modelName\" : \"demoVFWCL\",\n"
- + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
- + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
- + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
- + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
- + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
- + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
- + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
- + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
- + "\t\t\"nfType\" \t\t: null,\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
- + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
- + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\t\t\"resourceType\" \t\t: \"VNF\",\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\","
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
- + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-
- // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ VnfResource resource = new VnfResource();
+ resource.setResourceType(ResourceType.VNF);
+ resource.setResourceInput("{\"a\":\"value\"}");
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null);
assertEquals(stringObjectMap.get("a"), "value");
}
@@ -356,118 +183,93 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputWithEmptyServiceResourcesTest() throws Exception {
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
- + "\t\t\"modelName\" : \"demoVFWCL\",\n"
- + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
- + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
- + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
- + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
- + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
- + "\t\"serviceVnfs\": [], \n" + "\t\"serviceNetworks\": [],\n"
- + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
+ VnfResource resource = new VnfResource();
+ resource.setResourceType(ResourceType.VNF);
+ resource.setResourceInput(null);
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput, null);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null);
assertEquals(0, stringObjectMap.size());
}
@Test
public void testGetResourceInputEmptyValue() {
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
- + "\t\t\"modelName\" : \"demoVFWCL\",\n"
- + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
- + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
- + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
- + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
- + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n"
- + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n"
- + "\t\t{ \"modelInfo\" : {\n"
- + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
- + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
- + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
- + "\t\t\t\"modelVersion\" : \"1.0\",\n"
- + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
- + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
- + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
- + "\t\t\"nfFunction\" \t: null,\n"
- + "\"resourceInput\":\"{\\\"a\\\":\\\"key1|\\\"}\","
- + "\t\t\"resourceType\" \t\t: \"VNF\",\n"
- + "\t\t\"nfRole\" \t\t: null,\n"
- + "\t\t\"nfNamingCode\" \t: null,\n"
- + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
- + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
- + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
- + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
- + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
- + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
- + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
- + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
- + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
- + "\t\t\t\t\t\"initialCount\" : 1,\n"
- + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
- + "\t\t}]}}")));
+
+ VnfResource resource = new VnfResource();
+ resource.setResourceType(ResourceType.VNF);
+ resource.setResourceInput("{\"a\":\"key1|\"}");
HashMap serviceInput = new HashMap();
serviceInput.put("key2", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
- "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput, null);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null);
assertEquals(stringObjectMap.get("a"), "");
}
@Test
public void getListResourceInputTest() throws Exception {
+ List<Map> vnfdata = null;
+ List<Resource> resources = new ArrayList<>();
+ if (this.serviceInput.containsKey("serviceResources")) {
+ vnfdata = (List<Map>) ((Map) this.serviceInput.get("serviceResources")).get("serviceVnfs");
+ }
+ assertNotNull(vnfdata);
+ vnfdata.forEach(e -> {
+ if (e.get("resourceType").equals("VNF")) {
+ VnfResource r = new VnfResource();
+ r.setResourceInput(e.get("resourceInput").toString());
+ resources.add(r);
+ } else if (e.get("resourceType").equals("GROUP")) {
+ GroupResource r = new GroupResource();
+ VnfcResource vfc = new VnfcResource();
+ vfc.setResourceInput(e.get("resourceInput").toString());
+ List<VnfcResource> vfcList = new ArrayList();
+ vfcList.add(vfc);
+ r.setVnfcs(vfcList);
+ resources.add(r);
+ }
+ });
- wireMockServer.stubFor(get(urlEqualTo(
- "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok(this.serviceInput)));
-
- // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ assertEquals(9, resources.size());
// VF level request
Map<String, Object> currentVFData = new HashMap<>();
Map<String, Object> stringObjectMap =
- ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", this.userInputMap, currentVFData);
+ ResourceRequestBuilder.buildResouceRequest(resources.get(0), this.userInputMap, currentVFData);
assertEquals("b", stringObjectMap.get("a"));
assertEquals("hub_spoke", stringObjectMap.get("topology"));
assertEquals("defaultvpn", stringObjectMap.get("name"));
assertTrue(((String) stringObjectMap.get("sitelist")).contains("["));
// vfc level request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a0", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(1), this.userInputMap, currentVFData);
assertEquals("", stringObjectMap.get("a"));
assertEquals("layer3-port", stringObjectMap.get("portswitch"));
assertEquals("192.168.10.1", stringObjectMap.get("ipAddress"));
assertEquals("vCPE", stringObjectMap.get("deviceName"));
// vfc level request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a1", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(2), this.userInputMap, currentVFData);
assertEquals("", stringObjectMap.get("a"));
assertEquals("layer2-port", stringObjectMap.get("portswitch"));
assertEquals("192.168.11.1", stringObjectMap.get("ipAddress"));
assertEquals("CPE_Beijing", stringObjectMap.get("deviceName"));
// VF level request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1c1", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(3), this.userInputMap, currentVFData);
assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
assertEquals("dsvpn_hub1", stringObjectMap.get("role"));
assertTrue(((String) stringObjectMap.get("wanlist")).contains("["));
assertTrue(((String) stringObjectMap.get("devlist")).contains("["));
// VFC request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88cb1a1", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(4), this.userInputMap, currentVFData);
assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
assertEquals("20000", stringObjectMap.get("postcode"));
assertEquals("single_gateway", stringObjectMap.get("type"));
@@ -475,8 +277,8 @@ public class ResourceRequestBuilderTest extends BaseTest {
assertEquals("DHCP", stringObjectMap.get("ipMode"));
// VFC request again
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88cb1f1", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(5), this.userInputMap, currentVFData);
assertEquals("Huawei Private Cloud", stringObjectMap.get("address"));
assertEquals("20000", stringObjectMap.get("postcode"));
assertEquals("single_gateway", stringObjectMap.get("type"));
@@ -485,16 +287,16 @@ public class ResourceRequestBuilderTest extends BaseTest {
assertEquals("VNF", stringObjectMap.get("devclass"));
// VF level request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1c3", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(6), this.userInputMap, currentVFData);
assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
assertEquals("dsvpn_hub", stringObjectMap.get("role"));
assertTrue(((String) stringObjectMap.get("wanlist")).contains("["));
assertTrue(((String) stringObjectMap.get("devlist")).contains("["));
// VFC request
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88cb1a4", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(7), this.userInputMap, currentVFData);
assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
assertEquals("20001", stringObjectMap.get("postcode"));
assertEquals("multiple_gateway", stringObjectMap.get("type"));
@@ -502,8 +304,8 @@ public class ResourceRequestBuilderTest extends BaseTest {
assertEquals("Static", stringObjectMap.get("ipMode"));
// VFC request again
- stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88cb1f5", this.userInputMap, currentVFData);
+ stringObjectMap =
+ ResourceRequestBuilder.buildResouceRequest(resources.get(8), this.userInputMap, currentVFData);
assertEquals("Huawei Public Cloud", stringObjectMap.get("address"));
assertEquals("20001", stringObjectMap.get("postcode"));
assertEquals("multiple_gateway", stringObjectMap.get("type"));
@@ -512,7 +314,6 @@ public class ResourceRequestBuilderTest extends BaseTest {
assertEquals("PNF", stringObjectMap.get("devclass"));
-
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
index c99c702af0..9f378e567c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
@@ -184,7 +184,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
rmodel.setResourceCustomizationUuid(resourceCustomizationUuid)
addedResourceList.add(rmodel)
- Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null, null)
+ Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(rc, null, null)
requestInputs.addAll(resourceParameters.keySet())
}