aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy39
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy76
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json33
3 files changed, 130 insertions, 18 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
index ba450c1b12..58c8f27de9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -281,14 +281,14 @@ class SDNCAdapterUtils {
}
boolean isAic3 = execution.getVariable("isAic3")
-
+
if(isAic3) {
nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
}
else {
nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
}
-
+
String content = """
<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
@@ -319,7 +319,7 @@ class SDNCAdapterUtils {
/**
* Builds an SDNC "reserve" request and stores it in the specified execution
- * variable.
+ * variable.
* @param execution the execution
* @param action the type of action: reserve, turnup, etc
* @param resultVar the execution variable in which the result will be stored
@@ -424,7 +424,7 @@ class SDNCAdapterUtils {
if (additionalData == null) {
additionalData = ""
}
-
+
if(isAic3) {
nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
}
@@ -470,7 +470,7 @@ class SDNCAdapterUtils {
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
}
}
-
+
public String updateHomingInfo(String homingInfo, String aicVersion) {
String newHomingInfo
if(homingInfo == null || homingInfo.trim().length() == 0) {
@@ -480,7 +480,7 @@ class SDNCAdapterUtils {
newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
}
}
-
+
/**
* Builds a topology SDNC request and return String request.
* As V2 will use 1607-style request, region instead of aic clli code
@@ -506,7 +506,7 @@ class SDNCAdapterUtils {
} else {
hdrRequestId = testHdrRequestId
}
-
+
String requestId = ""
try {
requestId = execution.getVariable("mso-request-id")
@@ -561,6 +561,9 @@ class SDNCAdapterUtils {
int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
subscriberName = UriUtils.decode(subscriberName,"UTF-8")
+ }else{
+ serviceType = execution.getVariable("serviceType")
+ subscriberName = execution.getVariable("subscriberName")
}
String content =
@@ -635,11 +638,11 @@ class SDNCAdapterUtils {
requestId = execution.getVariable("mso-request-id")
if (requestId == null) {
requestId = execution.getVariable("msoRequestId")
- }
+ }
} else {
requestId = testRequestId
- }
-
+ }
+
String aicCloudRegion = cloudRegionId
String tenantId = ""
if (utils.nodeExists(requestXML, "tenant-id")) {
@@ -717,7 +720,7 @@ class SDNCAdapterUtils {
String content =
"""<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
- xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
@@ -993,7 +996,7 @@ class SDNCAdapterUtils {
exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg)
}
}
-
+
public String modelInfoToEcompModelInformation(String jsonModelInfo) {
String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
@@ -1004,11 +1007,11 @@ class SDNCAdapterUtils {
String modelCustomizationString = ""
if (modelCustomizationUuid != null) {
modelCustomizationString = "<model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>"
- }
+ }
String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
if (modelVersion == null) {
modelVersion = ""
- }
+ }
String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
String ecompModelInformation =
"""<onap-model-information>
@@ -1019,6 +1022,6 @@ class SDNCAdapterUtils {
<model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
</onap-model-information>"""
- return ecompModelInformation
- }
+ return ecompModelInformation
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy
new file mode 100644
index 0000000000..5deec5b434
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DecomposeServiceTest.groovy
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.junit.Before
+import org.mockito.MockitoAnnotations
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.NetworkResource
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.DecomposeJsonUtil
+import org.onap.so.bpmn.core.domain.ServiceInstance
+
+import org.onap.so.bpmn.mock.FileUtil
+import static org.mockito.Mockito.*
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import static org.junit.Assert.*;
+import org.junit.Test;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+
+class DecomposeServiceTest {
+
+ @Test
+ public void testDecomposeService() {
+
+ String catalogDbResponse = FileUtil.readResourceFile("__files/decomposition/catalogDbResponse.json");
+
+ ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setInstanceId("serviceInstanceID");
+ serviceDecomposition.setServiceType("");
+ serviceDecomposition.setServiceRole("");
+
+ ArrayList networkResources = new ArrayList();
+ NetworkResource networkResource = new NetworkResource();
+ networkResource.setNetworkType("testNetworkType");
+ networkResource.setNetworkRole("testNetworkRole");
+ networkResource.setNetworkScope("testNetworkScope");
+ networkResource.setToscaNodeType("testToscaModelType")
+ networkResource.setNetworkTechnology("testNetworkTechnology");
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelName("testModleName");
+ modelInfo.setModelUuid("testModelUuid")
+ modelInfo.setModelInvariantUuid("testModelInvariantId")
+ modelInfo.setModelVersion("testModelVersion");
+ modelInfo.setModelCustomizationUuid("testModelCustomizationUuid");
+ modelInfo.setModelInstanceName("testModelInstanceName");
+ networkResource.setModelInfo(modelInfo);
+
+ networkResources.add(networkResource);
+ serviceDecomposition.setNetworkResources(networkResources)
+ serviceDecomposition.setServiceInstance(serviceInstance);
+
+ ServiceDecomposition serviceDecompositionExtracted = DecomposeJsonUtil.jsonToServiceDecomposition(catalogDbResponse, "serviceInstanceID")
+
+ assertThat(serviceDecompositionExtracted, sameBeanAs(serviceDecomposition).ignoring("modelInfo").ignoring("vnfResources").ignoring("allottedResources").ignoring("networkResources.resourceId"));
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json
new file mode 100644
index 0000000000..087233d08b
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/decomposition/catalogDbResponse.json
@@ -0,0 +1,33 @@
+{
+ "serviceResources": {
+ "serviceType": "",
+ "workloadContext": "testWorkloadContext",
+ "serviceAllottedResources": [],
+ "modelInfo": {
+ "modelInvariantUuid": "testModelInvariantId",
+ "modelName": "testModleName",
+ "modelVersion": "testModelVersion",
+ "modelUuid": "testModelUuid"
+ },
+ "environmentContext": "testEnvironmentContent",
+ "serviceRole": "",
+ "serviceVnfs": [],
+ "serviceNetworks": [
+ {
+ "toscaNodeType": "testToscaModelType",
+ "networkTechnology": "testNetworkTechnology",
+ "networkScope": "testNetworkScope",
+ "modelInfo": {
+ "modelInvariantUuid": "testModelInvariantId",
+ "modelName": "testModleName",
+ "modelVersion": "testModelVersion",
+ "modelCustomizationUuid": "testModelCustomizationUuid",
+ "modelInstanceName": "testModelInstanceName",
+ "modelUuid": "testModelUuid"
+ },
+ "networkRole": "testNetworkRole",
+ "networkType": "testNetworkType"
+ }
+ ]
+ }
+} \ No newline at end of file