diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
6 files changed, 83 insertions, 1422 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 57bfb4ed30..151ba2c3aa 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -135,12 +135,6 @@ <version>2.3.0</version> </dependency> <dependency> - <groupId>org.camunda.bpm.extension</groupId> - <artifactId>camunda-bpm-assert</artifactId> - <version>2.0-alpha2</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.camunda.bpm.springboot</groupId> <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId> <version>2.3.0</version> @@ -202,5 +196,10 @@ <artifactId>micrometer-registry-prometheus</artifactId> <version>1.0.5</version> </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>so-bpmn-tasks</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> </project> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy b/bpmn/mso-infrastructure-bpmn/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy deleted file mode 100644 index bb58030683..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy +++ /dev/null @@ -1,425 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.infrastructure.scripts - -import org.json.JSONObject -import org.json.XML; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.recipe.ResourceInput; -import org.onap.so.bpmn.common.resource.ResourceRequestBuilder -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder -import org.onap.so.rest.APIResponse -import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory -import java.util.UUID; - -import org.camunda.bpm.engine.runtime.Execution -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig - -/** - * This groovy class supports the <class>CreateActivateSDNCResource.bpmn</class> process. - * flow for SDNC Network Resource Create - */ -public class CreateActivateSDNCResource extends AbstractServiceTaskProcessor { - - String Prefix="CRESDNCRES_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - JsonUtils jsonUtil = new JsonUtils() - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - public void preProcessRequest(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled) - try { - - //get bpmn inputs from resource request. - String requestId = execution.getVariable("mso-request-id") - String requestAction = execution.getVariable("requestAction") - utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled) - String recipeParamsFromRequest = execution.getVariable("recipeParams") - utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled) - String resourceInput = execution.getVariable("resourceInput") - utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled) - //Get ResourceInput Object - ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) - execution.setVariable(Prefix + "resourceInput", resourceInputObj) - - //Deal with recipeParams - String recipeParamsFromWf = execution.getVariable("recipeParamXsd") - String resourceName = resourceInputObj.getResourceInstanceName() - //For sdnc requestAction default is "createNetworkInstance" - String operationType = "Network" - String apiType = "network" - if(!StringUtils.isBlank(recipeParamsFromRequest)){ - //the operationType from worflow(first node) is second priority. - operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType") - apiType = jsonUtil.getJsonValue(recipeParamsFromRequest, "apiType") - } - if(!StringUtils.isBlank(recipeParamsFromWf)){ - //the operationType from worflow(first node) is highest priority. - operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") - apiType = jsonUtil.getJsonValue(recipeParamsFromRequest, "apiType") - } - - execution.setVariable(Prefix + "operationType", operationType) - execution.setVariable(Prefix + "apiType", apiType) - execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) - execution.setVariable("mso-request-id", requestId) - execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) - //TODO Here build networkrequest - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - String msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - - String customizeResourceParam(String netowrkInputParametersJson) { - List<Map<String, Object>> paramList = new ArrayList(); - JSONObject jsonObject = new JSONObject(netowrkInputParametersJson); - Iterator iterator = jsonObject.keys(); - while (iterator.hasNext()) { - String key = iterator.next(); - HashMap<String, String> hashMap = new HashMap(); - hashMap.put("name", key); - hashMap.put("value", jsonObject.get(key)) - paramList.add(hashMap) - } - Map<String, List<Map<String, Object>>> paramMap = new HashMap(); - paramMap.put("param", paramList); - - return new JSONObject(paramMap).toString(); - } - - public void prepareSDNCRequest (DelegateExecution execution) { - String svcAction = "create" - prepareSDNCRequestReq(execution, svcAction, "") - } - - - public void prepareSDNCActivateRequest (DelegateExecution execution) { - String svcAction = "activate" - String sndcResourceId = execution.getVariable(Prefix + "sdncResourceId") - prepareSDNCRequestReq(execution, svcAction, sndcResourceId) - } - /** - * Pre Process the BPMN Flow Request - * Inclouds: - * generate the nsOperationKey - * generate the nsParameters - */ - public void prepareSDNCRequestReq (DelegateExecution execution, String svcAction, String sdncResourceId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) - - try { - // get variables - String operationType = execution.getVariable(Prefix + "operationType") - String sdnc_apiType = execution.getVariable(Prefix + "apiType") - String sdnc_svcAction = svcAction - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" - - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String hdrRequestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - String source = execution.getVariable("source") - String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String serviceType = resourceInputObj.getServiceType() - String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() - String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid() - String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() - String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() - String globalCustomerId = resourceInputObj.getGlobalSubscriberId() - String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); - String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion() - String resourceInputPrameters = resourceInputObj.getResourceParameters() - String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs") - //here convert json string to xml string - String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson))) - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${sdnc_svcAction}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${sdnc_apiType}-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${hdrRequestId}</request-id> - <request-action>${sdnc_requestAction}</request-action> - <source>${source}</source> - <notification-url></notification-url> - <order-number></order-number> - <order-version></order-version> - </request-information> - <service-information> - <service-id>${serviceInstanceId}</service-id> - <subscription-service-type>${serviceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid> - <model-uuid>${serviceModelUuid}</model-uuid> - <model-version>${serviceModelVersion}</model-version> - <model-name>${serviceModelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <${sdnc_apiType}-information> - <${sdnc_apiType}-id>${sdncResourceId}</${sdnc_apiType}-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </${sdnc_apiType}-information> - <${sdnc_apiType}-request-input> - <${sdnc_apiType}-input-parameters>${netowrkInputParameters}</${sdnc_apiType}-input-parameters> - </${sdnc_apiType}-request-input> - </sdncadapterworkflow:SDNCRequestData> - </aetgt:SDNCAdapterWorkflowRequest>""".trim() - - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) - execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) - utils.log("INFO","sdncAdapterWorkflowRequest :" + sndcTopologyCreateRequesAsString, isDebugEnabled) - utils.log("DEBUG","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyCreateRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled) - } - - private void setProgressUpdateVariables(DelegateExecution execution, String body) { - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - execution.setVariable("CVFMI_updateResOperStatusRequest", body) - } - - public void prepareUpdateBeforeCreateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateBeforeCreateSDNCResource *****", isDebugEnabled) - - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String operationId = resourceInputObj.getOperationId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String progress = "20" - String status = "processing" - String statusDescription = "Create " + modelName - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateBeforeCreateSDNCResource *****", isDebugEnabled) - } - - public void postCreateSDNC(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - ServicePluginFactory.getInstance().test() - utils.log("INFO"," ***** Started postCreateSDNC *****", isDebugEnabled) - String sdnc_apiType = execution.getVariable(Prefix + "apiType") - String sdncAdapterResponse = execution.getVariable("sdncAdapterResponse") - utils.log("INFO","sdncAdapterResponse for create:" + sdncAdapterResponse , isDebugEnabled) - sdncAdapterResponse = sdncAdapterResponse.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") - sdncAdapterResponse = sdncAdapterResponse.replaceAll('tag0:', '').replaceAll(':tag0', '') - utils.log("INFO","sdncAdapterResponse for create after replace:" + sdncAdapterResponse , isDebugEnabled) - //if it is vnf we need to query the vnf-id,if it is network , we need to query the network-id - String sdncRespData = utils.getNodeText1(sdncAdapterResponse, "RequestData") - utils.log("INFO","sdncRespData:" + sdncRespData , isDebugEnabled) - String objectKey = "/" + sdnc_apiType + "/" - String objectDataKey = "/" + sdnc_apiType + "-data/" - String objectPath = utils.getNodeText1(sdncRespData, "object-path") - - String resourceObjId = objectPath.substring(objectPath.indexOf(objectKey) + objectKey.length(), objectPath.indexOf(objectDataKey)) - utils.log("INFO", "resourceObjId:" + resourceObjId, isDebugEnabled) - execution.setVariable(Prefix + "sdncResourceId", resourceObjId) - - utils.log("INFO"," ***** End postCreateSDNC *****", isDebugEnabled) - - } - - public void postActivateSDNC(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started postActivateSDNC *****", isDebugEnabled) - String sdncAdapterResponse = execution.getVariable("sdncAdapterResponse") - utils.log("INFO","sdncAdapterResponse for activate:" + sdncAdapterResponse , isDebugEnabled) - utils.log("INFO"," ***** End postActivateSDNC *****", isDebugEnabled) - } - - public void prepareUpdateAfterCreateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateAfterCreateSDNCResource *****", isDebugEnabled) - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String operationId = resourceInputObj.getOperationId() - String progress = "50" - String status = "processing" - String statusDescription = "Instantiate " + modelName - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateAfterCreateSDNCResource *****", isDebugEnabled) - } - - public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateAfterActivateSDNCResource *****", isDebugEnabled) - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String operationId = resourceInputObj.getOperationId() - String progress = "100" - String status = "finished" - String statusDescription = "Instantiate " + modelName + " finished" - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateAfterActivateSDNCResource *****", isDebugEnabled) - } - - public void postCreateSDNCCall(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) - String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") - String responseObj = execution.getVariable(Prefix + "SuccessIndicator") - - utils.log("INFO","response from sdnc, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled) - utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String operationStatus = "finished" - // RESTResponse for main flow - String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) - sendWorkflowResponse(execution, 202, resourceOperationResp) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java deleted file mode 100644 index bd781756a5..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ /dev/null @@ -1,422 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.infrastructure.workflow.service; - -import java.io.IOException; -import java.net.SocketTimeoutException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.http.HttpResponse; -import org.apache.http.ParseException; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.camunda.bpm.engine.runtime.Execution; -import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.bpmn.core.domain.ServiceDecomposition; -import org.onap.so.bpmn.core.json.JsonUtils; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -public class ServicePluginFactory { - - // SOTN calculate route - public static final String OOF_Default_EndPoint = "http://192.168.1.223:8443/oof/sotncalc"; - - public static final String Third_SP_Default_EndPoint = "http://192.168.1.223:8443/sp/resourcemgr/querytps"; - - private static final int DEFAULT_TIME_OUT = 60000; - - static JsonUtils jsonUtil = new JsonUtils(); - - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ServicePluginFactory.class); - - private static ServicePluginFactory instance; - - - public static synchronized ServicePluginFactory getInstance() { - if (null == instance) { - instance = new ServicePluginFactory(); - } - return instance; - } - - private String getThirdSPEndPoint(){ - return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", Third_SP_Default_EndPoint); - } - - private String getOOFCalcEndPoint(){ - return UrnPropertiesReader.getVariable("mso.service-plugin.oof-calc-endpoint", OOF_Default_EndPoint); - } - - - public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { - - // now only for sotn - if (isSOTN(serviceDecomposition, uuiRequest)) { - // We Need to query the terminalpoint of the VPN by site location - // info - return preProcessSOTNService(serviceDecomposition, uuiRequest); - } - return uuiRequest; - } - - public String doServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // now only for sotn - if (isSOTN(serviceDecomposition, uuiRequest)) { - return doSOTNServiceHoming(serviceDecomposition, uuiRequest); - } - return uuiRequest; - } - - private boolean isSOTN(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // there should be a register platform , we check it very simple here. - return uuiRequest.contains("clientSignal") && uuiRequest.contains("vpnType"); - } - - private String preProcessSOTNService(ServiceDecomposition serviceDecomposition, String uuiRequest) { - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - List<Object> resources = (List<Object>) serviceParametersObject.get("resources"); - // This is a logic for demo , it could not be finalized to community. - String srcLocation = ""; - String dstLocation = ""; - String srcClientSignal = ""; - String dstClientSignal = ""; - // support R2 uuiReq and R1 uuiReq - // logic for R2 uuiRequest params in service level - for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("location")) { - if ("".equals(srcLocation)) { - srcLocation = (String) entry.getValue(); - } else if ("".equals(dstLocation)) { - dstLocation = (String) entry.getValue(); - } - } - if (entry.getKey().toLowerCase().contains("clientsignal")) { - if ("".equals(srcClientSignal)) { - srcClientSignal = (String) entry.getValue(); - } else if ("".equals(dstClientSignal)) { - dstClientSignal = (String) entry.getValue(); - } - } - } - - // logic for R1 uuiRequest, params in resource level - for (Object resource : resources) { - Map<String, Object> resourceObject = (Map<String, Object>) resource; - Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); - Map<String, Object> resourceRequestInputs = (Map<String, Object>) resourceParametersObject - .get("requestInputs"); - for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("location")) { - if ("".equals(srcLocation)) { - srcLocation = (String) entry.getValue(); - } else if ("".equals(dstLocation)) { - dstLocation = (String) entry.getValue(); - } - } - if (entry.getKey().toLowerCase().contains("clientsignal")) { - if ("".equals(srcClientSignal)) { - srcClientSignal = (String) entry.getValue(); - } else if ("".equals(dstClientSignal)) { - dstClientSignal = (String) entry.getValue(); - } - } - } - } - - Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); - // here we put client signal to vpn resource inputs - vpnRequestInputs.put("src-client-signal", srcClientSignal); - vpnRequestInputs.put("dst-client-signal", dstClientSignal); - - // Now we need to query terminal points from SP resourcemgr system. - List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation); - Map<String, Object> tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(0); - - serviceRequestInputs.put("inner-src-access-provider-id", tpInfoMap.get("access-provider-id")); - serviceRequestInputs.put("inner-src-access-client-id", tpInfoMap.get("access-client-id")); - serviceRequestInputs.put("inner-src-access-topology-id", tpInfoMap.get("access-topology-id")); - serviceRequestInputs.put("inner-src-access-node-id", tpInfoMap.get("access-node-id")); - serviceRequestInputs.put("inner-src-access-ltp-id", tpInfoMap.get("access-ltp-id")); - tpInfoMap = (Map<String, Object>) locationTerminalPointList.get(1); - - serviceRequestInputs.put("inner-dst-access-provider-id", tpInfoMap.get("access-provider-id")); - serviceRequestInputs.put("inner-dst-access-client-id", tpInfoMap.get("access-client-id")); - serviceRequestInputs.put("inner-dst-access-topology-id", tpInfoMap.get("access-topology-id")); - serviceRequestInputs.put("inner-dst-access-node-id", tpInfoMap.get("access-node-id")); - serviceRequestInputs.put("inner-dst-access-ltp-id", tpInfoMap.get("access-ltp-id")); - - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - private List<Object> queryTerminalPointsFromServiceProviderSystem(String srcLocation, String dstLocation) { - Map<String, String> locationSrc = new HashMap<>(); - locationSrc.put("location", srcLocation); - Map<String, String> locationDst = new HashMap<>(); - locationDst.put("location", dstLocation); - List<Map<String, String>> locations = new ArrayList<>(); - locations.add(locationSrc); - locations.add(locationDst); - List<Object> returnList = new ArrayList<>(); - String reqContent = getJsonString(locations); - String url = getThirdSPEndPoint(); - String responseContent = sendRequest(url, "POST", reqContent); - if (null != responseContent) { - returnList = getJsonObject(responseContent, List.class); - } - return returnList; - } - - private Map<String, Object> getVPNResourceRequestInputs(List<Object> resources) { - for (Object resource : resources) { - Map<String, Object> resourceObject = (Map<String, Object>) resource; - Map<String, Object> resourceParametersObject = (Map<String, Object>) resourceObject.get("parameters"); - Map<String, Object> resourceRequestInputs = (Map<String, Object>) resourceParametersObject - .get("requestInputs"); - for (Entry<String, Object> entry : resourceRequestInputs.entrySet()) { - if (entry.getKey().toLowerCase().contains("vpntype")) { - return resourceRequestInputs; - } - } - } - return null; - } - - public static void main(String args[]){ - String str = "restconf/config/GENERIC-RESOURCE-API:services/service/eca7e542-12ba-48de-8544-fac59303b14e/service-data/networks/network/aec07806-1671-4af2-b722-53c8e320a633/network-data/"; - - int index1 = str.indexOf("/network/"); - int index2 = str.indexOf("/network-data"); - - String str1 = str.substring(index1 + "/network/".length(), index2); - System.out.println(str1); - - } - - private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) { - // query the route for the service. - Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class); - Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service"); - Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters"); - Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs"); - Map<String, Object> oofQueryObject = new HashMap<>(); - List<Object> resources = (List<Object>) serviceParametersObject.get("resources"); - oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id")); - oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id")); - oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id")); - oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id")); - oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id")); - oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id")); - oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id")); - oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id")); - oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id")); - oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id")); - String oofRequestReq = getJsonString(oofQueryObject); - String url = getOOFCalcEndPoint(); - String responseContent = sendRequest(url, "POST", oofRequestReq); - - List<Object> returnList = new ArrayList<>(); - if (null != responseContent) { - returnList = getJsonObject(responseContent, List.class); - } - // in demo we have only one VPN. no cross VPNs, so get first item. - Map<String, Object> returnRoute = getReturnRoute(returnList); - Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources); - vpnRequestInputs.putAll(returnRoute); - String newRequest = getJsonString(uuiObject); - return newRequest; - } - - private Map<String, Object> getReturnRoute(List<Object> returnList){ - Map<String, Object> returnRoute = new HashMap<>(); - for(Object returnVpn :returnList){ - Map<String, Object> returnVpnInfo = (Map<String, Object>) returnVpn; - String accessTopoId = (String)returnVpnInfo.get("access-topology-id"); - if("100".equals(accessTopoId)){ - returnRoute.putAll(returnVpnInfo); - } - else if("101".equals(accessTopoId)){ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain1-" + key, returnVpnInfo.get(key)); - } - } - else if("102".equals(accessTopoId)){ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain2-" + key, returnVpnInfo.get(key)); - } - } - else{ - for(String key : returnVpnInfo.keySet()){ - returnRoute.put("domain" + accessTopoId +"-" + key, returnVpnInfo.get(key)); - } - } - } - return returnRoute; - } - - private Map<String, Object> getResourceParams(Execution execution, String resourceCustomizationUuid, - String serviceParameters) { - List<String> resourceList = jsonUtil.StringArrayToList(execution, - (String) JsonUtils.getJsonValue(serviceParameters, "resources")); - // Get the right location str for resource. default is an empty array. - String resourceInputsFromUui = ""; - for (String resource : resourceList) { - String resCusUuid = (String) JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); - if (resourceCustomizationUuid.equals(resCusUuid)) { - String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); - resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); - } - } - Map<String, Object> resourceInputsFromUuiMap = getJsonObject(resourceInputsFromUui, Map.class); - return resourceInputsFromUuiMap; - } - - public static <T> T getJsonObject(String jsonstr, Class<T> type) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - try { - return mapper.readValue(jsonstr, type); - } catch (IOException e) { - LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, - "fail to unMarshal json", e); - } - return null; - } - - public static String getJsonString(Object srcObj) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - String jsonStr = null; - try { - jsonStr = mapper.writeValueAsString(srcObj); - } catch (JsonProcessingException e) { - LOGGER.debug("SdcToscaParserException", e); - e.printStackTrace(); - } - return jsonStr; - } - - private static String sendRequest(String url, String methodType, String content) { - - String msbUrl = url; - HttpRequestBase method = null; - HttpResponse httpResponse = null; - - try { - int timeout = DEFAULT_TIME_OUT; - - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) - .setConnectionRequestTimeout(timeout).build(); - - HttpClient client = HttpClientBuilder.create().build(); - - if ("POST".equals(methodType.toUpperCase())) { - HttpPost httpPost = new HttpPost(msbUrl); - httpPost.setConfig(requestConfig); - httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPost; - } else if ("PUT".equals(methodType.toUpperCase())) { - HttpPut httpPut = new HttpPut(msbUrl); - httpPut.setConfig(requestConfig); - httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); - method = httpPut; - } else if ("GET".equals(methodType.toUpperCase())) { - HttpGet httpGet = new HttpGet(msbUrl); - httpGet.setConfig(requestConfig); - method = httpGet; - } else if ("DELETE".equals(methodType.toUpperCase())) { - HttpDelete httpDelete = new HttpDelete(msbUrl); - httpDelete.setConfig(requestConfig); - method = httpDelete; - } - - // now have no auth - // String userCredentials = - // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP, - // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); - // String authorization = "Basic " + - // DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - // method.setHeader("Authorization", authorization); - - httpResponse = client.execute(method); - String responseContent = null; - if (null != httpResponse && httpResponse.getEntity() != null) { - try { - responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); - } catch (ParseException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (null != method) { - method.reset(); - } - method = null; - return responseContent; - - } catch (SocketTimeoutException | ConnectTimeoutException e) { - return null; - - } catch (Exception e) { - return null; - - } finally { - if (httpResponse != null) { - try { - EntityUtils.consume(httpResponse.getEntity()); - } catch (Exception e) { - } - } - if (method != null) { - try { - method.reset(); - } catch (Exception e) { - - } - } - } - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetServiceIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetServiceIT.java deleted file mode 100644 index 38d05fe28e..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetServiceIT.java +++ /dev/null @@ -1,560 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; - - -/** - * Unit Test for the GenericGetService Sub Flow - */ - -public class GenericGetServiceIT extends BaseIntegrationTest { - - - @Test - public void testGenericGetService_success_serviceInstance() throws Exception{ - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - String processId = invokeSubProcess( "GenericGetService", variables); - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - - @Test - - public void testGenericGetService_success_serviceSubscription() throws Exception{ - - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstance_byName() throws Exception{ - - MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstance_byId() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_genericQueryResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ - - MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceSubscription404() throws Exception{ - MockGetServiceSubscription("SDN-ETHERNET-INTERNET", "1604-MVM-26", 404); - - Map<String, Object> variables = new HashMap<>(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ - - MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstanceById404() throws Exception{ - - MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_genericQueryResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ - - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ - MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_genericQueryResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - - @Test - - public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ - - Map<String, Object> variables = new HashMap<>(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.,workStep=*]"; - - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - - public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ - - MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - - public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_genericQueryResponseCode",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - - public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String obtainUrl = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainObjectsUrl",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstance_byNameServicePresent() throws Exception{ - - MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml"); - MockGetServiceInstance("AbcBank", "ABC-ST", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, null, "1604-MVM-26", "XyCorporation", null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String resourceLink = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_resourceLink",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertNotNull(resourceLink); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - - public void testGenericGetService_success_serviceInstance_byNameServiceNotPresent() throws Exception{ - - MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml"); - MockGetServiceInstance("CorporationNotPresent", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariablesInstance(variables, null, "1604-MVM-26", "CorporationNotPresent", null); - - String processId = invokeSubProcess( "GenericGetService", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_FoundIndicator",processId); - String resourceLink = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_resourceLink",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetService", "WorkflowException",processId); - String siUrlResponseCode = BPMNUtil.getVariable(processEngine, "GenericGetService", "GENGS_obtainSIUrlResponseCode",processId); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals(null, resourceLink); - assertEquals(" ", response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - private void setVariablesInstance(Map<String, Object> variables, String siId, String siName, String globalCustId, String serviceType) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGS_serviceInstanceId", siId); - variables.put("GENGS_serviceInstanceName", siName); - variables.put("GENGS_globalCustomerId",globalCustId); - variables.put("GENGS_serviceType", serviceType); - variables.put("GENGS_type", "service-instance"); - variables.put("mso-request-id", UUID.randomUUID().toString()); - } - - private void setVariablesSubscription(Map<String, Object> variables, String siId, String siName, String globalCustId, String serviceType) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGS_serviceInstanceId", siId); - variables.put("GENGS_serviceInstanceName", siName); - variables.put("GENGS_globalCustomerId",globalCustId); - variables.put("GENGS_serviceType", serviceType); - variables.put("GENGS_type", "service-subscription"); - variables.put("mso-request-id", UUID.randomUUID().toString()); - } - - -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java index 7c4c8201ea..b514c38d47 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java @@ -30,25 +30,23 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import java.util.HashMap; import java.util.List; import java.util.Map; - import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.history.HistoricVariableInstance; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.test.Deployment; import org.camunda.bpm.engine.test.ProcessEngineRule; import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl; +import org.onap.so.bpmn.infrastructure.pnf.delegate.DmaapClientTestImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @ContextConfiguration(locations = "/applicationContext_forPnfTesting.xml") -@Ignore public class CreateAndActivatePnfResourceTest { private static final String TIMEOUT_10_S = "PT10S"; @@ -62,6 +60,9 @@ public class CreateAndActivatePnfResourceTest { @Autowired private AaiConnectionTestImpl aaiConnection; + @Autowired + private DmaapClientTestImpl dmaapClientTestImpl; + @Test @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) public void shouldSaveCurrentIpToVariableIfItAlreadyExistsInAai() throws Exception { @@ -97,9 +98,8 @@ public class CreateAndActivatePnfResourceTest { ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); - runtimeService.createMessageCorrelation("WorkflowMessage") - .processInstanceBusinessKey("businessKey") - .correlateWithResult(); + dmaapClientTestImpl.sendMessage(); + // then assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", @@ -126,9 +126,8 @@ public class CreateAndActivatePnfResourceTest { ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); - runtimeService.createMessageCorrelation("WorkflowMessage") - .processInstanceBusinessKey("businessKey") - .correlateWithResult(); + dmaapClientTestImpl.sendMessage(); + // then assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml new file mode 100644 index 0000000000..72462bd092 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/applicationContext_forPnfTesting.xml @@ -0,0 +1,70 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-2.5.xsd" > + + <bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> + <property name="targetDataSource"> + <bean class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> + <property name="driverClass" value="org.h2.Driver" /> + <property name="url" + value="jdbc:h2:mem:process-engine;DB_CLOSE_DELAY=1000" /> + <property name="username" value="sa" /> + <property name="password" value="" /> + </bean> + </property> + </bean> + + <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource" ref="dataSource" /> + </bean> + + <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration"> + <property name="processEngineName" value="engine" /> + <property name="dataSource" ref="dataSource" /> + <property name="transactionManager" ref="transactionManager" /> + <property name="databaseSchemaUpdate" value="true" /> + <property name="jobExecutorActivate" value="false" /> + <!--<property name="deploymentResources" value="classpath*:*.bpmn" />--> + </bean> + + <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean"> + <property name="processEngineConfiguration" ref="processEngineConfiguration" /> + </bean> + + <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /> + <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /> + <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /> + <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /> + <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /> + + <context:annotation-config /> + + <bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule"> + <property name="processEngine" ref="processEngine" /> + </bean> + + <bean id="aaiConnection" class="org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl"/> + + <bean id="checkAaiForCorrelationIdDelegate" class="org.onap.so.bpmn.infrastructure.pnf.delegate.CheckAaiForCorrelationIdDelegate"> + <property name="aaiConnection" ref="aaiConnection"/> + </bean> + + <bean id="createAaiEntryWithPnfIdDelegate" class="org.onap.so.bpmn.infrastructure.pnf.delegate.CreateAaiEntryWithPnfIdDelegate"> + <property name="aaiConnection" ref="aaiConnection"/> + </bean> + + <bean id="informDmaapClient" class="org.onap.so.bpmn.infrastructure.pnf.delegate.InformDmaapClient"> + <property name="dmaapClient" ref="dmaapClient"/> + </bean> + + <bean id="dmaapClient" class="org.onap.so.bpmn.infrastructure.pnf.delegate.DmaapClientTestImpl"/> + + + <bean id="pnfCheckInputs" class="org.onap.so.bpmn.infrastructure.pnf.delegate.PnfCheckInputs"> + <property name="defaultTimeout" value="PT1S"/> + </bean> +</beans> |