summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy141
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy15
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java44
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy78
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java29
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json29
13 files changed, 281 insertions, 91 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index 83714ed022..456b8ae074 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -207,10 +207,6 @@
</dependencyManagement>
<dependencies>
<dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </dependency>
- <dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
</dependency>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
index cae80e9137..3e451a5a4a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy
@@ -25,7 +25,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.rest.APIResponse;
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
-import org.onap.so.logger.MessageEnum
+import org.springframework.web.util.UriUtils
import org.onap.so.logger.MsoLogger
class AaiUtil {
@@ -43,6 +43,8 @@ class AaiUtil {
public AaiUtil(AbstractServiceTaskProcessor taskProcessor) {
this.taskProcessor = taskProcessor
}
+ public AaiUtil() {
+ }
public String getNetworkGenericVnfEndpoint(DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
@@ -87,6 +89,12 @@ class AaiUtil {
return uri
}
+ public String getNetworkDeviceUri(DelegateExecution execution) {
+ def uri = getUri(execution, 'device')
+ msoLogger.debug('AaiUtil.getNetworkDeviceUri() - AAI URI: ' + uri)
+ return uri
+ }
+
public String getBusinessCustomerUri(DelegateExecution execution) {
def uri = getUri(execution, 'customer')
msoLogger.debug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri)
@@ -109,7 +117,7 @@ class AaiUtil {
}
//public String getBusinessCustomerUriv7(DelegateExecution execution) {
- // // //def uri = getUri(execution, BUSINESS_CUSTOMERV7)
+ // //def uri = getUri(execution, BUSINESS_CUSTOMERV7)
// def uri = getUri(execution, 'Customer')
// msoLogger.debug('AaiUtil.getBusinessCustomerUriv7() - AAI URI: ' + uri)
// return uri
@@ -178,9 +186,30 @@ class AaiUtil {
(new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}")
}
+ public String getMainProcessKey(DelegateExecution execution) {
+ DelegateExecution exec = execution
+
+ while (true) {
+ DelegateExecution parent = exec.getSuperExecution()
+
+ if (parent == null) {
+ parent = exec.getParent()
+
+ if (parent == null) {
+ break
+ }
+ }
+
+ exec = parent
+ }
+
+ return execution.getProcessEngineServices().getRepositoryService()
+ .getProcessDefinition(exec.getProcessDefinitionId()).getKey()
+ }
+
public String getUri(DelegateExecution execution, resourceName) {
- def processKey = taskProcessor.getMainProcessKey(execution)
+ def processKey = getMainProcessKey(execution)
//set namespace
setNamespace(execution)
@@ -656,9 +685,9 @@ class AaiUtil {
private def getPInterface(DelegateExecution execution, String aai_uri) {
- String namespace = getNamespaceFromUri(aai_uri)
+ String namespace = getNamespaceFromUri(execution, aai_uri)
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- String serviceAaiPath = ${aai_endpoint}${aai_uri}
+ String serviceAaiPath = aai_endpoint + aai_uri
APIResponse response = executeAAIGetCall(execution, serviceAaiPath)
return new XmlParser().parseText(response.getResponseBodyAsString())
@@ -680,58 +709,102 @@ class AaiUtil {
String aai_uri = '/aai/v14/network/logical-links'
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- String serviceAaiPath = ${aai_endpoint}${aai_uri}
+ String serviceAaiPath = aai_endpoint + aai_uri
APIResponse response = executeAAIGetCall(execution, serviceAaiPath)
def logicalLinks = new XmlParser().parseText(response.getResponseBodyAsString())
- logicalLinks."logical-links".find { link ->
- def pInterface = []
+ logicalLinks."logical-link".each { link ->
+ def isRemoteLink = false
+ def pInterfaces = []
def relationship = link."relationship-list"."relationship"
- relationship.each {
- if ("p-interface".compareToIgnoreCase(it."related-to")) {
- pInterface.add(it)
+ relationship.each { rel ->
+ if ("ext-aai-network".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) {
+ isRemoteLink = true
+ }
+ if ("p-interface".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) {
+ pInterfaces.add(rel)
}
}
- if (pInterface.size() == 2) {
+
+ // if remote link then process
+ if (isRemoteLink) {
+
+ // find remote p interface
def localTP = null
def remoteTP = null
- if (pInterface[0]."related-link".contains("ext-aai-networks")) {
- remoteTP = pInterface[0]
- localTP = pInterface[1]
- }
+ def pInterface0 = pInterfaces[0]
+ def pIntfUrl = "${pInterface0."related-link"[0].text()}"
- if (pInterface[1]."related-link".contains("ext-aai-networks")) {
- localTP = pInterface[0]
- remoteTP = pInterface[1]
+ if (isRemotePInterface(execution, pIntfUrl)) {
+ remoteTP = pInterfaces[0]
+ localTP = pInterfaces[1]
+ } else {
+ localTP = pInterfaces[0]
+ remoteTP = pInterfaces[1]
}
if (localTP != null && remoteTP != null) {
// give local tp
- var intfLocal = getPInterface(execution, localTP."related-link")
- tpInfotpInfo.put("local-access-node-id", localTP."related-link".split("/")[6])
+ def tpUrl = "${localTP."related-link"[0]?.text()}"
+ def intfLocal = getPInterface(execution, "${localTP?."related-link"[0]?.text()}")
+ tpInfo.put("local-access-node-id", tpUrl.split("/")[6])
- def networkRef = intfLocal."network-ref".split("/")
- tpInfo.put("local-access-provider-id", networkRef[1])
- tpInfo.put("local-access-client-id", networkRef[3])
- tpInfo.put("local-access-topology-id", networkRef[5])
- tpInfo.put("local-access-ltp-id", localTP."interface-name")
+ def networkRef = "${intfLocal."network-ref"[0]?.text()}".split("/")
+ if (networkRef.size() == 6) {
+ tpInfo.put("local-access-provider-id", networkRef[1])
+ tpInfo.put("local-access-client-id", networkRef[3])
+ tpInfo.put("local-access-topology-id", networkRef[5])
+ }
+ def ltpIdStr = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1)
+ if (ltpIdStr?.contains("-")) {
+ tpInfo.put("local-access-ltp-id", ltpIdStr?.substring(ltpIdStr?.lastIndexOf("-") + 1))
+ }
- // give local tp
- var intfRemote = getPInterface(execution, remoteTP."related-link")
- tpInfo.put("remote-access-node-id", remoteTP."related-link".split("/")[6])
- def networkRefRemote = intfRemote."network-ref".split("/")
- tpInfo.put("remote-access-provider-id", networkRefRemote[1])
- tpInfo.put("remote-access-client-id", networkRefRemote[3])
- tpInfo.put("remote-access-topology-id", networkRefRemote[5])
- tpInfo.put("remote-access-ltp-id", remoteTP."interface-name")
+ // give remote tp
+ tpUrl = "${remoteTP."related-link"[0]?.text()}"
+ def intfRemote = getPInterface(execution, "${remoteTP."related-link"[0].text()}")
+ tpInfo.put("remote-access-node-id", tpUrl.split("/")[6])
+
+ def networkRefRemote = "${intfRemote."network-ref"[0]?.text()}".split("/")
+
+ if (networkRefRemote.size() == 6) {
+ tpInfo.put("remote-access-provider-id", networkRefRemote[1])
+ tpInfo.put("remote-access-client-id", networkRefRemote[3])
+ tpInfo.put("remote-access-topology-id", networkRefRemote[5])
+ }
+ def ltpIdStrR = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1)
+ if (ltpIdStrR?.contains("-")) {
+ tpInfo.put("remote-access-ltp-id", ltpIdStrR?.substring(ltpIdStr?.lastIndexOf("-") + 1))
+ }
+ return tpInfo
}
}
}
return tpInfo
}
+
+ // this method check if pInterface is remote
+ private def isRemotePInterface(DelegateExecution execution, String uri) {
+ def aai_uri = uri.substring(0, uri.indexOf("/p-interfaces"))
+
+ String namespace = getNamespaceFromUri(execution, aai_uri)
+ String aai_endpoint = execution.getVariable("URN_aai_endpoint")
+ String serviceAaiPath = aai_endpoint + aai_uri
+
+ APIResponse response = executeAAIGetCall(execution, serviceAaiPath)
+ def pnf = new XmlParser().parseText(response.getResponseBodyAsString())
+
+ def relationship = pnf."relationship-list"."relationship"
+ relationship.each {
+ if ("ext-aai-network".compareToIgnoreCase("${it."related-to"[0]?.text()}") == 0) {
+ return true
+ }
+ }
+ return false
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
index 8b786bc152..bcd740eae9 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy
@@ -43,7 +43,6 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
execution.setVariable("CVGN_queryVolumeGroupResponseCode",null)
execution.setVariable("CVGN_queryVolumeGroupResponse","")
execution.setVariable("CVGN_ResponseCode",null)
-// execution.setVariable("CVGN_ErrorResponse","")
execution.setVariable("RollbackData", null)
}
@@ -125,10 +124,6 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
// generates a WorkflowException if the A&AI query returns a response code other than 200/404
public void handleAAIQueryFailure(DelegateExecution execution) {
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CVGN_queryVolumeGroupResponseCode"), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse"));
- //String processKey = getProcessKey(execution);
- //WorkflowException exception = new WorkflowException(processKey, 5000,
- //execution.getVariable("CVGN_queryVolumeGroupResponse"))
- //execution.setVariable("WorkflowException", exception)
}
// generates a WorkflowException if the volume group name does not match AAI record for this volume group
@@ -137,16 +132,6 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{
" is not associated with " + execution.getVariable("CVGN_volumeGroupName")
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, errorNotAssociated, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated)
- //String processKey = getProcessKey(execution);
- //WorkflowException exception = new WorkflowException(processKey, 1002,
- // errorNotAssociated)
- //execution.setVariable("WorkflowException", exception)
}
- // sends a successful WorkflowResponse
- public void reportSuccess(DelegateExecution execution) {
- msoLogger.debug("Sending 200 back to the caller")
- def responseXML = ""
- execution.setVariable("WorkflowResponse", responseXML)
- }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
index 2c2cd8269c..7d4adaea58 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy
@@ -37,9 +37,9 @@ class ExternalAPIUtil {
public MsoUtils utils = new MsoUtils()
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
+
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExternalAPIUtil.class)
-
+
public static final String PostServiceOrderRequestsTemplate =
"{\n" +
"\t\"externalId\": <externalId>,\n" +
@@ -83,6 +83,8 @@ class ExternalAPIUtil {
"\t} \n" +
"}"
+ public ExternalAPIUtil() {
+ }
// public String getUri(DelegateExecution execution, resourceName) {
//
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
index 9b144323c0..5ff49fbae8 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroUtils.groovy
@@ -322,7 +322,6 @@ class SniroUtils{
}
if((isBlank(placements) || placements.equalsIgnoreCase("[]")) && (isBlank(licenses) || licenses.equalsIgnoreCase("[]"))){
msoLogger.debug("Sniro Async Response does not contain: licenses or placements")
- exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Sniro Async Callback Response does not contain: licenses or placements")
}else{
return
}
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 bb2ad9507f..35bd25fabf 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
@@ -191,7 +191,9 @@ public class ResourceRequestBuilder {
HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
- File csarFile = new File(System.getProperty("mso.config.path") + "ASDC/" + map.get("name"));
+ String filePath = System.getProperty("mso.config.path") + "ASDC/" + map.get("version") + "/" + map.get("name");
+
+ File csarFile = new File(filePath);
if(!csarFile.exists()) {
throw new Exception("csar file does not exist.");
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
index 24c0548641..5e49ffcf40 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
@@ -47,7 +47,8 @@ public class RequestParameters implements Serializable {
private List<Map<String, Object>> userParams = new ArrayList<>();
@JsonProperty("aLaCarte")
private Boolean aLaCarte;
-
+ @JsonProperty("payload")
+ private String payload;
public String getSubscriptionServiceType() {
return subscriptionServiceType;
@@ -68,6 +69,13 @@ public class RequestParameters implements Serializable {
public Boolean isaLaCarte() {
return aLaCarte;
}
+
+ public String getPayload(){
+ return payload;
+ }
+ public void setPayload(String value){
+ this.payload = value;
+ }
public List<Map<String, Object>> getUserParams() {
return userParams;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 6d5fb2f825..eb4f4ca0d5 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -190,14 +190,19 @@ public class BBInputSetup implements JavaDelegate {
if(requestDetails == null) {
requestDetails = bbInputSetupUtils.getRequestDetails(requestId);
}
- ModelType modelType = requestDetails.getModelInfo().getModelType();
- if (aLaCarte && modelType.equals(ModelType.service)) {
- return this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
- } else if (aLaCarte && !modelType.equals(ModelType.service)) {
- return this.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
- vnfType);
- } else {
- return this.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ if (requestDetails.getModelInfo() == null) {
+ return this.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
+ }
+ else {
+ ModelType modelType = requestDetails.getModelInfo().getModelType();
+ if (aLaCarte && modelType.equals(ModelType.service)) {
+ return this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
+ } else if (aLaCarte && !modelType.equals(ModelType.service)) {
+ return this.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
+ vnfType);
+ } else {
+ return this.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ }
}
}
@@ -236,6 +241,25 @@ public class BBInputSetup implements JavaDelegate {
throw new Exception("Could not find relevant information for related Service Instance");
}
}
+
+ protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB,
+ RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction,
+ String resourceId) throws Exception {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
+ serviceInstance.setServiceInstanceId(serviceInstanceId);
+
+ List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
+
+ String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
+ org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
+
+ GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
+ genericVnfs.add(genericVnf);
+
+ return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, new Customer());
+
+ }
protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType)
@@ -790,7 +814,9 @@ public class BBInputSetup implements JavaDelegate {
customer = mapCustomer(globalCustomerId, subscriptionServiceType);
}
outputBB.setServiceInstance(serviceInstance);
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ if (customer.getServiceSubscription() != null) {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ }
outputBB.setCustomer(customer);
return outputBB;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
index 877d5bb88f..0c7eb0973f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
@@ -341,6 +341,7 @@ public class BBInputSetupMapperLayer {
requestParams.setaLaCarte(requestParameters.getALaCarte());
requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
requestParams.setUserParams(requestParameters.getUserParams());
+ requestParams.setPayload(requestParameters.getPayload());
return requestParams;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
index c74e81506c..42da72528f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
@@ -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.
@@ -37,9 +37,9 @@ public class ExceptionBuilder {
String msg = "Exception in %s.%s ";
try{
msoLogger.error(exception);
-
+
String errorVariable = "Error%s%s";
-
+
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
for (StackTraceElement traceElement : trace) {
if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) {
@@ -49,7 +49,7 @@ public class ExceptionBuilder {
break;
}
}
-
+
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, msg.toString());
execution.setVariable(errorVariable, exception.getMessage());
} catch (Exception ex){
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
index 9b3b8c2fb0..e065ccd14f 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
@@ -22,28 +22,12 @@ package org.onap.so.bpmn.common.scripts
import com.github.tomakehurst.wiremock.junit.WireMockRule
-import static org.junit.Assert.*;
import static org.mockito.Mockito.*
-
-import org.onap.so.rest.HttpHeader
-import org.mockito.MockitoAnnotations
-import org.mockito.runners.MockitoJUnitRunner
-import org.mockito.internal.debugging.MockitoDebuggerImpl
-import org.junit.Before
-import org.onap.so.bpmn.common.scripts.AaiUtil;
-import org.junit.Rule;
-import org.junit.Test
-import org.junit.Ignore
-import org.junit.runner.RunWith
-import org.junit.Before;
-import org.junit.Test;
import org.camunda.bpm.engine.ProcessEngineServices
import org.camunda.bpm.engine.RepositoryService
import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
import org.camunda.bpm.engine.repository.ProcessDefinition
import org.junit.Assert
-import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -51,16 +35,18 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mockito
import org.mockito.runners.MockitoJUnitRunner
-import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupName
import org.onap.so.bpmn.core.WorkflowException
import static com.github.tomakehurst.wiremock.client.WireMock.*
-import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
-@Ignore
class ConfirmVolumeGroupNameTest extends MsoGroovyTest {
+ private static final def AAA_URI = "uri_test"
+ private static final def AIC_CLOUD_REGION = "AicClReg_test"
+ private static final def VOLUME_GROUP_NAME = "volumeTestGName"
+ private static final def VOLUME_GROUP_ID = "vol_gr_id_test"
+
@Captor
ArgumentCaptor<ExecutionEntity> captor= ArgumentCaptor.forClass(ExecutionEntity.class);
@@ -68,6 +54,60 @@ class ConfirmVolumeGroupNameTest extends MsoGroovyTest {
public WireMockRule wireMockRule = new WireMockRule(8090);
@Test
+ void preProcessRequestSuccessful() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupId")).thenReturn(VOLUME_GROUP_ID)
+ when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME)
+ when(mockExecution.getVariable("ConfirmVolumeGroupName_aicCloudRegion")).thenReturn(AIC_CLOUD_REGION)
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('namespace_test')
+ when(mockExecution.getVariable("mso.workflow.ConfirmVolumeGroupName.aai.cloud-region.uri")).thenReturn(AAA_URI)
+ new ConfirmVolumeGroupName().preProcessRequest(mockExecution)
+
+ verifyInitProcessVariables(mockExecution)
+ verify(mockExecution).setVariable("CVGN_volumeGroupId", VOLUME_GROUP_ID)
+ verify(mockExecution).setVariable("CVGN_volumeGroupName", "volumeTestGName")
+ verify(mockExecution).setVariable("CVGN_aicCloudRegion", AIC_CLOUD_REGION)
+ verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint",
+ "${AAA_URI}/${AIC_CLOUD_REGION}/volume-groups/volume-group/" + VOLUME_GROUP_ID)
+ }
+
+ private void verifyInitProcessVariables(ExecutionEntity mockExecution) {
+ verify(mockExecution).setVariable("prefix", "CVGN_")
+ verify(mockExecution).setVariable("CVGN_volumeGroupId", null)
+ verify(mockExecution).setVariable("CVGN_volumeGroupName", null)
+ verify(mockExecution).setVariable("CVGN_aicCloudRegion", null)
+ verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint", null)
+ verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false)
+ verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode", null)
+ verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse", "")
+ verify(mockExecution).setVariable("CVGN_ResponseCode", null)
+ verify(mockExecution).setVariable("RollbackData", null)
+ }
+
+ @Test
+ void checkAAIQueryResult_volumeGroupNamesMatch() {
+ ExecutionEntity mockExecution = setupMock()
+ commonPartOfCheckAAIQueryTest(mockExecution, VOLUME_GROUP_NAME)
+ verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", true)
+ }
+
+ @Test
+ void checkAAIQueryResult_volumeGroupNamesDoNotMatch() {
+ ExecutionEntity mockExecution = setupMock()
+ commonPartOfCheckAAIQueryTest(mockExecution, "grName2")
+ verify(mockExecution, Mockito.times(0)).setVariable("CVGN_volumeGroupNameMatches", true)
+ }
+
+ private void commonPartOfCheckAAIQueryTest(ExecutionEntity mockExecution, def volumeGroupName) {
+ when(mockExecution.getVariable("CVGN_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME)
+ def xml = "<volume-group-name>" + volumeGroupName + "</volume-group-name>"
+ when(mockExecution.getVariable("CVGN_queryVolumeGroupResponse")).thenReturn(xml)
+ new ConfirmVolumeGroupName().checkAAIQueryResult(mockExecution)
+ verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false)
+ }
+
+ @Test
public void testQueryAAIForVolumeGroupId() {
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 9897c04ad8..d0ecedf878 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -301,6 +301,35 @@ public class BBInputSetupTest {
assertThat(actual, sameBeanAs(expected));
}
+
+ @Test
+ public void testGetGBBCM() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockCMExpected.json"),
+ GeneralBuildingBlock.class);
+
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ executeBB.setRequestId("requestId");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setModelInfo(null);
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(true);
+ requestDetails.setRequestParameters(requestParams);
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSuppressRollback(true);
+ requestDetails.setRequestInfo(requestInfo);
+ doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId());
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String resourceId = "123";
+ String requestAction = "createInstance";
+ doReturn(expected).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId);
+ doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(any(WorkflowResourceIds.class), any());
+ doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(any(org.onap.aai.domain.yang.GenericVnf.class));
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction,
+ resourceId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
@Test
public void testGetGBBALaCarteNonService() throws Exception {
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json
new file mode 100644
index 0000000000..8cd04fdd8e
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json
@@ -0,0 +1,29 @@
+{
+ "requestContext": {
+ "source": "VID",
+ "mso-request-id": "requestId",
+ "action": "createInstance",
+ "requestParameters": {
+ "userParams": [],
+ "aLaCarte": true
+ },
+ "configurationParameters": []
+ },
+ "orchContext": {
+ "is-rollback-enabled": true
+ },
+ "cloudRegion": {
+ "cloud-owner": "att-aic"
+ },
+ "userInput": null,
+ "customer": {
+ "vpn-bindings": []
+ },
+ "serviceInstance": {
+ "vnfs": [null],
+ "pnfs": [],
+ "allotted-resources": [],
+ "networks": [],
+ "configurations": []
+ }
+}