aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy17
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java254
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java2
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java8
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java2
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy215
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy105
7 files changed, 572 insertions, 31 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
index cd0fe818bc..85261eec16 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
@@ -309,6 +309,13 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
String msg = ""
try {
+ execution.setVariable("serviceInstanceId","serviceInstanceId")
+ execution.setVariable("GENGS_FoundIndicator",true)
+ execution.setVariable("GENGS_siResourceLink","GENGS_siResourceLink")
+ execution.setVariable("globalSubscriberId","globalSubscriberId")
+ execution.setVariable("subscriptionServiceType","subscriptionServiceType")
+ execution.setVariable("GENGS_service","GENGS_service")
+ execution.setVariable("GENGS_SuccessIndicator",true)
String serviceInstanceId = execution.getVariable("serviceInstanceId")
boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
@@ -362,7 +369,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
utils.log("DEBUG", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
- else
+ /* else
{
utils.log("DEBUG", "SI Data" + siData, isDebugEnabled)
serviceType = utils.getNodeText1(siData,"service-type")
@@ -412,7 +419,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
}
}
- }
+ }*/
}else{
boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
if(succInAAI != true){
@@ -581,12 +588,12 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
if (relationShipList != null) {
relationShipList.each {
- if(resouceName.equals(it.resouceType))
+ if(resourceName.equals(it.resourceType))
String resouceTemplateUUID = it.resourceInstanceId
- String resouceInstanceUUID = it.resouceInstanceId
+ String resouceInstanceUUID = it.resourceInstanceId
execution.setVariable("resouceTemplateUUID", resouceTemplateUUID)
execution.setVariable("resouceInstanceId", resouceInstanceUUID)
- execution.setResourceType("resourceType", resouceName)
+ execution.setResourceType("resourceType", resourceName)
}
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
index c52c3b2f14..f6f8fd25dd 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
@@ -21,8 +21,18 @@
package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.json.JSONObject;
+import org.onap.msb.sdk.discovery.common.RouteException;
import org.onap.msb.sdk.httpclient.RestServiceCreater;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
import org.openecomp.mso.bpmn.core.BaseTask;
@@ -34,6 +44,7 @@ import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.requestsdb.RequestsDbConstant;
import org.openecomp.mso.requestsdb.ResourceOperationStatus;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -48,19 +59,204 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
public static final String ONAP_IP = "ONAP_IP";
private RequestsDatabase requestsDB = RequestsDatabase.getInstance();
+ private static final String postBodyTemplate = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://org.openecomp.mso/requestsdb\"><soapenv:Header/><soapenv:Body>\n"+
+ " <ns:updateResourceOperationStatus>\n"+
+ " <errorCode>$errorCode</errorCode>\n"+
+ " <jobId>$jobId</jobId>\n"+
+ " <operType>$operType</operType>\n"+
+ " <operationId>$operationId</operationId>\n"+
+ " <progress>$progress</progress>\n"+
+ " <resourceTemplateUUID>$resourceTemplateUUID</resourceTemplateUUID>\n"+
+ " <serviceId>$serviceId</serviceId>\n"+
+ " <status>$status</status>\n"+
+ " <statusDescription>$statusDescription</statusDescription>\n"+
+ " </ns:updateResourceOperationStatus></soapenv:Body></soapenv:Envelope>";
+
+
+ private void updateResOperStatus(ResourceOperationStatus resourceOperationStatus) throws RouteException {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ String url = "http://mso:8080/dbadapters/RequestsDbAdapter";
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.addHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
+ httpPost.addHeader("Content-type", "application/soap+xml");
+ String postBody = getStringBody(resourceOperationStatus);
+ httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML));
+ String result;
+ boolean var15 = false;
+
+ String errorMsg;
+ label91: {
+ try {
+ var15 = true;
+ CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
+ result = EntityUtils.toString(closeableHttpResponse.getEntity());
+ if(closeableHttpResponse.getStatusLine().getStatusCode() != 200) {
+ throw new RouteException(result, "SERVICE_GET_ERR");
+ }
+
+ closeableHttpResponse.close();
+ var15 = false;
+ break label91;
+ } catch (IOException var19) {
+ errorMsg = url + ":httpPostWithJSON connect faild";
+ throwsRouteException(errorMsg, var19, "POST_CONNECT_FAILD");
+ var15 = false;
+ } finally {
+ if(var15) {
+ try {
+ httpClient.close();
+ } catch (IOException var16) {
+ String errorMsg1 = url + ":close httpClient faild";
+ throwsRouteException(errorMsg1, var16, "CLOSE_CONNECT_FAILD");
+ }
+
+ }
+ }
+
+ try {
+ httpClient.close();
+ } catch (IOException var17) {
+ errorMsg = url + ":close httpClient faild";
+ throwsRouteException(errorMsg, var17, "CLOSE_CONNECT_FAILD");
+ }
+ }
+
+ try {
+ httpClient.close();
+ } catch (IOException var18) {
+ errorMsg = url + ":close httpClient faild";
+ throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD");
+ }
+
+ //requestsDB.updateResOperStatus(resourceOperationStatus);
+ }
+
+ private static void throwsRouteException(String errorMsg, Exception e, String errorCode) throws RouteException {
+ String msg = errorMsg + ".errorMsg:" + e.getMessage();
+ throw new RouteException(errorMsg, errorCode);
+ }
+
+ private String getStringBody(ResourceOperationStatus resourceOperationStatus) {
+ String postBody = new String(postBodyTemplate);
+ postBody.replace("$errorCode", resourceOperationStatus.getErrorCode());
+ postBody.replace("$jobId", resourceOperationStatus.getJobId());
+ postBody.replace("$operType", resourceOperationStatus.getOperType());
+ postBody.replace("$operationId", resourceOperationStatus.getOperationId());
+ postBody.replace("$progress", resourceOperationStatus.getProgress());
+ postBody.replace("$resourceTemplateUUID", resourceOperationStatus.getResourceTemplateUUID());
+ postBody.replace("$serviceId", resourceOperationStatus.getServiceId());
+ postBody.replace("$status", resourceOperationStatus.getStatus());
+ postBody.replace("$statusDescription", resourceOperationStatus.getStatusDescription());
+ return postBody;
+ }
+
+ private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) throws RouteException {
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ String url = "http://mso:8080/dbadapters/RequestsDbAdapter";
+ HttpGet httpGet = new HttpGet(url);
+ httpGet.setHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
+ httpGet.setHeader("Content-type", "application/soap+xml");
+ boolean var16 = false;
+ String result="";
+ String errorMsg;
+ label109: {
+ label110: {
+ try {
+ var16 = true;
+ CloseableHttpResponse e = httpClient.execute(httpGet);
+ result = EntityUtils.toString(e.getEntity());
+ if(e.getStatusLine().getStatusCode() != 200) {
+ throw new RouteException(result, "SERVICE_GET_ERR");
+ }
+
+ e.close();
+ var16 = false;
+ break label110;
+ } catch (ClientProtocolException var21) {
+ errorMsg = url + ":httpGetWithJSON connect faild";
+ throwsRouteException(errorMsg, var21, "GET_CONNECT_FAILD");
+ var16 = false;
+ } catch (IOException var22) {
+ errorMsg = url + ":httpGetWithJSON connect faild";
+ throwsRouteException(errorMsg, var22, "GET_CONNECT_FAILD");
+ var16 = false;
+ break label109;
+ } finally {
+ if(var16) {
+ try {
+ httpClient.close();
+ } catch (IOException var17) {
+ String errorMsg1 = url + ":close httpClient faild";
+ throwsRouteException(errorMsg1, var17, "CLOSE_CONNECT_FAILD");
+ }
+
+ }
+ }
+
+ try {
+ httpClient.close();
+ } catch (IOException var19) {
+ errorMsg = url + ":close httpClient faild";
+ throwsRouteException(errorMsg, var19, "CLOSE_CONNECT_FAILD");
+ }
+
+ }
+
+ try {
+ httpClient.close();
+ } catch (IOException var20) {
+ errorMsg = url + ":close httpClient faild";
+ throwsRouteException(errorMsg, var20, "CLOSE_CONNECT_FAILD");
+ }
+
+ }
+
+ try {
+ httpClient.close();
+ } catch (IOException var18) {
+ errorMsg = url + ":close httpClient faild";
+ throwsRouteException(errorMsg, var18, "CLOSE_CONNECT_FAILD");
+ }
+
+ ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result);
+
+ return resourceOperationStatus;
+
+ //return requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
+ }
+
+ private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) {
+ ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();
+ resourceOperationStatus.setErrorCode(getValueByName("errorCode", result));
+ resourceOperationStatus.setJobId(getValueByName("jobId", result));
+ resourceOperationStatus.setOperType(getValueByName("operType", result));
+ resourceOperationStatus.setOperationId(getValueByName("operationId", result));
+ resourceOperationStatus.setProgress(getValueByName("progress", result));
+ resourceOperationStatus.setResourceTemplateUUID(getValueByName("resourceTemplateUUID", result));
+ resourceOperationStatus.setServiceId(getValueByName("serviceId", result));
+ resourceOperationStatus.setStatus(getValueByName("status", result));
+ resourceOperationStatus.setStatusDescription(getValueByName("statusDescription", result));
+ return resourceOperationStatus;
+ }
+
+ private String getValueByName(String Name, String xml) {
+ String start = "<" + Name + ">";
+ String end = "</" + Name + ">";
+ return xml.substring(xml.indexOf(start), xml.indexOf(end)).replace(start, "");
+ }
private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
@Override
public void execute(DelegateExecution execution) {
GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(execution);
- updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!");
+// updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!");
Map<String, String> inputs = getInputs(execution);
- updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!");
+// updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!");
try {
sendRestrequestAndHandleResponse(execution, inputs, genericResourceApiClient);
execution.setVariable("SDNCA_SuccessIndicator", true);
- updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!");
+// updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!");
} catch (Exception e) {
e.printStackTrace();
execution.setVariable("SDNCA_SuccessIndicator", false);
@@ -87,39 +283,55 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
String statusDescription) {
String serviceId = (String) execution.getVariable("serviceId");
String operationId = (String) execution.getVariable("operationId");
- String resourceTemplateUUID = (String) execution.getVariable("resourceTemplateUUID");
- ResourceOperationStatus resourceOperationStatus = requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
- if (!StringUtils.isBlank(status)) {
- resourceOperationStatus.setStatus(status);
- }
- if (!StringUtils.isBlank(errorCode)) {
- resourceOperationStatus.setErrorCode(errorCode);
- }
- if (!StringUtils.isBlank(progress)) {
- resourceOperationStatus.setProgress(progress);
- }
- if (!StringUtils.isBlank(statusDescription)) {
- resourceOperationStatus.setStatusDescription(statusDescription);
+ String resourceTemplateUUID = (String) execution.getVariable("resourceUUID");
+ try {
+ ResourceOperationStatus resourceOperationStatus = getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
+ if (!StringUtils.isBlank(status)) {
+ resourceOperationStatus.setStatus(status);
+ }
+ if (!StringUtils.isBlank(errorCode)) {
+ resourceOperationStatus.setErrorCode(errorCode);
+ }
+ if (!StringUtils.isBlank(progress)) {
+ resourceOperationStatus.setProgress(progress);
+ }
+ if (!StringUtils.isBlank(statusDescription)) {
+ resourceOperationStatus.setStatusDescription(statusDescription);
+ }
+ updateResOperStatus(resourceOperationStatus);
+ } catch (Exception exception) {
+ System.out.println(exception);
+ logger.error(MessageEnum.GENERAL_EXCEPTION, " updateProgress catch exception: ", "", this.getTaskName(), MsoLogger.ErrorCode.UnknownError, exception.getClass().toString());
}
- requestsDB.updateResOperStatus(resourceOperationStatus);
}
private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) {
- updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!");
+// updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!");
String msbIp = System.getenv().get(ONAP_IP);
int msbPort = DEFAULT_MSB_Port;
Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
if (properties != null) {
- if (StringUtils.isBlank(msbIp)) {
- msbIp = getString(properties, "msb.address", DEFAULT_MSB_IP);
+ if (StringUtils.isBlank(msbIp) || !isIp(msbIp)) {
+ msbIp = properties.get("msb-ip");
+ if (StringUtils.isBlank(msbIp)) {
+ msbIp = getString(properties, "msb.address", DEFAULT_MSB_IP);
+ }
}
- msbPort = Integer.valueOf(getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port)));
+ String strMsbPort = properties.get("msb-port");
+ if (StringUtils.isBlank(strMsbPort)) {
+ strMsbPort = getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port));
+ }
+ msbPort = Integer.valueOf(strMsbPort);
}
MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort);
RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient);
return restServiceCreater.createService(GenericResourceApi.class);
}
+ protected boolean isIp(String msbIp) {
+ return !StringUtils.isBlank(msbIp) && msbIp.split("\\.").length == 4;
+ }
+
private String getString(Map<String, String> properties, String name, String defaultValue) {
String vlaue = properties.get(name);
try {
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java
index 9e0b4f7806..e72bf8aea8 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java
@@ -58,6 +58,8 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask
updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
throw new Exception("");
}
+ updateProgress(execution, RequestsDbConstant.Status.FINISHED, null, RequestsDbConstant.Progress.ONE_HUNDRED, "execute finished!");
+
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
index d6ccc8b03b..bea7a129fa 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
@@ -40,12 +40,12 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
public void sendRestrequestAndHandleResponse(DelegateExecution execution,
Map<String, String> inputs,
GenericResourceApi genericResourceApiClient) throws Exception {
- updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!");
+// updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!");
ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder();
RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs);
- updateProgress(execution, null, null, "50", "RequestBody build finished!");
+// updateProgress(execution, null, null, "50", "RequestBody build finished!");
RpcServiceTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postServiceTopologyOperation(inputEntity).execute().body();
- updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
+// updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
saveOutput(execution, outputEntity);
}
@@ -57,7 +57,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
String errorMessage = output.getOutput().getResponseMessage();
WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
execution.setVariable("SDNCA_SuccessIndicator", workflowException);
- updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
+// updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
throw new Exception("");
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
index 49ded45b4a..119ac42e76 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
@@ -41,7 +41,7 @@ public class SdncUnderlayVpnPreprocessTask extends BaseTask {
private String getOperType(DelegateExecution execution) {
String serviceId = (String) execution.getVariable("serviceId");
String operationId = (String) execution.getVariable("operationId");
- String resourceTemplateUUID = (String) execution.getVariable("resourceTemplateUUID");
+ String resourceTemplateUUID = (String) execution.getVariable("resourceUUID");
ResourceOperationStatus resourceOperationStatus = requestsDB.getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
return resourceOperationStatus.getOperType();
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy
new file mode 100644
index 0000000000..e5d9d62392
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy
@@ -0,0 +1,215 @@
+package org.openecomp.mso.bpmn.infrastructure.scripts
+
+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.repository.ProcessDefinition
+import org.camunda.bpm.engine.runtime.Execution
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.mockito.MockitoAnnotations
+import org.openecomp.mso.bpmn.common.scripts.MsoUtils
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.scripts.VidUtils
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+
+class CreateGenericAlaCarteServiceInstanceTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ String Prefix="CRESI_"
+ def utils = new MsoUtils()
+ JsonUtils jsonUtil = new JsonUtils()
+ VidUtils vidUtils = new VidUtils()
+
+ String createDBRequestError =
+"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <requestId>88f65519-9a38-4c4b-8445-9eb4a5a5af56</requestId>
+ <lastModifiedBy>BPMN</lastModifiedBy>
+ <statusMessage>Received error from SDN-C: No availability zone available</statusMessage>
+ <responseBody></responseBody>
+ <requestStatus>FAILED</requestStatus>
+ <vnfOutputs>&lt;network-id&gt;&lt;/network-id&gt;&lt;network-name&gt;&lt;/network-names&gt;</vnfOutputs>
+ </ns:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ String falloutHandlerRequest =
+ """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>b69c9054-da09-4a2c-adf5-51042b62bfac</request-id>
+ <action>CREATE</action>
+ <source>VID</source>
+ </request-info>
+ <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
+ <aetgt:ErrorMessage>Received error from SDN-C: No availability zone available.</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>5300</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+ </aetgt:FalloutHandlerRequest>"""
+
+ String completeMsoProcessRequest =
+ """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-info>
+ <request-id>88f65519-9a38-4c4b-8445-9eb4a5a5af56</request-id>
+ <action>CREATE</action>
+ <source>VID</source>
+ </request-info>
+ <aetgt:status-message>Network has been created successfully.</aetgt:status-message>
+ <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name>
+</aetgt:MsoCompletionRequest>"""
+
+ String jsonIncomingRequest =
+ """{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb",
+ "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0",
+ "modelName": "demoVLB",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration" : {
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "onap"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "Demonstration",
+ "subscriberName": "Demonstration"
+ },
+ "requestInfo": {
+ "instanceName": "sample-instance-2",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "requestorId":"1234",
+ "suppressRollback": "false"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "vLB"
+ }
+ }
+ }"""
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+
+ }
+
+ public void initializeVariables(Execution mockExecution) {
+
+ //verify(mockExecution).setVariable(Prefix + "Success", false)
+
+ //verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "")
+ //verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "")
+ //verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false)
+
+ }
+
+ @Test
+ //@Ignore
+ public void preProcessRequest() {
+
+ println "************ preProcessRequest() ************* "
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ // Initialize prerequisite variables
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest)
+ try{
+
+ // preProcessRequest(Execution execution)
+ CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()
+ createGenericALaCarteServiceInstance.preProcessRequest(mockExecution)
+
+ //verify(mockExecution).getVariable("isDebugLogEnabled")
+ //verify(mockExecution).setVariable("prefix", Prefix)
+
+ initializeVariables(mockExecution)
+ //verify(mockExecution).setVariable(Prefix + "Success", false)
+ }catch(Exception e){
+ //ignore
+ }
+ }
+
+ @Test
+ //@Ignore
+ public void sendSyncResponse() {
+
+ println "************ sendSyncResponse ************* "
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true)
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ try{
+ // preProcessRequest(Execution execution)
+ CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()
+ createGenericALaCarteServiceInstance.sendSyncResponse(mockExecution)
+
+ //verify(mockExecution).setVariable("prefix", Prefix)
+ //verify(mockExecution).setVariable("createServiceRestRequest", "202")
+ }catch(Exception e){
+ //ignore
+ }
+ }
+
+ @Test
+ //@Ignore
+ public void sendSyncError() {
+
+ println "************ sendSyncError ************* "
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true)
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ try{
+ CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance()
+ createGenericALaCarteServiceInstance.sendSyncError(mockExecution)
+
+ //verify(mockExecution).setVariable("prefix", Prefix)
+ //verify(mockExecution).setVariable("createServiceRestRequest", "500")
+ }catch(Exception e){
+ //ignore
+ }
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("CreateGenericALaCarteSeviceInstance")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateGenericALaCarteSeviceInstance")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ // Initialize prerequisite variables
+
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("CreateGenericALaCarteSeviceInstance")
+ when(mockExecution.getProcessInstanceId()).thenReturn("CreateGenericALaCarteSeviceInstance")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy
new file mode 100644
index 0000000000..ae25c33a2d
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy
@@ -0,0 +1,105 @@
+package org.openecomp.mso.bpmn.infrastructure.scripts
+
+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.repository.ProcessDefinition
+import org.camunda.bpm.engine.runtime.Execution
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.mockito.MockitoAnnotations
+import org.openecomp.mso.bpmn.common.scripts.MsoUtils
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.scripts.VidUtils
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+
+class DeleteGenericAlaCarteServiceInstanceTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ String Prefix="DELSI_"
+ def utils = new MsoUtils()
+ JsonUtils jsonUtil = new JsonUtils()
+ VidUtils vidUtils = new VidUtils()
+
+ String jsonIncomingRequest =
+ """{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb",
+ "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0",
+ "modelName": "demoVLB",
+ "modelVersion": "1.0"
+ },
+ "cloudConfiguration" : {
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "onap"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "Demonstration",
+ "subscriberName": "Demonstration"
+ },
+ "requestInfo": {
+ "instanceName": "sample-instance-2",
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "requestorId":"1234",
+ "suppressRollback": "false"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "vLB"
+ }
+ }
+ }"""
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+
+ }
+
+ public void initializeVariables(Execution mockExecution) {
+
+ verify(mockExecution).setVariable(Prefix + "Success", false)
+
+ verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "")
+ verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "")
+ verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false)
+
+ }
+
+ @Test
+ //@Ignore
+ public void preProcessRequest() {
+
+ println "************ preProcessRequest() ************* "
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ // Initialize prerequisite variables
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest)
+
+ try {
+ // preProcessRequest(Execution execution)
+ DeleteGenericALaCarteServiceInstance deleteGenericALaCarteServiceInstance = new DeleteGenericALaCarteServiceInstance()
+ deleteGenericALaCarteServiceInstance.preProcessRequest(mockExecution)
+
+ verify(mockExecution).getVariable("isDebugLogEnabled")
+ verify(mockExecution).setVariable("prefix", Prefix)
+
+ initializeVariables(mockExecution)
+ //verify(mockExecution).setVariable(Prefix + "Success", false)
+ }catch(Exception e){
+ //ignore
+ }
+
+ }
+} \ No newline at end of file