From b1e5734ef566af5d49ba17d05ca0ab7b56d6666d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 9 May 2017 03:55:30 -0700 Subject: [MSO-8] Additional fixes for the second rebase DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) --- .../mso/bpmn/common/scripts/AaiUtil.groovy | 198 +++- .../scripts/AbstractServiceTaskProcessor.groovy | 30 + .../common/scripts/AllottedResourceUtils.groovy | 312 ++++++ .../bpmn/common/scripts/CreateAAIVfModule.groovy | 27 +- .../common/scripts/CreateGenericVNFUtils.groovy | 164 ---- .../common/scripts/GenerateVfModuleName.groovy | 6 +- .../bpmn/common/scripts/GenericDeleteVnf.groovy | 1 - .../bpmn/common/scripts/GenericGetService.groovy | 111 ++- .../mso/bpmn/common/scripts/GenericGetVnf.groovy | 2 +- .../bpmn/common/scripts/GenericPutService.groovy | 6 +- .../mso/bpmn/common/scripts/GenericUtils.groovy | 20 + .../bpmn/common/scripts/SDNCAdapterUtils.groovy | 2 +- .../bpmn/common/scripts/UpdateAAIGenericVnf.groovy | 31 +- .../bpmn/common/scripts/UpdateAAIVfModule.groovy | 8 +- .../mso/bpmn/common/scripts/VfModuleBase.groovy | 246 ++--- .../workflow/service/AbstractCallbackService.java | 352 +++++++ .../service/SDNCAdapterCallbackServiceImpl.java | 235 +---- .../service/VnfAdapterNotifyServiceImpl.java | 763 +++++---------- .../workflow/service/WorkflowMessageResource.java | 103 +- .../resources/subprocess/GenericGetService.bpmn | 210 ++-- .../mso/bpmn/common/scripts/AaiUtilTest.groovy | 690 +++++++------ .../common/CreateAAIVfModuleVolumeGroupTest.java | 272 +++--- .../mso/bpmn/common/GenericGetServiceTest.java | 1010 ++++++++++---------- .../bpmn/common/PrepareUpdateAAIVfModuleTest.java | 8 +- .../mso/bpmn/common/SDNCAdapterV1Test.java | 22 +- .../mso/bpmn/common/UpdateAAIGenericVnfTest.java | 6 +- .../mso/bpmn/common/UpdateAAIVfModuleTest.java | 6 +- .../openecomp/mso/bpmn/common/WorkflowTest.java | 320 +++++-- .../Archive/drop_mariadb_engine_7.5.6.sql | 149 ++- .../Archive/mariadb_engine_7.5_patch_7.5.6.sql | 443 +++++---- .../VfModularity/UpdateAAIVfModuleRequest.xml | 18 +- .../__files/VfModularity/VfModule-supercool.xml | 4 +- .../src/test/resources/mso.bpmn.urn.properties | 11 +- 33 files changed, 3058 insertions(+), 2728 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy delete mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy index 95a577c946..b50bf68207 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy @@ -27,17 +27,19 @@ import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig class AaiUtil { - + public MsoUtils utils = new MsoUtils() - public static final String AAI_NAMESPACE_STRING = 'http://org.openecomp.aai.inventory/' + public static final String AAI_NAMESPACE_STRING_KEY = 'URN_mso_workflow_global_default_aai_namespace' public static final String DEFAULT_VERSION_KEY = 'URN_mso_workflow_global_default_aai_version' - + + private String aaiNamespace = null; + private AbstractServiceTaskProcessor taskProcessor public AaiUtil(AbstractServiceTaskProcessor taskProcessor) { this.taskProcessor = taskProcessor } - + public String getNetworkGenericVnfEndpoint(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") @@ -52,7 +54,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getNetworkVpnBindingUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vpn_binding') @@ -73,7 +75,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getNetworkVceUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vce') @@ -110,7 +112,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) return endpoint + uri } - + public String getCloudInfrastructureCloudRegionUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'cloud_region') @@ -131,7 +133,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - + public String getSearchNodesQueryEndpoint(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") @@ -139,7 +141,7 @@ class AaiUtil { taskProcessor.logDebug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled) return endpoint + uri } - + public String getSearchGenericQueryUri(Execution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'generic_query') @@ -151,37 +153,39 @@ class AaiUtil { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') resourceName = resourceName.replaceAll('-', '_') - + def versionWithResourceKey = "URN_mso_workflow_default_aai_${resourceName}_version" def versionWithProcessKey = "URN_mso_workflow_custom_${processKey}_aai_version" def version = execution.getVariable(versionWithProcessKey) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}", isDebugLogEnabled) - return version + return version } - + version = execution.getVariable(versionWithResourceKey) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}", isDebugLogEnabled) return version } - + version = execution.getVariable(DEFAULT_VERSION_KEY) if (version) { taskProcessor.logDebug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}", isDebugLogEnabled) return version } - + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") } - + public String getUri(Execution execution, resourceName) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def processKey = taskProcessor.getMainProcessKey(execution) - resourceName = resourceName.replaceAll('-', '_') + + //set namespace + setNamespace(execution) // Check for flow+resource specific first def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri" @@ -190,7 +194,7 @@ class AaiUtil { taskProcessor.logDebug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}", isDebugLogEnabled) return uri } - + // Check for versioned key def version = getVersion(execution, resourceName, processKey) key = "URN_mso_workflow_default_aai_v${version}_${resourceName}_uri" @@ -204,17 +208,80 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') } + public String setNamespace(Execution execution) { + def key = AAI_NAMESPACE_STRING_KEY + aaiNamespace = execution.getVariable(key) + if (aaiNamespace == null ) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') + } + } + + /** + * This method can be used for getting the building namespace out of uri. + * NOTE: A getUri() method needs to be invoked first. + * Alternative method is the getNamespaceFromUri(Execution execution, String uri) + * return namespace (plus version from uri) + * + * @param url + * + * @return namespace + */ + public String getNamespaceFromUri(String uri) { - String namespace = AAI_NAMESPACE_STRING + if (aaiNamespace == null) { + throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') + } + String namespace = aaiNamespace if(uri!=null){ - return namespace + uri.substring(uri.indexOf("v"), uri.indexOf("v")+2) + String version = getVersionFromUri(uri) + return namespace + "v"+version }else{ return namespace } } - + /** + * This method can be used for building namespace with aai version out of uri. + * NOTE: 2 arguments: Execution execution & String uri + * @param execution + * @param url + * + * @return namespace + */ + public String getNamespaceFromUri(Execution execution, String uri) { + String namespace = execution.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null ) { + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file') + } + if(uri!=null){ + String version = getVersionFromUri(uri) + return namespace + "v"+version + }else{ + return namespace + } + } + + /** + * This is used to extract the version from uri. + * + * @param uri + * + * @return version + */ + private String getVersionFromUri(String uri) { + def version = "" + def savedVersion = "" + for (int x=2; x<6; x++) { + version = uri.substring(uri.indexOf("v")+1, uri.indexOf("v")+x) + if (!Character.isDigit(version.charAt(version.size()-1))) { + break + } + savedVersion = version + } + return savedVersion + } + /** * This reusable method can be used for making AAI Get Calls. The url should * be passed as a parameter along with the execution. The method will @@ -232,16 +299,16 @@ class AaiUtil { String uuid = UUID.randomUUID() taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) - + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); - + if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - + APIResponse apiResponse = client.get() return apiResponse @@ -252,6 +319,7 @@ class AaiUtil { taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled) } + /** * This reusable method can be used for making AAI httpPut Calls. The url should * be passed as a parameter along with the execution and payload. The method will @@ -287,7 +355,7 @@ class AaiUtil { } taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled) } - + /** * This reusable method can be used for making AAI httpPatch Calls. The url should * be passed as a parameter along with the execution and payload. The method will @@ -345,7 +413,7 @@ class AaiUtil { taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - + RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); if (basicAuthCred != null && !"".equals(basicAuthCred)) { @@ -379,8 +447,9 @@ class AaiUtil { try{ String uuid = UUID.randomUUID() taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled) + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) - + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader); @@ -398,11 +467,11 @@ class AaiUtil { } taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) } - + /** - * This reusable method can be used for making AAI Post Calls. The url should - * be passed as a parameter along with the execution. The method will - * return an APIResponse. + * This reusable method can be used for making AAI Post Calls. The url + * and payload should be passed as a parameters along with the execution. + * The method will return an APIResponse. * * @param execution * @param url @@ -421,6 +490,7 @@ class AaiUtil { String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml"); + if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } @@ -435,7 +505,49 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) } - /** Utilitty to get the Cloud Region from AAI + /** + * This reusable method can be used for making AAI Post Calls. The url + * and payload should be passed as a parameters along with the execution. + * The method will return an APIResponse. + * + * @param execution + * @param url + * @param payload + * @param authenticationHeader - addAuthenticationHeader value + * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue) + * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue) + * + * @return APIResponse + */ + public APIResponse executeAAIPostCall(Execution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled) + try{ + taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled) + + String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) + + RESTConfig config = new RESTConfig(url); + RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue) + if (basicAuthCred != null && !"".equals(basicAuthCred)) { + client.addAuthorizationHeader(basicAuthCred) + } + APIResponse apiResponse = client.httpPost(payload) + + return apiResponse + + }catch(Exception e){ + taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled) + return e + } + taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) + } + + + + + + /* Utility to get the Cloud Region from AAI * Returns String cloud region id, (ie, cloud-region-id) * @param execution * @param url - url for AAI get cloud region @@ -479,7 +591,7 @@ class AaiUtil { return "ERROR" } } else { // not 200 - if (returnCode == "404") { + if (returnCode == "404") { if (backend == "PO") { regionId = inputCloudRegion } else { // backend not "PO" @@ -487,10 +599,10 @@ class AaiUtil { } taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled) return regionId - } else { - taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled) - return "ERROR" - } + } else { + taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled) + return "ERROR" + } } }catch(Exception e) { taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled) @@ -511,19 +623,18 @@ class AaiUtil { return ret } - /** - * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for + * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for * determining module type is specified by "key" parameter (for example, "persona-model-id"), * the value for filtering is specified in "value" parameter - * + * * @param execution * @param aaiVnfResponse * @param key * @param value * * @return moduleIndex - * + * */ public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -531,7 +642,7 @@ class AaiUtil { String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules") if (vfModulesText == null || vfModulesText.isEmpty()) { taskProcessor.utils.log("DEBUG", "There are no VF modules in this VNF yet", isDebugEnabled) - return 0 + return 0 } else { def xmlVfModules= new XmlSlurper().parseText(vfModulesText) @@ -548,15 +659,14 @@ class AaiUtil { matchingVfModules = matchingVfModules + taskProcessor.utils.removeXmlPreamble(vfModuleXml) } } - matchingVfModules = matchingVfModules + "" + matchingVfModules = matchingVfModules + "" taskProcessor.utils.log("DEBUG", "Matching VF Modules: " + matchingVfModules, isDebugEnabled) String lowestUnusedIndex = taskProcessor.utils.getLowestUnusedIndex(matchingVfModules) return Integer.parseInt(lowestUnusedIndex) - } + } } else { return 0 } } - } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index d7aa97906c..e86f77c890 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -697,6 +697,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess /** * Constructs a workflow message callback URL for the specified message type and correlator. + * This type of callback URL is used when a workflow wants an MSO adapter (like the SDNC + * adapter) to call it back. In other words, this is for callbacks internal to the MSO + * complex. Use createWorkflowMessageAdapterCallbackURL if the callback + * will come from outside the MSO complex. * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse) * @param correlator the correlator value (e.g. a request ID) */ @@ -717,4 +721,30 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') } + + /** + * + * Constructs a workflow message callback URL for the specified message type and correlator. + * This type of callback URL is used when a workflow wants a system outside the MSO complex + * to call it back through the Workflow Message Adapter. + * @param messageType the message type (e.g. SNIROResponse) + * @param correlator the correlator value (e.g. a request ID) + */ + public String createWorkflowMessageAdapterCallbackURL(Execution execution, String messageType, String correlator) { + String endpoint = (String) execution.getVariable('URN_mso_adapters_workflow_message_endpoint') + + if (endpoint == null || endpoint.isEmpty()) { + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, + 'mso:adapters:workflow:message:endpoint URN mapping is not set') + } + + while (endpoint.endsWith('/')) { + endpoint = endpoint.substring(0, endpoint.length()-1) + } + + return endpoint + + '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') + } } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy new file mode 100644 index 0000000000..540fe036fc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -0,0 +1,312 @@ +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.StringEscapeUtils; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.rest.APIResponse; + +class AllottedResourceUtils { + + private AbstractServiceTaskProcessor taskProcessor + ExceptionUtil exceptionUtil = new ExceptionUtil() + MsoUtils utils; + + public AllottedResourceUtils(AbstractServiceTaskProcessor taskProcessor) { + this.taskProcessor = taskProcessor + this.utils = taskProcessor.utils + } + + /*Used on Create - called from DoCreate + * Using Consuming ServiceInstanceId get related Allotted Resources Orchestration status from AAI + * 1) get related AR links for CSI 2) get AR from AR links + * return: null -> AR Not found + * return: " " -> AR found with empty orchStatus + * return: orchStatus - > AR found with this orchStatus + * setsVariable aaiARGetResponse + */ + public String getAROrchStatus (Execution execution) { + + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** getAROrchStatus *****", isDebugEnabled) + String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String arType = execution.getVariable("allottedResourceType") + String arRole = execution.getVariable("allottedResourceRole") + String siXml = execution.getVariable("CSI_service") + String ar = null + String orchStatus = null + XmlParser xmlParser = new XmlParser() + utils.log("DEBUG","getAROrchStatus siXml:" + siXml, isDebugEnabled) + try { + if (!isBlank(siXml)) { + def groovy.util.Node siNode = xmlParser.parseText(siXml) + def groovy.util.Node relationshipList = utils.getChildNode(siNode, 'relationship-list') + if (relationshipList != null) { + def groovy.util.NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship') + for (groovy.util.Node relationship in relationships) { + def groovy.util.Node relatedTo = utils.getChildNode(relationship, 'related-to') + if ((relatedTo != null) && (relatedTo.text().equals('allotted-resource'))) { + utils.log("DEBUG","getARORchStatus AR found", isDebugEnabled) + def groovy.util.Node relatedLink = utils.getChildNode(relationship, 'related-link') + if (relatedLink != null){ + ar = getARbyLink(execution, relatedLink.text(), arRole) + if (!isBlank(ar)) + { + orchStatus = execution.getVariable("aaiAROrchStatus") + break + } + } + } + } + } + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered in getAROrchStatus" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in getAROrchStatus" + e.getMessage()) + } + utils.log("DEBUG"," *****Exit getAROrchStatus **** OrchStatus:" + orchStatus, isDebugEnabled) + return orchStatus + } + + // get Allotted Resource by AllottedResourceId + // used on Delete - called from doDeleteAR + // setsVariable aaiARGetResponse + public String getARbyId (Execution execution, String allottedResourceId) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARbyId ***** ", isDebugEnabled) + String arLink = getARLinkbyId(execution, allottedResourceId) + String ar = null + if (!isBlank(arLink)) + { + ar = getARbyLink(execution, arLink, "") + } + utils.log("DEBUG", " ***** Exit GetARbyId ***** AR:" + ar, isDebugEnabled) + return ar; + } + + // get Allotted Resource Link by AllottedResourceId using Nodes Query + // used on Delete - called from getARbyId + public String getARLinkbyId (Execution execution, String allottedResourceId) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARLinkbyId ***** ", isDebugEnabled) + String arLink = null + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + String aaiNQUri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) + String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + String aaiUrl = "${aaiNQUri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" + + utils.log("DEBUG", "getARLinkbyId url: \n" + aaiUrl, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, aaiUrl) + int responseCode = response.getStatusCode() + utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled) + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled) + if(utils.nodeExists(aaiResponse, "result-data")){ + utils.log("DEBUG", "Query for AllottedResource Url Response Does Contain Data" , isDebugEnabled) + arLink = utils.getNodeText1(aaiResponse, "resource-link") + }else{ + utils.log("DEBUG", "GET AR Response Does NOT Contain Data" , isDebugEnabled) + } + }else if(responseCode == 404){ + utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled) + } + else{ + utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage()) + } + utils.log("DEBUG", " ***** Exit GetARLinkbyId ***** Link:" + arLink, isDebugEnabled) + return arLink + } + + // get Allotted resource using Link + // used on Create called from getARORchStatus + // used on Delete called from getARbyId + // setsVariable aaiARPath - used for Patch in create + public String getARbyLink (Execution execution, String link, String role) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** getARbyLink ***** ", isDebugEnabled) + String ar = null + String arUrl = null + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + String aai_endpoint = execution.getVariable("URN_aai_endpoint") + String arEndpoint = "" + + if(!isBlank(link)) { + utils.log("DEBUG", "Incoming AR Resource Link is: " + link, isDebugEnabled) + String[] split = link.split("/aai/") + arEndpoint = "/aai/" + split[1] + } + + arUrl = "${aai_endpoint}" + arEndpoint + + utils.log("DEBUG", "GET AR Aai Path is: \n" + arUrl, isDebugEnabled) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl) + int responseCode = response.getStatusCode() + utils.log("DEBUG", " GET AR response code is: " + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + utils.log("DEBUG", "GET AR:" + aaiResponse, isDebugEnabled) + if(responseCode == 200 || responseCode == 202){ + utils.log("DEBUG", "GET AR Received a Good Response Code", isDebugEnabled) + if(utils.nodeExists(aaiResponse, "allotted-resource")){ + if (!isBlank(role)) + { + if (utils.nodeExists(aaiResponse, "role") && role.equals(utils.getNodeText1(aaiResponse, "role"))) { + ar = aaiResponse + }else{ + utils.log("DEBUG", "AAI AR does not match input role:" + role, isDebugEnabled) + } + } + else + { + ar = aaiResponse + } + } + else + { + utils.log("DEBUG", "GET AR Does NOT Contain Data" , isDebugEnabled) + } + }else if(responseCode == 404){ + utils.log("DEBUG", "GET AR received a Not Found (404) Response", isDebugEnabled) + } + else{ + utils.log("DEBUG", " GET AR received a Bad Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") + } + }catch(Exception e){ + utils.log("DEBUG", " Error encountered within GetAaiAR" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetAaiAR" + e.getMessage()) + } + if (!isBlank(ar)) + { + execution.setVariable("aaiARGetResponse", ar) + execution.setVariable("aaiARPath", arUrl) + + String resourceVersion = null + if (utils.nodeExists(ar, "resource-version")) { + resourceVersion = utils.getNodeText1(ar, "resource-version") + execution.setVariable("aaiARResourceVersion", resourceVersion) + } + + String orchStatus = null + if (utils.nodeExists(ar, "orchestration-status")) { + orchStatus= utils.getNodeText1(ar, "orchestration-status") + } + else + { + orchStatus = " " + } + execution.setVariable("aaiAROrchStatus", orchStatus) + } + utils.log("DEBUG", " ***** Exit GetARbyLink ***** AR:" + ar, isDebugEnabled) + return ar + } + + public void updateAROrchStatus(Execution execution, String status, String aaiARPath){ + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** updaAROrchStatus *** ", isDebugEnabled) + try{ + + String updateReq = """ + { + "orchestration-status": "Created"" + } + """ + + utils.log("DEBUG", 'AAI AR URI: ' + aaiARPath, isDebugEnabled) + + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + APIResponse apiResponse = aaiUriUtil.executeAAIPatchCall(execution, aaiARPath, updateReq) + def aaiResponse = StringEscapeUtils.unescapeXml(apiResponse.getResponseBodyAsString()) + def responseCode = apiResponse.getStatusCode() + + utils.logAudit("AAI Response Code: " + responseCode) + utils.logAudit("AAI Response: " + aaiResponse) + if(responseCode == 200){ + utils.log("DEBUG", "UpdateAR Good REST Response is: " + "\n" + aaiResponse, isDebugEnabled) + }else{ + utils.log("DEBUG", "UpdateAROrchStatus Bad REST Response!", isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error updating AR OrchStatus in AAI") + } + + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException ", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("ERROR", "Exception in updateAR. Exception is:\n" + e.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage()) + } + utils.log("DEBUG", " *** Exit updateAROrchStatus *** ", isDebugEnabled) + } + + //Sets Variable "wasDeleted" + public void deleteAR(Execution execution, String aaiARPath){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** deleteAR *** aaiARPath:" + aaiARPath, isDebugEnabled) + try { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath) + int responseCode = response.getStatusCode() + execution.setVariable("deleteARResponseCode", responseCode) + + utils.log("DEBUG", " Delete AR response code:" + responseCode, isDebugEnabled) + + String aaiResponse = response.getResponseBodyAsString() + aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + execution.setVariable("aaiARDeleteResponse", aaiResponse) + + utils.log("DEBUG", "Delete AR Response:" + aaiResponse) + //Process Response + if(responseCode == 204){ + utils.log("DEBUG", " Delete AR Received a Good Response", isDebugEnabled) + execution.setVariable("wasDeleted", "true") + }else if(responseCode == 404){ + utils.log("DEBUG", " Delete AR Received a Not Found (404) Response", isDebugEnabled) + }else if(responseCode == 412){ + utils.log("DEBUG", "Delete AR Received a Resource Version Mismatch Error: \n" + aaiResponse, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 412, "DeleteAR Received a resource-version Mismatch Error Response from AAI") + }else{ + utils.log("DEBUG", "Delete AR Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + buildAAIErrorResponse(execution, aaiResponse, "Error deleting AR in AAI") + exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) + } + }catch(BpmnError b){ + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) + throw b + }catch(Exception e){ + utils.log("DEBUG", " Error encountered in deleteAR!" + e, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Delete AR") + } + utils.log("DEBUG", " *** Exit deleteAR *** ", isDebugEnabled) + } + + public void buildAAIErrorResponse(Execution execution, String response, String errorMessage){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** BuildAAIErrorResponse*** ", isDebugEnabled) + + if((response != null) && (response.contains("Fault") || response.contains("RESTFault"))){ + WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(response, execution) + execution.setVariable("WorkflowException", workflowException) + }else{ + exceptionUtil.buildWorkflowException(execution, 500, errorMessage) + } + + utils.log("DEBUG", " *** Exit BuildAAIErrorResponse Process*** ", isDebugEnabled) + throw new BpmnError("MSOWorkflowException") + } + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy index 986111ccda..9cf22aaf4a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -159,7 +159,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + aaiNamespace, isDebugEnabled) execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") @@ -258,8 +258,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ ${execution.getVariable("CAAIVfMod_vnfType")} ${execution.getVariable("CAAIVfMod_serviceId")} active - ${execution.getVariable("CAAIVfMod_vnfPersonaId")} - ${execution.getVariable("CAAIVfMod_vnfPersonaVer")} + ${execution.getVariable("CAAIVfMod_vnfPersonaId")} + ${execution.getVariable("CAAIVfMod_vnfPersonaVer")} """ as String execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) @@ -305,8 +305,19 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") AaiUtil aaiUtil = new AaiUtil(this) def personaModelId = execution.getVariable("CAAIVfMod_personaId") + + // Check if the response includes model-invariant-id or persona-model-id + // note: getRequiredNodeText() throws an exception if the field is missing + // need to retun a null for the subsequent "either/or" logic to work properly +// def modelInvariantId = getRequiredNodeText(execution, aaiVnfResponse,'model-invariant-id') + def modelInvariantId = getNodeText(aaiVnfResponse,'model-invariant-id', null) + def fieldToCheck = 'model-invariant-id' + if (!modelInvariantId) { + fieldToCheck = 'persona-model-id' + } + moduleIndex = aaiUtil.getLowestUnusedVfModuleIndexFromAAIVnfResponse(execution, aaiVnfResponse, - "persona-model-id", personaModelId) + fieldToCheck, personaModelId) } def moduleIndexString = String.valueOf(moduleIndex) @@ -324,11 +335,11 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ String payload = """ ${newModuleId} ${execution.getVariable("CAAIVfMod_moduleName")} - ${execution.getVariable("CAAIVfMod_personaId")} - ${execution.getVariable("CAAIVfMod_personaVer")} - ${execution.getVariable("CAAIVfMod_modelCustomizationId")} + ${execution.getVariable("CAAIVfMod_personaId")} + ${execution.getVariable("CAAIVfMod_personaVer")} + ${execution.getVariable("CAAIVfMod_modelCustomizationId")} ${isBaseModule} - pending-create + PendingCreate ${moduleIndex} """ as String execution.setVariable("CAAIVfMod_createVfModulePayload", payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy deleted file mode 100644 index 887eb7456d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateGenericVNFUtils.groovy +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.common.scripts - -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - -import org.camunda.bpm.engine.runtime.Execution; -import org.camunda.bpm.engine.delegate.BpmnError - -/** - * Please describe the CreateGenericVNFUtils.groovy class - * - */ -class CreateGenericVNFUtils{ - - String Prefix="CRTGVNF_" - - def utils=new MsoUtils() - - private AbstractServiceTaskProcessor taskProcessor - - public CreateGenericVNFUtils(AbstractServiceTaskProcessor taskProcessor) { - this.taskProcessor = taskProcessor - } - - /** - * This method is executed during the Initialization task of the process. - * - * @param execution - * - */ - - public APIResponse queryAAI(Execution execution, String path){ - - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED queryAAI Process ======== ", isDebugEnabled) - - def uuid = execution.getVariable("CRTGVNF_uuid") - utils.log("DEBUG", "UUID is: " + uuid, isDebugEnabled) - - //Setting request path - String queryAAIRequestPath = execution.getVariable("URN_aai_endpoint")+path -// execution.setVariable("CRTGVNF_queryAAIRequestPath", queryAAIRequestPath) - utils.log("DEBUG", "QueryAAIRequest Path is: " + "\n" + queryAAIRequestPath, isDebugEnabled) - - try { - AaiUtil aaiUtil = new AaiUtil(taskProcessor) - return aaiUtil.executeAAIGetCall(execution, queryAAIRequestPath) - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing queryAAI. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CRTGVNF_dataValidationFlag", false) - execution.setVariable("CRTGVNF_ErrorResponse", "Error Occured during queryAAI Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED queryAAI Process ======== ", isDebugEnabled) -} - - public String buildSDNCRequest(Execution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("CRTGVNF_sdncCallbackUrl") - def requestId = execution.getVariable("CRTGVNF_requestId") - def serviceType = execution.getVariable("CRTGVNF_serviceType") - def vnfType = execution.getVariable("CRTGVNF_vnfType") - def vnfName = execution.getVariable("CRTGVNF_vnfName") - def tenantId = execution.getVariable("CRTGVNF_tenantId") - def source = execution.getVariable("CRTGVNF_source") - String vnfId = svcInstId - String sdncVNFParamsXml = "" - - if(execution.getVariable("CRTGVNF_vnfParamsExistFlag") == true){ - sdncVNFParamsXml = buildSDNCParamsXml(execution) - }else{ - sdncVNFParamsXml = "" - } - - String sdncRequest = - """ - - ${uuid} - ${svcInstId} - ${action} - vnf-topology-operation - ${callbackURL} - - - - ${requestId} - VNFActivateRequest - ${source} - - - ${serviceType} - ${vnfId} - notsurewecare - - - ${vnfId} - ${vnfType} - ${vnfName} - ${tenantId} -${sdncVNFParamsXml} - - - """ - - return sdncRequest - - } - - public String buildSDNCParamsXml(Execution execution){ - - String params = "" - StringBuilder sb = new StringBuilder() - Map paramsMap = execution.getVariable("CRTGVNF_vnfParamsMap") - - for (Map.Entry entry : paramsMap.entrySet()) { - String paramsXml - String key = entry.getKey(); - if(key.endsWith("_network")){ - String requestKey = key.substring(0, key.indexOf("_network")) - String requestValue = entry.getValue() - paramsXml = -""" - { functx:substring-before-match(data($param/@name), '_network') } - { $param/text() } -""" - }else{ - paramsXml = "" - } - params = sb.append(paramsXml) - } - return params - } - -} - - - - - diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy index fba5cbe1b0..53678ec749 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -120,7 +120,11 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ String matchingVfModules = "" for (i in 0..vfModulesSize-1) { def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "model-invariant-id") + if (!personaModelIdFromAAI) { + // check old attribute name + personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id") + } if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) { matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy index 1bd4383b74..344bba29bd 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy @@ -67,7 +67,6 @@ import org.springframework.web.util.UriUtils * * * Out Mapping Variables: - * @param - GENDV_vnf * @param - GENDV_SuccessIndicator * @param - GENDV_FoundIndicator * @param - WorkflowException diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy index 70ce1ba5cf..2e65339270 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy @@ -64,6 +64,13 @@ import org.springframework.web.util.UriUtils * Variable Mapping Below: * * In Mapping Variables: + * For Allotted-Resource: + * @param - GENGS_allottedResourceId + * @param - GENGS_type + * @param (Optional) - GENGS_serviceInstanceId + * @param (Optional) - GENGS_serviceType + * @param (Optional) - GENGS_globalCustomerId + * * For Service-Instance: * @param - GENGS_serviceInstanceId or @param - GENGS_serviceInstanceName * @param - GENGS_type @@ -82,6 +89,7 @@ import org.springframework.web.util.UriUtils * @param - WorkflowException * * + * @author cb645j */ class GenericGetService extends AbstractServiceTaskProcessor{ @@ -94,20 +102,24 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * variables the calling flow provided. * * @param - execution + * + * @author cb645j */ public void preProcessRequest(Execution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled) - execution.setVariable("GENGS_obtainServiceInstanceUrl", false) + execution.setVariable("GENGS_obtainObjectsUrl", false) execution.setVariable("GENGS_obtainServiceInstanceUrlByName", false) execution.setVariable("GENGS_SuccessIndicator", false) execution.setVariable("GENGS_FoundIndicator", false) + execution.setVariable("GENGS_resourceLink", null) execution.setVariable("GENGS_siResourceLink", null) try{ // Get Variables + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName") String serviceType = execution.getVariable("GENGS_serviceType") @@ -116,7 +128,21 @@ class GenericGetService extends AbstractServiceTaskProcessor{ if(type != null){ utils.log("DEBUG", "Incoming GENGS_type is: " + type, isDebugEnabled) - if(type.equalsIgnoreCase("service-instance")){ + if(type.equalsIgnoreCase("allotted-resource")){ + if(isBlank(allottedResourceId)){ + utils.log("DEBUG", "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.") + }else{ + utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled) + if(isBlank(globalCustomerId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ + execution.setVariable("GENGS_obtainObjectsUrl", true) + }else{ + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled) + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + } + } + }else if(type.equalsIgnoreCase("service-instance")){ if(isBlank(serviceInstanceId) && isBlank(serviceInstanceName)){ utils.log("DEBUG", "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.", isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.") @@ -124,7 +150,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled) if(isBlank(globalCustomerId) || isBlank(serviceType)){ - execution.setVariable("GENGS_obtainServiceInstanceUrl", true) + execution.setVariable("GENGS_obtainObjectsUrl", true) if(isBlank(serviceInstanceId)){ execution.setVariable("GENGS_obtainServiceInstanceUrlByName", true) } @@ -170,49 +196,64 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) try { - String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") - utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled) - AaiUtil aaiUriUtil = new AaiUtil(this) String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) String aai_endpoint = execution.getVariable("URN_aai_endpoint") - - utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint) - String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}" + + String type = execution.getVariable("GENGS_type") + String path = "" + if(type.equalsIgnoreCase("service-instance")){ + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled) + path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}" + utils.logAudit("Service Instance Node Query Url is: " + path) + utils.log("DEBUG", "Service Instance Node Query Url is: " + path, isDebugEnabled) + }else if(type.equalsIgnoreCase("allotted-resource")){ + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") + utils.log("DEBUG", " Querying Node for Service-Instance URL by using Allotted Resource Id: " + allottedResourceId, isDebugEnabled) + path = "${aai_uri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" + utils.logAudit("Allotted Resource Node Query Url is: " + path) + utils.log("DEBUG", "Allotted Resource Node Query Url is: " + path, isDebugEnabled) + } //String url = "${aai_endpoint}${path}" host name needs to be removed from property String url = "${path}" - execution.setVariable("GENGS_obtainSIUrlPath", url) + execution.setVariable("GENGS_genericQueryPath", url) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url) int responseCode = response.getStatusCode() - execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) + execution.setVariable("GENGS_genericQueryResponseCode", responseCode) utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI GET Response Code: " + responseCode) String aaiResponse = response.getResponseBodyAsString() + execution.setVariable("GENGS_obtainSIUrlResponseBeforeUnescaping", aaiResponse) + utils.log("DEBUG", "GenericGetService AAI Response before unescaping: " + aaiResponse, isDebugEnabled) aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) - execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) + execution.setVariable("GENGS_genericQueryResponse", aaiResponse) utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + utils.log("DEBUG", "GenericGetService AAI Response: " + aaiResponse, isDebugEnabled) + //Process Response if(responseCode == 200){ - utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a Good Response Code", isDebugEnabled) execution.setVariable("GENGS_SuccessIndicator", true) if(utils.nodeExists(aaiResponse, "result-data")){ - utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) + utils.log("DEBUG", "Generic Query Response Does Contain Data" , isDebugEnabled) execution.setVariable("GENGS_FoundIndicator", true) String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_resourceLink", resourceLink) execution.setVariable("GENGS_siResourceLink", resourceLink) }else{ - utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) + utils.log("DEBUG", "Generic Query Response Does NOT Contains Data" , isDebugEnabled) execution.setVariable("WorkflowResponse", " ") //for junits } }else if(responseCode == 404){ - utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a Not Found (404) Response", isDebugEnabled) execution.setVariable("GENGS_SuccessIndicator", true) execution.setVariable("WorkflowResponse", " ") //for junits }else{ - utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) + utils.log("DEBUG", "Generic Query Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled) exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) throw new BpmnError("MSOWorkflowException") } @@ -255,11 +296,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode) utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI Response Code: " + responseCode) - + String aaiResponse = response.getResponseBodyAsString() aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse) - utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + utils.logAudit("GenericGetService AAI Response: " + aaiResponse) //Process Response if(responseCode == 200){ utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled) @@ -268,6 +309,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled) execution.setVariable("GENGS_FoundIndicator", true) String resourceLink = utils.getNodeText1(aaiResponse, "resource-link") + execution.setVariable("GENGS_resourceLink", resourceLink) execution.setVariable("GENGS_siResourceLink", resourceLink) }else{ utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled) @@ -308,10 +350,10 @@ class GenericGetService extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) String aai_endpoint = execution.getVariable("URN_aai_endpoint") String serviceEndpoint = "" - + utils.logAudit("GenericGetService getServiceObject AAI Endpoint: " + aai_endpoint) if(type.equalsIgnoreCase("service-instance")){ - String siResourceLink = execution.getVariable("GENGS_siResourceLink") + String siResourceLink = execution.getVariable("GENGS_resourceLink") if(isBlank(siResourceLink)){ String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) @@ -324,7 +366,27 @@ class GenericGetService extends AbstractServiceTaskProcessor{ logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") }else{ - utils.log("DEBUG", "Incoming Service Instance Resource Link is: " + siResourceLink, isDebugEnabled) + utils.log("DEBUG", "Incoming Service Instance Url is: " + siResourceLink, isDebugEnabled) + String[] split = siResourceLink.split("/aai/") + serviceEndpoint = "/aai/" + split[1] + } + }else if(type.equalsIgnoreCase("allotted-resource")){ + String siResourceLink = execution.getVariable("GENGS_resourceLink") + if(isBlank(siResourceLink)){ + String allottedResourceId = execution.getVariable("GENGS_allottedResourceId") + utils.log("DEBUG", " Incoming GENGS_allottedResourceId is: " + allottedResourceId, isDebugEnabled) + String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId") + utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) + String serviceType = execution.getVariable("GENGS_serviceType") + utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled) + String globalCustomerId = execution.getVariable("GENGS_globalCustomerId") + utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled) + + String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) + logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) + serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + }else{ + utils.log("DEBUG", "Incoming Allotted-Resource Url is: " + siResourceLink, isDebugEnabled) String[] split = siResourceLink.split("/aai/") serviceEndpoint = "/aai/" + split[1] } @@ -345,12 +407,11 @@ class GenericGetService extends AbstractServiceTaskProcessor{ execution.setVariable("GENGS_getServiceResponseCode", responseCode) utils.log("DEBUG", " GET Service response code is: " + responseCode, isDebugEnabled) utils.logAudit("GenericGetService AAI Response Code: " + responseCode) - + String aaiResponse = response.getResponseBodyAsString() aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENGS_getServiceResponse", aaiResponse) utils.logAudit("GenericGetService AAI Response: " + aaiResponse) - //Process Response if(responseCode == 200 || responseCode == 202){ utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled) @@ -382,4 +443,4 @@ class GenericGetService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled) } -} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy index df9a97c78c..bc787df577 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts -import static org.apache.commons.lang3.StringUtils.* +import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy index 9609103228..9f7d57f335 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy @@ -49,6 +49,7 @@ import org.springframework.web.util.UriUtils * * * Incoming Required Variables: + * @param - GENPS_requestId * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription * @param - GENPS_globalSubscriberId - Required field * @param - GENPS_serviceType - Required Field @@ -58,8 +59,7 @@ import org.springframework.web.util.UriUtils * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. * - * @param - GENPS_requestId to trace the request id - * @param - GENPS_serviceResourceVersion optional needs to be provided only in case of update for both service-instance and service subscription. The calling flows + * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows * should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be * obtained from aai and sent as an input parameter. * @@ -183,7 +183,7 @@ class GenericPutService extends AbstractServiceTaskProcessor{ AaiUtil aaiUriUtil = new AaiUtil(this) String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) logDebug('AAI URI is: ' + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + namespace, isDebugEnabled) String aai_endpoint = execution.getVariable("URN_aai_endpoint") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy new file mode 100644 index 0000000000..3397aa9b54 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericUtils.groovy @@ -0,0 +1,20 @@ +package org.openecomp.mso.bpmn.common.scripts + +import org.apache.commons.lang3.StringUtils; + +class GenericUtils extends StringUtils{ + + @Override + public static boolean isBlank(final CharSequence cs) { + int strLen; + if (cs == null || (strLen = cs.length()) == 0 || cs.equals("null")) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (Character.isWhitespace(cs.charAt(i)) == false) { + return false; + } + } + return true; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy index f870e30d1d..4ca0370185 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -932,7 +932,7 @@ class SDNCAdapterUtils { if (modelVersionId == null) { modelVersionId = "" } - String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationId") + String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid") String modelCustomizationString = "" if (modelCustomizationUuid != null) { modelCustomizationString = "${modelCustomizationUuid}" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 4838a67d36..0c483388c1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -28,7 +28,7 @@ import org.springframework.web.util.UriUtils public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { - + private XmlParser xmlParser = new XmlParser() ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -44,12 +44,13 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { execution.setVariable('UAAIGenVnf_personaModelVersion', null) execution.setVariable("UAAIGenVnf_ipv4OamAddress", null) execution.setVariable('UAAIGenVnf_managementV6Address', null) + execution.setVariable('UAAIGenVnf_orchestrationStatus', null) execution.setVariable('UAAIGenVnf_getGenericVnfResponseCode' ,null) execution.setVariable('UAAIGenVnf_getGenericVnfResponse', '') execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', null) execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', '') } - + /** * Check for missing elements in the received request. * @@ -90,6 +91,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { if (managementV6Address != null && !managementV6Address.isEmpty()) { execution.setVariable('UAAIGenVnf_managementV6Address', managementV6Address) } + + def orchestrationStatus = getNodeTextForce(xml, 'orchestration-status') + if (orchestrationStatus != null && !orchestrationStatus.isEmpty()) { + execution.setVariable('UAAIGenVnf_orchestrationStatus', orchestrationStatus) + } logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError e) { @@ -99,7 +105,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) } } - + /** * Using the received vnfId, query AAI to get the corresponding Generic VNF. * A 200 response is expected with the VF Module in the response body. @@ -182,7 +188,11 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { if (newPersonaModelId != null || newPersonaModelVersion != null) { // Confirm "new" persona-model-id is same as "current" persona-model-id - def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') + def Node currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'model-invariant-id') + if (currPersonaModelIdNode == null) { + // check the old attribute name + currPersonaModelIdNode = utils.getChildNode(genericVnfNode, 'persona-model-id') + } def String currPersonaModelId = '' if (currPersonaModelIdNode != null) { currPersonaModelId = currPersonaModelIdNode.text() @@ -194,7 +204,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { } // Construct payload - personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'persona-model-version') + personaModelVersionEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'model-version-id') } // Handle ipv4-oam-address @@ -212,11 +222,20 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct payload managementV6AddressEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'management-v6-address') } + + // Handle orchestration-status + def String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') + def String orchestrationStatusEntry = "" + if (orchestrationStatus != null) { + // Construct payload + orchestrationStatusEntry = updateGenericVnfNode(origRequest, genericVnfNode, 'orchestration-status') + } def payload = """ { ${personaModelVersionEntry} ${ipv4OamAddressEntry} - ${managementV6AddressEntry} + ${managementV6AddressEntry} + ${orchestrationStatusEntry} "vnf-id": "${vnfId}" } """ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy index 7283a3ecfc..1f9db12b6f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -133,7 +133,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } /** - * Construct and send a PUT request to AAI to update the VF Module. + * Construct and send a PATCH request to AAI to update the VF Module. * * @param execution The flow's execution instance. */ @@ -176,7 +176,11 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { doPersonaModelVersion = false } else { // Confirm "new" persona-model-id is same as "current" persona-model-id - def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'persona-model-id') + def String currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-invariant-id') + if (currPersonaModelId == null) { + // check the old attribute name + currPersonaModelId = utils.getChildNodeText(vfModuleNode, 'model-version-id') + } if (currPersonaModelId == null) { currPersonaModelId = '' } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy index d48ae8f84e..7a97d5cd12 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy @@ -40,7 +40,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * Get the XmlParser. - * + * * @return the XmlParser. */ protected XmlParser getXmlParser() { @@ -50,7 +50,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * Find the VF Module with specified ID in the specified Generic VF. If no such * VF Module is found, null is returned. - * + * * @param genericVnf The Generic VNF in which to search for the specified VF Moduel. * @param vfModuleId The ID of the VF Module for which to search. * @return a VFModule object for the found VF Module or null if no VF Module is found. @@ -77,7 +77,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { * element to a corresponding list of 'vnf-networks' specifications (typically used when * invoking the VNF Rest Adpater). Each element in '*-params' whose name attribute ends * with '_network' is used to create an 'vnf-networks' element. - * + * * @param paramsNode A Node representing a '*-params' element. * @return a String of 'vnf-networks' elements, one for each 'param' element whose name * attribute ends with '_network'. @@ -189,7 +189,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /** * Extract the Tenant Id from the Volume Group information returned by AAI. - * + * * @param volumeGroupXml Volume Group XML returned by AAI. * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if * the Tenant Id is missing or could not otherwise be extracted. @@ -233,7 +233,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { */ - protected String buildVfModuleParams(String vnfParams, String sdncGetResponse, String vnfId, String vnfName, + protected String buildVfModuleParams(Map vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName, String vfModuleId, String vfModuleName, String vfModuleIndex) { //Get SDNC Response Data @@ -251,36 +251,19 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { oldVnfId = utils.removeXmlNamespaces(oldVnfId) serviceData = serviceData.replace(oldVnfId, "") def vnfId1 = utils.getNodeText1(serviceData, "vnf-id") - String vfModuleIndexParam = "" + + Map paramsMap = new HashMap() if (vfModuleIndex != null) { - vfModuleIndexParam = """ - vf_module_index - ${vfModuleIndex} - """ + paramsMap.put("vf_module_index", "${vfModuleIndex}") } // Add-on data - String vnfInfo = - """ - vnf_id - ${vnfId} - - - vnf_name - ${vnfName} - - - vf_module_id - ${vfModuleId} - - - vf_module_name - ${vfModuleName} - - ${vfModuleIndexParam}""" - - utils.logAudit("vnfInfo: " + vnfInfo) + paramsMap.put("vnf_id", "${vnfId}") + paramsMap.put("vnf_name", "${vnfName}") + paramsMap.put("vf_module_id", "${vfModuleId}") + paramsMap.put("vf_module_name", "${vfModuleName}") + InputSource source = new InputSource(new StringReader(data)); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true) @@ -289,8 +272,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { // Availability Zones Data - String aZones = "" - StringBuilder sbAZone = new StringBuilder() NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") String aZonePosition = "0" @@ -300,28 +281,14 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { Element eElement = (Element) node String aZoneValue = utils.getElementText(eElement, "availability-zone") aZonePosition = z.toString() - String aZoneXml = - """ - availability_zone_${aZonePosition} - ${aZoneValue} - """ - aZones = sbAZone.append(aZoneXml) + paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") } } // VNF Networks Data - String vnfNetworkNetId = "" - String vnfNetworkNetName = "" - String vnfNetworkSubNetId = "" - String vnfNetworkV6SubNetId = "" - String vnfNetworkNetFqdn = "" - String vnfNetworksSriovVlanFilters = "" + StringBuilder sbNet = new StringBuilder() - StringBuilder sbNet2 = new StringBuilder() - StringBuilder sbNet3 = new StringBuilder() - StringBuilder sbNet4 = new StringBuilder() - StringBuilder sbNet5 = new StringBuilder() - StringBuilder sbNet6 = new StringBuilder() + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") for (int x = 0; x < vnfNetworkList.getLength(); x++) { Node node = vnfNetworkList.item(x) @@ -333,36 +300,11 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - String vnfNetworkNetIdXml = - """ - ${vnfNetworkKey}_net_id - ${vnfNetworkNeutronIdValue} - """ - vnfNetworkNetId = sbNet.append(vnfNetworkNetIdXml) - String vnfNetworkNetNameXml = - """ - ${vnfNetworkKey}_net_name - ${vnfNetworkNetNameValue} - """ - vnfNetworkNetName = sbNet2.append(vnfNetworkNetNameXml) - String vnfNetworkSubNetIdXml = - """ - ${vnfNetworkKey}_subnet_id - ${vnfNetworkSubNetIdValue} - """ - vnfNetworkSubNetId = sbNet3.append(vnfNetworkSubNetIdXml) - String vnfNetworkV6SubNetIdXml = - """ - ${vnfNetworkKey}_v6_subnet_id - ${vnfNetworkV6SubNetIdValue} - """ - vnfNetworkV6SubNetId = sbNet5.append(vnfNetworkV6SubNetIdXml) - String vnfNetworkNetFqdnXml = - """ - ${vnfNetworkKey}_net_fqdn - ${vnfNetworkNetFqdnValue} - """ - vnfNetworkNetFqdn = sbNet4.append(vnfNetworkNetFqdnXml) + paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") + paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") + paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") StringBuffer sriovFilterBuf = new StringBuffer() @@ -381,23 +323,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } } if (!values.isEmpty()) { - String vnfNetworkSriovVlanFilterXml = - """ - ${vnfNetworkKey}_ATT_VF_VLAN_FILTER - ${values} - """ - vnfNetworksSriovVlanFilters = sbNet6.append(vnfNetworkSriovVlanFilterXml) + paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") } } } // VNF-VMS Data - String vnfVMS = "" - String vnfVMSPositions = "" - String vmNetworks = "" - String vmNetworksPositions = "" - String vmNetworksPositionsV6 = "" - String interfaceRoutePrefixes = "" + def key def value def networkKey @@ -407,11 +339,6 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { def floatingIPV6Key def floatingIPV6KeyValue StringBuilder sb = new StringBuilder() - StringBuilder sbPositions = new StringBuilder() - StringBuilder sbVmNetworks = new StringBuilder() - StringBuilder sbNetworksPositions = new StringBuilder() - StringBuilder sbInterfaceRoutePrefixes = new StringBuilder() - StringBuilder sbNetworksPositionsV6 = new StringBuilder() NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") for (int x = 0; x < vmsList.getLength(); x++) { @@ -436,12 +363,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { values = sb1.append(value); } position = i.toString() - String vnfPositionXml = - """ - ${key}_name_${position} - ${value} - """ - vnfVMSPositions = sbPositions.append(vnfPositionXml) + paramsMap.put("${key}_name_${position}", "${value}") } } for(int n = 0; n < vmNetworksList.getLength(); n++){ @@ -459,19 +381,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { networkKey = utils.getElementText(eElementNetworkKey, "network-role") floatingIPKey = key + '_' + networkKey + '_floating_ip' floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - floatingIpKeyValueStr = """ - $floatingIPKey - $floatingIPKeyValue - """ + if(!floatingIPKeyValue.isEmpty()){ + paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") } floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - floatingIpV6KeyValueStr = """ - $floatingIPV6Key - $floatingIPV6KeyValue - """ + if(!floatingIPV6KeyValue.isEmpty()){ + paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") } NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") for(int a = 0; a < networkIpsList.getLength(); a++){ @@ -486,50 +402,34 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ipAddressValues = sb2.append(ipAddressValue); } networkPosition = a.toString() - String vmNetworksPositionsXml = - """ - ${key}_${networkKey}_ip_${networkPosition} - ${ipAddressValue} - """ - vmNetworksPositions = sbNetworksPositions.append(vmNetworksPositionsXml) + paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") } } - vmNetworksPositions = sbNetworksPositions.append(floatingIpKeyValueStr).append(floatingIpV6KeyValueStr) - - String vmNetworksXml = - """ - ${key}_${networkKey}_ips - ${ipAddressValues} - """ - vmNetworks = sbVmNetworks.append(vmNetworksXml) + + paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") String interfaceRoutePrefixValues = sb3.append("[") - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") } - if (a != interfaceRoutePrefixesList.getLength() - 1) { + if (a != interfaceRoutePrefixesList.getLength() - 1) { interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") } else { interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } + } } } interfaceRoutePrefixValues = sb3.append("]") if (interfaceRoutePrefixesList.getLength() > 0) { - String interfaceRoutePrefixesXml = - """ - ${key}_${networkKey}_route_prefixes - ${interfaceRoutePrefixValues} - """ - interfaceRoutePrefixes = sbInterfaceRoutePrefixes.append(interfaceRoutePrefixesXml) + paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") } NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") @@ -545,28 +445,13 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { ipV6AddressValues = sb4.append(ipV6AddressValue); } networkPosition = a.toString() - String vmNetworksPositionsV6Xml = - """ - ${key}_${networkKey}_v6_ip_${networkPosition} - ${ipV6AddressValue} - """ - vmNetworksPositionsV6 = sbNetworksPositionsV6.append(vmNetworksPositionsV6Xml) + paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") } } - String vmNetworksV6Xml = - """ - ${key}_${networkKey}_v6_ips - ${ipV6AddressValues} - """ - vmNetworks = sbVmNetworks.append(vmNetworksV6Xml) + paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") } } - String vnfXml = - """ - ${key}_names - ${values} - """ - vnfVMS = sb.append(vnfXml) + paramsMap.put("${key}_names", "${values}") } } //SDNC Response Params @@ -575,7 +460,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ // No SDNC params - }else{ + }else{ NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") for (int z = 0; z < paramsList.getLength(); z++) { Node node = paramsList.item(z) @@ -583,34 +468,35 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") - String paraEntry = - """ - ${vnfParameterName} - ${vnfParameterValue} - """ - sdncResponseParams = sb.append(paraEntry) + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") } } } + + // Parameters received from the request should overwrite any parameters received from SDNC + if (vnfParamsMap != null) { + for (Map.Entry entry : vnfParamsMap.entrySet()) { + String vnfKey = entry.getKey() + String vnfValue = entry.getValue() + paramsMap.put("$vnfKey", "$vnfValue") + } + } + + StringBuilder sbParams = new StringBuilder() + def vfModuleParams = "" + for (Map.Entry entry : paramsMap.entrySet()) { + String paramsXml + String paramName = entry.getKey() + String paramValue = entry.getValue() + paramsXml = + """ + ${paramName} + ${paramValue} + + """ - - def vfModuleParams = """ - ${vnfInfo} - ${aZones} - ${vnfNetworkNetId} - ${vnfNetworkNetName} - ${vnfNetworkSubNetId} - ${vnfNetworkV6SubNetId} - ${vnfNetworkNetFqdn} - ${vnfNetworksSriovVlanFilters} - ${vnfVMS} - ${vnfVMSPositions} - ${vmNetworks} - ${vmNetworksPositions} - ${vmNetworksPositionsV6} - ${interfaceRoutePrefixes} - ${vnfParams} - ${sdncResponseParams}""" + vfModuleParams = sbParams.append(paramsXml) + } return vfModuleParams @@ -618,7 +504,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { /* - * VBNG specific method that parses VNF parameters passed in on the + * VBNG specific method that parses VNF parameters passed in on the * incoming requests and SDNC parameters returned from SDNC get response * and puts them into the format expected by VNF adapter. * @param vnfParamsMap - map of VNF parameters passed in the request body diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java new file mode 100644 index 0000000000..214ae28b70 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java @@ -0,0 +1,352 @@ +package org.openecomp.mso.bpmn.common.workflow.service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.BpmPlatform; +import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.MessageCorrelationResult; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Abstract base class for callback services. + */ +public abstract class AbstractCallbackService { + public static final long DEFAULT_TIMEOUT_SECONDS = 60; + public static final long FAST_POLL_DUR_SECONDS = 5; + public static final long FAST_POLL_INT_MS = 100; + public static final long SLOW_POLL_INT_MS = 1000; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + protected volatile ProcessEngineServices pes4junit = null; + + /** + * Parameterized callback handler. + */ + protected CallbackResult handleCallback(String method, Object message, + String messageEventName, String messageVariable, + String correlationVariable, String correlationValue, + String logMarker) { + + return handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker, null); + } + + /** + * Parameterized callback handler. + */ + protected CallbackResult handleCallback(String method, Object message, + String messageEventName, String messageVariable, + String correlationVariable, String correlationValue, + String logMarker, Map injectedVariables) { + + long startTime = System.currentTimeMillis(); + + LOGGER.debug(logMarker + " " + method + " received message: " + + (message == null ? "" : System.lineSeparator()) + message); + + try { + Map variables = new HashMap(); + + if (injectedVariables != null) { + variables.putAll(injectedVariables); + } + + variables.put(correlationVariable, correlationValue); + variables.put(messageVariable, message == null ? null : message.toString()); + + boolean ok = correlate(messageEventName, correlationVariable, + correlationValue, variables, logMarker); + + if (!ok) { + String msg = "No process is waiting for " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + + logCallbackSuccess(method, startTime); + return new CallbackSuccess(); + } catch (Exception e) { + String msg = "Caught " + e.getClass().getSimpleName() + + " processing " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'"; + logCallbackError(method, startTime, msg); + return new CallbackError(msg); + } + } + + /** + * Performs message correlation. Waits a limited amount of time for + * a process to become ready for correlation. The return value indicates + * whether or not a process was found to receive the message. Due to the + * synchronous nature of message injection in Camunda, by the time this + * method returns, one of 3 things will have happened: (1) the process + * received the message and ended, (2) the process received the message + * and reached an activity that suspended, or (3) an exception occurred + * during correlation or while the process was executing. Correlation + * exceptions are handled differently from process execution exceptions. + * Correlation exceptions are thrown so the client knows something went + * wrong with the delivery of the message. Process execution exceptions + * are logged but not thrown. + * @param messageEventName the message event name + * @param correlationVariable the process variable used as the correlator + * @param correlationValue the correlation value + * @param variables variables to inject into the process + * @param logMarker a marker for debug logging + * @return true if a process could be found, false if not + * @throws Exception for correlation errors + */ + protected boolean correlate(String messageEventName, String correlationVariable, + String correlationValue, Map variables, String logMarker) + throws Exception { + + LOGGER.debug(logMarker + " Attempting to find process waiting" + + " for " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'"); + + RuntimeService runtimeService = + getProcessEngineServices().getRuntimeService(); + + Map properties = + PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + + long timeout = DEFAULT_TIMEOUT_SECONDS; + + // The code is here in case we ever need to change the default. + String s = properties.get("mso.correlation.timeout"); + if (s != null) { + try { + timeout = Long.parseLong(s); + } catch (NumberFormatException e) { + // Ignore + } + } + + long now = System.currentTimeMillis(); + long fastPollEndTime = now + (FAST_POLL_DUR_SECONDS * 1000); + long endTime = now + (timeout * 1000); + long sleep = FAST_POLL_INT_MS; + + List waitingProcesses = null; + Exception queryException = null; + int queryCount = 0; + int queryFailCount = 0; + + while (true) { + try { + ++queryCount; + waitingProcesses = runtimeService.createExecutionQuery() + .messageEventSubscriptionName(messageEventName) + .processVariableValueEquals(correlationVariable, correlationValue) + .list(); + } catch (Exception e) { + ++queryFailCount; + queryException = e; + } + + if (waitingProcesses != null && waitingProcesses.size() > 0) { + break; + } + + if (now > endTime - sleep) { + break; + } + + Thread.sleep(sleep); + now = System.currentTimeMillis(); + + if (now > fastPollEndTime) { + sleep = SLOW_POLL_INT_MS; + } + } + + if (waitingProcesses == null) { + waitingProcesses = new ArrayList(0); + } + + int count = waitingProcesses.size(); + + List execInfoList = new ArrayList(count); + for (Execution execution : waitingProcesses) { + execInfoList.add(new ExecInfo(execution)); + } + + LOGGER.debug(logMarker + " Found " + count + " process(es) waiting" + + " for " + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "': " + execInfoList); + + if (count == 0) { + if (queryFailCount > 0) { + String msg = queryFailCount + "/" + queryCount + + " execution queries failed attempting to correlate " + + messageEventName + " with " + correlationVariable + + " = '" + correlationValue + "'; last exception was:" + + queryException; + LOGGER.debug(msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, queryException); + } + + return false; + } + + if (count > 1) { + // Only one process should be waiting. Throw an exception back to the client. + throw new MismatchingMessageCorrelationException(messageEventName, + "more than 1 process is waiting with " + correlationVariable + + " = '" + correlationValue + "'"); + } + + // We prototyped an asynchronous solution, i.e. resuming the process + // flow in a separate thread, but this affected too many existing tests, + // and we went back to the synchronous solution. The synchronous solution + // has some troublesome characteristics though. For example, the + // resumed flow may send request #2 to a remote system before MSO has + // acknowledged the notification associated with request #1. + + try { + LOGGER.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " + + messageEventName + " with " + correlationVariable + " = '" + + correlationValue + "'"); + + @SuppressWarnings("unused") + MessageCorrelationResult result = runtimeService + .createMessageCorrelation(messageEventName) + .setVariables(variables) + .processInstanceVariableEquals(correlationVariable, correlationValue) + .correlateWithResult(); + + } catch (MismatchingMessageCorrelationException e) { + // A correlation exception occurred even after we identified + // one waiting process. Throw it back to the client. + throw e; + } catch (Exception e) { + // This must be an exception from the flow itself. Log it, but don't + // report it back to the client. + String msg = "Caught " + e.getClass().getSimpleName() + " running " + + execInfoList.get(0) + " after receiving " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + + "': " + e; + LOGGER.debug(msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, e); + } + + return true; + } + + /** + * Records audit and metric events in the log for a callback success. + * @param method the method name + * @param startTime the request start time + */ + protected void logCallbackSuccess(String method, long startTime) { + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Completed " + method); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Completed " + method, + "BPMN", MsoLogger.getServiceName(), null); + } + + /** + * Records error, audit and metric events in the log for a callback + * internal error. + * @param method the method name + * @param startTime the request start time + * @param msg the error message + */ + protected void logCallbackError(String method, long startTime, String msg) { + logCallbackError(method, startTime, msg, null); + } + + /** + * Records error, audit and metric events in the log for a callback + * internal error. + * @param method the method name + * @param startTime the request start time + * @param msg the error message + * @param e the exception + */ + protected void logCallbackError(String method, long startTime, String msg, Exception e) { + if (e == null) { + LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg); + } else { + LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, e); + } + + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.InternalError, "Completed " + method); + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.InternalError, "Completed " + method, + "BPMN", MsoLogger.getServiceName(), null); + } + + /** + * Abstract callback result object. + */ + protected abstract class CallbackResult { + } + + /** + * Indicates that callback handling was successful. + */ + protected class CallbackSuccess extends CallbackResult { + } + + /** + * Indicates that callback handling failed. + */ + protected class CallbackError extends CallbackResult { + private final String errorMessage; + + public CallbackError(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets the error message. + */ + public String getErrorMessage() { + return errorMessage; + } + } + + private static class ExecInfo { + private final Execution execution; + + public ExecInfo(Execution execution) { + this.execution = execution; + } + + @Override + public String toString() { + return "Process[" + execution.getProcessInstanceId() + + ":" + execution.getId() + "]"; + } + } + + protected ProcessEngineServices getProcessEngineServices() { + if (pes4junit == null) { + return BpmPlatform.getDefaultProcessEngine(); + } else { + return pes4junit; + } + } + + public void setProcessEngineServices4junit(ProcessEngineServices pes) { + pes4junit = pes; + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java index 4585d620ac..16fa51515e 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/SDNCAdapterCallbackServiceImpl.java @@ -41,240 +41,53 @@ import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType; import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; + /** - * @version 1.0 - * + * Implementation of SDNCAdapterCallbackService. */ @WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.openecomp/workflow/sdnc/adapter/schema/v1") -public class SDNCAdapterCallbackServiceImpl implements SDNCCallbackAdapterPortType { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private final int DEFAULT_RETRY_ATTEMPTS = 60; - private final int DEFAULT_SLEEP_TIME = 500; +public class SDNCAdapterCallbackServiceImpl extends AbstractCallbackService implements SDNCCallbackAdapterPortType { private final String logMarker = "[SDNC-CALLBACK]"; @Context WebServiceContext wsContext; - private volatile ProcessEngineServices pes4junit = null; - @WebMethod(operationName = "SDNCAdapterCallback") @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") public SDNCAdapterResponse sdncAdapterCallback( @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest") SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) { - //Callback URL to use http://localhost:28080/mso/SDNCAdapterCallbackService - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - String receivedRequestId = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - MsoLogger.setServiceName("MSO." + "sdncAdapter"); - MsoLogger.setLogContext(receivedRequestId, "N/A"); - msoLogger.debug(logMarker + "Received callback response:" + sdncAdapterCallbackRequest.toString()); - SDNCAdapterResponse sdncAdapterResponse; - long startTime = System.currentTimeMillis(); - - /*Correlating the response with the running instance*/ - - // NOTE: the following loop is a workaround for problems we've had - // with reliability of the runtime service. It seems that queries - // sometimes return results, and sometimes they don't. This might - // be a problem in mysql only. We aren't sure if it affects camunda - // on oracle or mariadb. The workaround is to repeat the request - // a number of times until it succeeds. If it doesn't succeed after - // 60 tries, then we give up. - - int maxAttempts = DEFAULT_RETRY_ATTEMPTS; - int attempt = 1; - int sleepTime = DEFAULT_SLEEP_TIME; + String method = "sdncAdapterCallback"; + Object message = sdncAdapterCallbackRequest; + String messageEventName = "sdncAdapterCallbackRequest"; + String messageVariable = "sdncAdapterCallbackRequest"; + String correlationVariable = "SDNCA_requestId"; + String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId(); - Map bpmnProperties = getMSOBPMNURNProperties(); - if (bpmnProperties != null) { - try { - maxAttempts = Integer.parseInt(bpmnProperties.get("mso.callbackRetryAttempts")); - msoLogger.debug(logMarker + "mso.callbackRetryAttempts=" + maxAttempts); - sleepTime = Integer.parseInt(bpmnProperties.get("mso.callbackRetrySleepTime")); - msoLogger.debug(logMarker + "mso.callbackRetrySleepTime:" + sleepTime); - } catch (Exception ex) { - - msoLogger.debug (logMarker - + "Error parsing mso.callbackRetrySleepTime/mso.callbackRetryAttempts:" - + sleepTime + ":" - + maxAttempts); - - } - } - - /* Check to make sure the process instance is reay for correlation*/ - try{ - isReadyforCorrelation(runtimeService, receivedRequestId, maxAttempts, sleepTime ); - }catch(Exception e){ - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but that RequestId doesn't exist or has timed out waiting for the callback"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService." ); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); - msoLogger.debug(logMarker + "*** Received MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO sdncAdapterCallbackService"); - - msoLogger.debug(logMarker + "Callback response string:\n" + sdncAdapterCallbackRequest.toString()); + CallbackResult result = handleCallback(method, message, messageEventName, + messageVariable, correlationVariable, correlationValue, logMarker); - String reqId = receivedRequestId; - Map variables = new HashMap(); - variables.put("SDNCA_requestId", reqId ); - variables.put("sdncAdapterCallbackRequest", sdncAdapterCallbackRequest.toString()); - while (true) { - try { - // sdncAdapterCallbackRequest is the message event name (defined in the bpmn process) - runtimeService.createMessageCorrelation("sdncAdapterCallbackRequest") - .setVariables(variables) - .processInstanceVariableEquals("SDNCA_requestId", reqId).correlate(); - sdncAdapterResponse = new SDNCAdapterResponse(); - msoLogger.debug(logMarker + "***** Completed processing of MSO sdncAdapterCallbackService ******"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch (attempt " + attempt + "/" + maxAttempts + ")"); - if (attempt == maxAttempts) { - // Couldn't correlate requestId to any active flow - //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but that RequestId could not be correlated to any active process - ignoring the Request"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService." ); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e2) { - String msg = - "SDNC Adapter Callback Service received a SDNC Adapter Callback Request with RequestId '" - + receivedRequestId - + "' but correlation was interrupted"; - sdncAdapterResponse = new SDNCAdapterExceptionResponse(e); - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker - + "Completed the execution of MSO SDNCAdapterCallbackService."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO SDNCAdapterCallbackService.", "BPMN", - MsoLogger.getServiceName(), "sdncAdapterCallback"); - - return sdncAdapterResponse; - } - } - - attempt++; - } - } - - - private Map getMSOBPMNURNProperties() { - PropertyConfiguration propertyConfiguration = PropertyConfiguration.getInstance(); - Map props = propertyConfiguration.getProperties("mso.bpmn.urn.properties"); - return props; - } - - private void isReadyforCorrelation(RuntimeService runtimeService, - String receivedRequestId, int retries, int sleepTime){ - ExecutionQuery waitingInstances = null; - long waitingInstancesCount = 0; - - //Workaround for performance testing, explicit wait for a second for the transactions to be committed - //Also check to make sure the process didn't timeout before trying to correlate - - do{ - waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName("sdncAdapterCallbackRequest") - .processVariableValueEquals("SDNCA_requestId", receivedRequestId); - waitingInstancesCount = waitingInstances.count(); - retries--; - msoLogger.debug(logMarker + "waitingInstancesCount: " + waitingInstancesCount); - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - - msoLogger.error (MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker, e); - - } - }while (waitingInstancesCount==0 && retries > 0); - if(waitingInstancesCount > 0){ - msoLogger.debug(logMarker + "waitingInstancesCount before timeout check: " + waitingInstancesCount); - waitingInstancesCount = waitingInstances.processVariableValueEquals("asynchronousResponseTimeout", false).count(); - msoLogger.debug(logMarker + "waitingInstancesCount after timeout check: " + waitingInstancesCount); - if(waitingInstancesCount<=0){ - msoLogger.debug(logMarker + "detected timeout on flow to correlate"); - throw new IllegalStateException("process timed out"); - } - }else{ - //flow may have already ended, so can't check timeout variable. Throw exception? - msoLogger.debug(logMarker + "no flow to correlate to"); - throw new IllegalStateException("no flow to correlate to"); - } - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); + if (result instanceof CallbackError) { + return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage()); } else { - return pes4junit; + return new SDNCAdapterResponse(); } } - @WebMethod(exclude=true) - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } - - public class SDNCAdapterExceptionResponse extends SDNCAdapterResponse { - private Exception ex; + // This subclass allows unit tests to extract the error + public class SDNCAdapterErrorResponse extends SDNCAdapterResponse { + private String error; - public SDNCAdapterExceptionResponse(Exception ex) { - super(); - this.ex = ex; + public SDNCAdapterErrorResponse(String error) { + this.error = error; } - public Exception getException() { - return ex; + public String getError() { + return error; } } -} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 457717243a..0faf5feafc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -1,536 +1,249 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.common.workflow.service; - -import java.util.HashMap; -import java.util.Map; - -import javax.jws.Oneway; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.ws.rs.core.Context; -import javax.xml.ws.Action; -import javax.xml.ws.RequestWrapper; -import javax.xml.ws.WebServiceContext; - -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.MismatchingMessageCorrelationException; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; -import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; -import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; -import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This is the service class for VnfAdapterNotify - * TODO: Add addition VnfAdapterNotify Methods for remaining VnfAdapterNotify operations. - */ - -@WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") -public class VnfAdapterNotifyServiceImpl implements VnfAdapterNotify{ - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.common.workflow.service; + +import javax.jws.Oneway; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ws.rs.core.Context; +import javax.xml.ws.Action; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.WebServiceContext; + +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory; +import org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.RollbackVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfAdapterNotify; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback; +import org.openecomp.mso.bpmn.common.adapter.vnf.VnfStatus; +import org.openecomp.mso.logger.MsoLogger; + +/** + * Implementation of the VnfAdapterNotify service. + */ +@WebService(serviceName = "vnfAdapterNotify", targetNamespace = "http://org.openecomp.mso/vnfNotify") +public class VnfAdapterNotifyServiceImpl extends AbstractCallbackService implements VnfAdapterNotify{ + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private final String logMarker = "[VNF-NOTIFY]"; - - @Context WebServiceContext wsContext; - - private volatile ProcessEngineServices pes4junit = null; - - /** - * - * @param errorMessage - * @param exception - * @param messageId - * @param completed - */ - @WebMethod(operationName = "rollbackVnfNotification") - @Oneway - @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") + private final String logMarker = "[VNF-NOTIFY]"; + + @Context WebServiceContext wsContext; + + @WebMethod(operationName = "rollbackVnfNotification") + @Oneway + @RequestWrapper(localName = "rollbackVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.RollbackVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/rollbackVnfNotificationRequest") - public void rollbackVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - - - RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); - - rollbackVnfNotification.setMessageId(messageId); - rollbackVnfNotification.setCompleted(completed); - rollbackVnfNotification.setException(exception); - rollbackVnfNotification.setErrorMessage(errorMessage); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnfAdapterRollback"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received RollbackVnfNotification" + rollbackVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "rollbackVnfNotificationCallback", "VNFRB_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO rollbackVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - msoLogger.debug(logMarker + "Rollback VNF Notification string:\n" + rollbackVnfNotification.toString()); - - System.out.println("testing ROllbackVnfNotification : " + rollbackVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFRB_messageId", messageId ); - variables.put("rollbackVnfNotificationCallback", rollbackVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("rollbackVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFRB_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Rollback VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "rollbackVnfNotification"); - - return; - } - - - - /** - * - * @param errorMessage - * @param vnfExists - * @param status - * @param exception - * @param outputs - * @param messageId - * @param vnfId - * @param completed - */ - @WebMethod(operationName = "queryVnfNotification") - @Oneway + public void rollbackVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + RollbackVnfNotification rollbackVnfNotification = new RollbackVnfNotification(); + + rollbackVnfNotification.setMessageId(messageId); + rollbackVnfNotification.setCompleted(completed); + rollbackVnfNotification.setException(exception); + rollbackVnfNotification.setErrorMessage(errorMessage); + + String method = "rollbackVnfNotification"; + Object message = rollbackVnfNotification; + String messageEventName = "rollbackVnfNotificationCallback"; + String messageVariable = "rollbackVnfNotificationCallback"; + String correlationVariable = "VNFRB_messageId"; + String correlationValue = messageId; + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "queryVnfNotification") + @Oneway @RequestWrapper(localName = "queryVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.QueryVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/queryVnfNotificationRequest") - public void queryVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfExists", targetNamespace = "") - Boolean vnfExists, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "status", targetNamespace = "") - VnfStatus status, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.QueryVnfNotification.Outputs outputs){ - - QueryVnfNotification queryVnfNotification = new QueryVnfNotification(); - - queryVnfNotification.setMessageId(messageId); - queryVnfNotification.setCompleted(completed); - queryVnfNotification.setException(exception); - queryVnfNotification.setErrorMessage(errorMessage); - queryVnfNotification.setVnfExists(vnfExists); - queryVnfNotification.setVnfId(vnfId); - queryVnfNotification.setStatus(status); - queryVnfNotification.setOutputs(outputs); - - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Query"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received QueryVnfNotification" + queryVnfNotification.toString()); - - System.out.println("Received QueryVnfNotification : " + queryVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "queryVnfNotificationCallback", "VNFQ_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO queryVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - msoLogger.debug(logMarker + "Query VNF Notification string:\n" + queryVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFQ_messageId", messageId ); - variables.put("queryVnfNotificationCallback", queryVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("queryVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFQ_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Query VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - } - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); - - return; - } - - - - - /** - * - * @param errorMessage - * @param exception - * @param rollback - * @param outputs - * @param messageId - * @param vnfId - * @param completed - */ - @WebMethod(operationName = "createVnfNotification") - @Oneway + public void queryVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfExists", targetNamespace = "") + Boolean vnfExists, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "status", targetNamespace = "") + VnfStatus status, + @WebParam(name = "outputs", targetNamespace = "") + QueryVnfNotification.Outputs outputs){ + + String method = "queryVnfNotification"; + String messageEventName = "queryVnfNotificationCallback"; + String messageVariable = "queryVnfNotificationCallback"; + String correlationVariable = "VNFQ_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + QueryVnfNotification message = new QueryVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfExists(vnfExists); + message.setVnfId(vnfId); + message.setStatus(status); + message.setOutputs(outputs); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "createVnfNotification") + @Oneway @RequestWrapper(localName = "createVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.CreateVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/createVnfNotificationRequest") - public void createVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "vnfId", targetNamespace = "") - String vnfId, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - CreateVnfNotification createVnfNotification = new CreateVnfNotification(); - - createVnfNotification.setMessageId(messageId); - createVnfNotification.setCompleted(completed); - createVnfNotification.setException(exception); - createVnfNotification.setErrorMessage(errorMessage); - createVnfNotification.setVnfId(vnfId); - createVnfNotification.setOutputs(outputs); - createVnfNotification.setRollback(rollback); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Create"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received CreateVnfNotification - " + createVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - isReadyforCorrelation(runtimeService, messageId, "createVnfNotificationCallback", "VNFC_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO createVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - - msoLogger.debug(logMarker + "Create VNF Notification string:\n" + createVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFC_messageId", messageId ); - variables.put("createVnfNotificationCallback", createVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("createVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFC_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Create VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Query VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "createVnfNotification"); - - return; - } - - /** - * - * @param errorMessage - * @param exception - * @param rollback - * @param outputs - * @param messageId - * @param completed - */ - @WebMethod(operationName = "updateVnfNotification") - @Oneway + public void createVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "vnfId", targetNamespace = "") + String vnfId, + @WebParam(name = "outputs", targetNamespace = "") + CreateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + String method = "createVnfNotification"; + String messageEventName = "createVnfNotificationCallback"; + String messageVariable = "createVnfNotificationCallback"; + String correlationVariable = "VNFC_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + CreateVnfNotification message = new CreateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setVnfId(vnfId); + message.setOutputs(outputs); + message.setRollback(rollback); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "updateVnfNotification") + @Oneway @RequestWrapper(localName = "updateVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.UpdateVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest") - public void updateVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage, - @WebParam(name = "outputs", targetNamespace = "") - org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs outputs, - @WebParam(name = "rollback", targetNamespace = "") - VnfRollback rollback){ - - UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification(); - - updateVnfNotification.setMessageId(messageId); - updateVnfNotification.setCompleted(completed); - updateVnfNotification.setException(exception); - updateVnfNotification.setErrorMessage(errorMessage); - updateVnfNotification.setOutputs(outputs); - updateVnfNotification.setRollback(rollback); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnf Adapter Update"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received UpdateVnfNotification - " + updateVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - // Check to make sure the process instance is ready for correlation - isReadyforCorrelation(runtimeService, messageId, "updateVnfNotificationCallback", "VNFU_messageId"); - - msoLogger.debug(logMarker + "*** Received MSO updateVnfNotification Callback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO VnfAdapterNotifyService "); - - msoLogger.debug(logMarker + "Update VNF Notification string:\n" + updateVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFU_messageId", messageId ); - variables.put("updateVnfNotificationCallback", updateVnfNotification.toString()); - - //Correlating the response with the running instance - runtimeService.createMessageCorrelation("updateVnfNotificationCallback").setVariables(variables) - .processInstanceVariableEquals("VNFU_messageId", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO VnfAdapterNotifyService ******"); - - } catch(MismatchingMessageCorrelationException e) { - msoLogger.debug(logMarker + "[CORM]correlation id mismatch"); - String msg = - "VNF Adapter Notify Service received a Update VNF Notification request with RequestId '" - + messageId - + "' but that RequestId could not be correlated to any active process - ignoring the request"; - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO Vnf Adapter Notify for Update VNF Notification.", "BPMN", - MsoLogger.getServiceName(), "updateVnfNotification"); - - return; - } - - /** - * - * @param errorMessage - * @param exception - * @param messageId - * @param completed - */ - - //@WebService(serviceName="VNFAdapterDeleteCallbackV1", targetNamespace="http://org.openecomp.mso/vnfNotify") - @WebMethod(operationName = "deleteVnfNotification") - @Oneway + public void updateVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage, + @WebParam(name = "outputs", targetNamespace = "") + UpdateVnfNotification.Outputs outputs, + @WebParam(name = "rollback", targetNamespace = "") + VnfRollback rollback){ + + String method = "updateVnfNotification"; + String messageEventName = "updateVnfNotificationCallback"; + String messageVariable = "updateVnfNotificationCallback"; + String correlationVariable = "VNFU_messageId"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + UpdateVnfNotification message = new UpdateVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + message.setOutputs(outputs); + message.setRollback(rollback); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } + + @WebMethod(operationName = "deleteVnfNotification") + @Oneway @RequestWrapper(localName = "deleteVnfNotification", targetNamespace = "http://org.openecomp.mso/vnfNotify", className = "org.openecomp.mso.adapters.vnf.async.client.DeleteVnfNotification") @Action(input = "http://org.openecomp.mso/notify/adapterNotify/deleteVnfNotificationRequest") - public void deleteVnfNotification( - @WebParam(name = "messageId", targetNamespace = "") - String messageId, - @WebParam(name = "completed", targetNamespace = "") - boolean completed, - @WebParam(name = "exception", targetNamespace = "") - MsoExceptionCategory exception, - @WebParam(name = "errorMessage", targetNamespace = "") - String errorMessage) { - - //Callback URL to use http://localhost:28080/mso/services/VNFAdapterDeleteCallbackV1 - - //DeleteVnfNotification Class - DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification(); - deleteVnfNotification.setMessageId(messageId); - deleteVnfNotification.setCompleted(completed); - deleteVnfNotification.setException(exception); - deleteVnfNotification.setErrorMessage(errorMessage); - - ProcessEngineServices pes = getProcessEngineServices(); - RuntimeService runtimeService = pes.getRuntimeService(); - - MsoLogger.setServiceName("MSO." + "vnfAdapterDelete"); - MsoLogger.setLogContext(messageId, "N/A"); - msoLogger.debug(logMarker + "Received DeleteVnfNotification callback: " + deleteVnfNotification.toString()); - - long startTime = System.currentTimeMillis(); - try { - - /* Check to make sure the process instance is ready for correlation*/ - //isReadyforCorrelation(runtimeService, messageId, "deleteVnfACallback", "VNFDEL_uuid"); - - msoLogger.debug(logMarker + " *** Received MSO deleteVnfACallback ******"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Call to MSO deleteVnfACallback "); - msoLogger.debug(logMarker + " Callback response string:\n" + deleteVnfNotification.toString()); - - Map variables = new HashMap(); - variables.put("VNFDEL_uuid", messageId); - variables.put("deleteVnfACallback", deleteVnfNotification.toString()); - - /*Correlating the response with the running instance*/ - - runtimeService.createMessageCorrelation("deleteVnfACallback") - .setVariables(variables) - .processInstanceVariableEquals("VNFDEL_uuid", messageId).correlate(); - - msoLogger.debug(logMarker + "***** Completed processing of MSO deleteVnfACallback ******"); - - } catch(MismatchingMessageCorrelationException e) { - - msoLogger.debug(logMarker + " [CORM]correlation id mismatch"); - // Couldn't correlate requestId to any active flow - //MsoLogger logger = MsoLogger.getMsoLogger("SDNCAdapterCallbackService"); - - String msg = - "Vnf Adapter Callback Service received a Vnf Adapter Callback with messageId '" - + messageId - + "' but that messageId could not be correlated to any active process - ignoring the Request"; - - msoLogger.error(MessageEnum.BPMN_SDNC_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, logMarker + ":" + msg, e); - - } - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1."); - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - logMarker + "Completed the execution of MSO VNFAdapterDeleteCallbackV1.", "BPMN", - MsoLogger.getServiceName(), "deleteVnfNotification"); - - return; - } - - private void isReadyforCorrelation(RuntimeService runtimeService, String requestId, String responseName, String correlationValue) { - - long waitingInstances = runtimeService.createExecutionQuery().messageEventSubscriptionName(responseName).processVariableValueEquals(correlationValue, requestId).count(); - int retries = 50; - while (waitingInstances==0 && retries > 0) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - // should I add new exception Message to MessageEnum??? - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker, e); - - } // you can still play with the numbers - waitingInstances = runtimeService.createExecutionQuery() // - .messageEventSubscriptionName(responseName) - .processVariableValueEquals(correlationValue, requestId).count(); - retries--; - } - } - - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); - } else { - return pes4junit; - } - } - - @WebMethod(exclude=true) - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } -} + public void deleteVnfNotification( + @WebParam(name = "messageId", targetNamespace = "") + String messageId, + @WebParam(name = "completed", targetNamespace = "") + boolean completed, + @WebParam(name = "exception", targetNamespace = "") + MsoExceptionCategory exception, + @WebParam(name = "errorMessage", targetNamespace = "") + String errorMessage) { + + String method = "deleteVnfNotification"; + String messageEventName = "deleteVnfACallback"; + String messageVariable = "deleteVnfACallback"; + String correlationVariable = "VNFDEL_uuid"; + String correlationValue = messageId; + + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlationValue, "N/A"); + + DeleteVnfNotification message = new DeleteVnfNotification(); + + message.setMessageId(messageId); + message.setCompleted(completed); + message.setException(exception); + message.setErrorMessage(errorMessage); + + handleCallback(method, message, messageEventName, messageVariable, + correlationVariable, correlationValue, logMarker); + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java index 5afbded982..698ec13c00 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -11,10 +12,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.camunda.bpm.BpmPlatform; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RuntimeService; - import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; @@ -27,25 +24,29 @@ import org.openecomp.mso.logger.MsoLogger; * */ @Path("/") -public class WorkflowMessageResource { +public class WorkflowMessageResource extends AbstractCallbackService { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; - - private ProcessEngineServices pes4junit = null; @POST @Path("/WorkflowMessage/{messageType}/{correlator}") @Consumes("*/*") @Produces(MediaType.TEXT_PLAIN) - public Response deliver(@PathParam("messageType") String messageType, - @PathParam("correlator") String correlator, String message) { + public Response deliver( + @HeaderParam("Content-Type") String contentType, + @PathParam("messageType") String messageType, + @PathParam("correlator") String correlator, + String message) { + + String method = "receiveWorkflowMessage"; + MsoLogger.setServiceName("MSO." + method); + MsoLogger.setLogContext(correlator, "N/A"); LOGGER.debug(LOGMARKER + " Received workflow message" + " type='" + messageType + "'" + " correlator='" + correlator + "'" - + System.lineSeparator() + message); - - MsoLogger.setServiceName("MSO." + "WorkflowMessage"); + + (contentType == null ? "" : " contentType='" + contentType + "'") + + " message=" + System.lineSeparator() + message); if (messageType == null || messageType.isEmpty()) { String msg = "Missing message type"; @@ -63,79 +64,25 @@ public class WorkflowMessageResource { return Response.status(400).entity(msg).build(); } - String correlatorVariable = messageType + "_CORRELATOR"; + String messageEventName = "WorkflowMessage"; String messageVariable = messageType + "_MESSAGE"; + String correlationVariable = messageType + "_CORRELATOR"; + String correlationValue = correlator; + String contentTypeVariable = messageType + "_CONTENT_TYPE"; - long startTime = System.currentTimeMillis(); - - try { - RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); - - if (!isReadyforCorrelation(runtimeService, correlatorVariable, correlator)) { - String msg = "No process is waiting to receive '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BusinessProcesssError, msg); - return Response.status(500).entity(msg).build(); - } + Map variables = new HashMap(); - Map variables = new HashMap(); - variables.put(correlatorVariable, correlator); - variables.put(messageVariable, message); - - runtimeService.createMessageCorrelation("WorkflowMessage").setVariables(variables) - .processInstanceVariableEquals(correlatorVariable, correlator).correlate(); - - String msg = "Completed delivery of '" + messageType + "' WorkflowMessage with correlator '" + correlator + "'"; - LOGGER.debug(LOGMARKER + msg); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, msg); - return Response.status(204).build(); - } catch (Exception e) { - // For example: MismatchingMessageCorrelationException - String msg = "Caught " + e.getClass().getSimpleName() + " processing '" + messageType + "' WorkflowMessage with " + correlatorVariable + "='" + correlator + "'"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, LOGMARKER + ":" + msg, e); - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg, "BPMN", MsoLogger.getServiceName(), messageType); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, msg); - return Response.status(500).entity(msg).build(); + if (contentType != null) { + variables.put(contentTypeVariable, contentType); } - } - - private boolean isReadyforCorrelation(RuntimeService runtimeService, - String correlationVariable, String correlationValue) - throws InterruptedException { - - long waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - int retries = 50; - while (waitingInstances == 0 && retries > 0) { - Thread.sleep(100); - waitingInstances = runtimeService.createExecutionQuery() - .messageEventSubscriptionName("WorkflowMessage") - .processVariableValueEquals(correlationVariable, correlationValue) - .count(); - - retries--; - } + CallbackResult result = handleCallback(method, message, messageEventName, + messageVariable, correlationVariable, correlationValue, LOGMARKER, variables); - return waitingInstances != 0; - } - - private ProcessEngineServices getProcessEngineServices() { - if (pes4junit == null) { - return BpmPlatform.getDefaultProcessEngine(); + if (result instanceof CallbackError) { + return Response.status(500).entity(((CallbackError)result).getErrorMessage()).build(); } else { - return pes4junit; + return Response.status(204).build(); } } - - public void setProcessEngineServices4junit(ProcessEngineServices pes) { - pes4junit = pes; - } } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn index af615e379d..6f012bcb88 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetService.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -9,16 +9,16 @@ GenericGetService getService = new GenericGetService() getService.preProcessRequest(execution) ]]> - - + + SequenceFlow_2 getUrlYes getUrlNo - + - + SequenceFlow_7 @@ -28,12 +28,12 @@ getService.preProcessRequest(execution) ExceptionUtil ex = new ExceptionUtil() ex.processSubflowsBPMNException(execution)]]> - + SequenceFlow_7 - + - + SequenceFlow_8 @@ -46,43 +46,43 @@ GenericGetService getService = new GenericGetService() getService.setSuccessIndicator(execution, true) ]]> - - + + SequenceFlow_5 SequenceFlow_3 - + getUrlNo foundYes SequenceFlow_5 - - + + obtainById SequenceFlow_4 - - + + obtainByName SequenceFlow_13 - - + + getUrlYes obtainById obtainByName - + @@ -94,226 +94,226 @@ getService.obtainServiceInstanceUrlByName(execution)]]> - + notFound - + SequenceFlow_4 SequenceFlow_13 SequenceFlow_14 - + SequenceFlow_6 - + SequenceFlow_1 - + - + - + - + - - + + - + - + - + - - + + - + - + - + - + - + - - - + + + - + - - - + + + - + - - + + - + - - - - + + + + - + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - - - + + + - + - - - + + + - + - - - + + + - + - + - + - - + + - + - - + + - + - - + + - + - + - + diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy index 8a5f9e96cd..19d21275be 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtilTest.groovy @@ -1,305 +1,385 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.common.scripts; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.junit.Before -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith -import org.junit.Before; -import org.junit.Test; -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl -import org.camunda.bpm.engine.repository.ProcessDefinition - -@RunWith(MockitoJUnitRunner.class) -class AaiUtilTest extends MsoGroovyTest { - - @Test - public void testGetVersionDefault() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('8', version) - } - - @Test - public void testGetVersionResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('7', version) - } - - @Test - public void testGetVersionFlowSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - assertEquals('6', version) - } - - @Test(expected=java.lang.Exception.class) - public void testGetVersionNotDefined() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') - } - - @Test - public void testGetUriDefaultVersion() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetUriFlowAndResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v6/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetNetworkGenericVnfEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) - } - - @Test - public void testGetNetworkGenericVnfUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) - assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) - } - - @Test - public void testGetNetworkVpnBindingUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) - assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) - } - - @Test - public void testGetNetworkPolicyUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkPolicyUri(mockExecution) - assertEquals('/aai/v8/network/network-policies/network-policy', uri) - } - - @Test - public void testGetNetworkTableReferencesUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) - assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) - } - - @Test - public void testGetNetworkVceUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVceUri(mockExecution) - assertEquals('/aai/v8/network/vces/vce', uri) - } - - @Test - public void testGetNetworkL3NetworkUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetBusinessCustomerUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getBusinessCustomerUri(mockExecution) - assertEquals('/aai/v8/business/customers/customer', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureTenantUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) - } - - @Test - public void testGetSearchNodesQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) - assertEquals('/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchNodesQueryEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') - when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchGenericQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) - assertEquals('/aai/v8/search/generic-query', uri) - } - - @Test - public void testGetNamespaceFromUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v6', ns) - } - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.common.scripts; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import org.openecomp.mso.rest.HttpHeader +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.junit.Before +import org.openecomp.mso.bpmn.common.scripts.AaiUtil; +import org.junit.Rule; +import org.junit.Test +import org.junit.Ignore +import org.junit.runner.RunWith +import org.junit.Before; +import org.junit.Test; +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl +import org.camunda.bpm.engine.repository.ProcessDefinition + +@RunWith(MockitoJUnitRunner.class) +class AaiUtilTest extends MsoGroovyTest { + + @Test + public void testGetVersionDefault() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('8', version) + } + + @Test + public void testGetVersionResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('7', version) + } + + @Test + public void testGetVersionFlowSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + assertEquals('6', version) + } + + @Test(expected=java.lang.Exception.class) + public void testGetVersionNotDefined() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule') + } + + @Test + public void testGetUriDefaultVersion() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetUriFlowAndResourceSpecific() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getUri(mockExecution, 'l3-network') + assertEquals('/aai/v6/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetNetworkGenericVnfEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) + } + + @Test + public void testGetNetworkGenericVnfUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) + assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) + } + + @Test + public void testGetNetworkVpnBindingUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) + assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) + } + + @Test + public void testGetNetworkPolicyUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkPolicyUri(mockExecution) + assertEquals('/aai/v8/network/network-policies/network-policy', uri) + } + + @Test + public void testGetNetworkTableReferencesUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) + assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) + } + + @Test + public void testGetNetworkVceUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkVceUri(mockExecution) + assertEquals('/aai/v8/network/vces/vce', uri) + } + + @Test + public void testGetNetworkL3NetworkUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) + assertEquals('/aai/v8/network/l3-networks/l3-network', uri) + } + + @Test + public void testGetBusinessCustomerUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getBusinessCustomerUri(mockExecution) + assertEquals('/aai/v8/business/customers/customer', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureCloudRegionUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) + } + + @Test + public void testGetCloudInfrastructureTenantUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) + assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) + } + + @Test + public void testGetSearchNodesQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) + assertEquals('/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchNodesQueryEndpoint() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query') + when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) + assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) + } + + @Test + public void testGetSearchGenericQueryUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) + assertEquals('/aai/v8/search/generic-query', uri) + } + + @Test + public void testGetNamespaceFromUri() { + ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('6') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v6_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v6', ns) + } + + @Test + public void testGetNamespaceFromUri2() { + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v10', ns) + } + + @Test + public void testGetNamespaceFromUri3() { + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('100') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v100_l3_network_uri")).thenReturn('/aai/v100/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class + def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v100', ns) + } + + @Test + public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10') + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') + CreateAAIVfModule myproc = new CreateAAIVfModule() + AaiUtil aaiUtil = new AaiUtil(myproc) + def ns = aaiUtil.getNamespaceFromUri(mockExecution,'/aai/v10/search/generic-query') + assertEquals('http://org.openecomp.aai.inventory/v10', ns) + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java index f1a2d7b4e2..e2942c9db5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java @@ -1,136 +1,136 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.common; - -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.mso.bpmn.mock.FileUtil; - -/** - * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. - */ -public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { - - /** - * Test the happy path through the flow. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void happyPath() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2); - MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm"); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(200, responseCode.intValue()); - - logEnd(); - } - - /** - * Test the case where the GET to AAI returns a 404. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void badGet() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(404, responseCode.intValue()); - - logEnd(); - } - - /** - * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. - */ - @Test - @Deployment(resources = { - "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" - }) - public void badPut() throws IOException { - - logStart(); - - String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); - MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200); - - String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); - variables.put("mso-request-id", "999-99-9999"); - variables.put("isDebugLogEnabled","true"); - variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); - invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); - - Assert.assertTrue(isProcessEnded(businessKey)); - String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); - Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - System.out.println("Subflow response code: " + responseCode); - System.out.println("Subflow response: " + response); - Assert.assertEquals(404, responseCode.intValue()); - - logEnd(); - } -} - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.common; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. + */ +public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest { + + /** + * Test the happy path through the flow. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void happyPath() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2); + MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(200, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI returns a 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badGet() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } + + /** + * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404. + */ + @Test + @Deployment(resources = { + "subprocess/CreateAAIVfModuleVolumeGroup.bpmn" + }) + public void badPatch() throws IOException { + + logStart(); + + String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml"); + MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap(); + variables.put("mso-request-id", "999-99-9999"); + variables.put("isDebugLogEnabled","true"); + variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest); + invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables); + + Assert.assertTrue(isProcessEnded(businessKey)); + String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); + Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); + System.out.println("Subflow response code: " + responseCode); + System.out.println("Subflow response: " + response); + Assert.assertEquals(404, responseCode.intValue()); + + logEnd(); + } +} + diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java index 2af42db574..b73ad7ab1c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java @@ -1,505 +1,505 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - - -/** - * Unit Test for the GenericGetService Sub Flow - */ -public class GenericGetServiceTest extends WorkflowTest { - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance() throws Exception{ - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscription() throws Exception{ - - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - 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 variables = new HashMap(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - 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 variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ - - MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscription404() throws Exception{ - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404); - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertNotNull(response); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ - - MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceById404() throws Exception{ - - MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("404", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ - - MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " "); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ - MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); - - Map variables = new HashMap(); - setVariablesInstance(variables, "", "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - assertEquals("true", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("200", siUrlResponseCode); - assertEquals(null, workflowException); - } - - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ - - Map variables = new HashMap(); - setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ - - Map variables = new HashMap(); - setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]"; - - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ - - MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", obtainUrl); - assertEquals("false", byName); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); - - Map variables = new HashMap(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("false", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) - public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ - - MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); - - Map variables = new HashMap(); - setVariablesInstance(variables, null, "1604-MVM-26", null, null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); - String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrl"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); - String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("true", obtainUrl); - assertEquals("true", byName); - assertEquals("500", siUrlResponseCode); - assertEquals(expectedWorkflowException, workflowException); - } - - - private void setVariablesInstance(Map 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"); - } - - private void setVariablesSubscription(Map 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"); - } - - -} +/* + * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + */ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.openecomp.mso.bpmn.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; +import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500; + +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; + + +/** + * Unit Test for the GenericGetService Sub Flow + */ +public class GenericGetServiceTest extends WorkflowTest { + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance() throws Exception{ + MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription() throws Exception{ + + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + 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 variables = new HashMap(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + 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 variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("true", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstance_404Response() throws Exception{ + + MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscription404() throws Exception{ + MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404); + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertNotNull(response); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByName404() throws Exception{ + + MockNodeQueryServiceInstanceByName_404("1604-MVM-26"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceById404() throws Exception{ + + MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("404", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{ + + MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " "); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{ + MockNodeQueryServiceInstanceByName("1604-MVM-26", ""); + + Map variables = new HashMap(); + setVariablesInstance(variables, "", "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{ + + MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", ""); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + assertEquals("true", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("200", siUrlResponseCode); + assertEquals(null, workflowException); + } + + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{ + + Map variables = new HashMap(); + setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{ + + Map variables = new HashMap(); + setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]"; + + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{ + + MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789"); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("false", obtainUrl); + assertEquals("false", byName); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET"); + + Map variables = new HashMap(); + setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("false", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + @Test + @Deployment(resources = {"subprocess/GenericGetService.bpmn"}) + public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{ + + MockNodeQueryServiceInstanceByName_500("1604-MVM-26"); + + Map variables = new HashMap(); + setVariablesInstance(variables, null, "1604-MVM-26", null, null); + + WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables); + waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); + + String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator"); + String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator"); + String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException"); + String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl"); + String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName"); + String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode"); + + String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]"; + + assertEquals("false", successIndicator); + assertEquals("false", found); + assertEquals("true", obtainUrl); + assertEquals("true", byName); + assertEquals("500", siUrlResponseCode); + assertEquals(expectedWorkflowException, workflowException); + } + + + private void setVariablesInstance(Map 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"); + } + + private void setVariablesSubscription(Map 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"); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java index 6fe6df6e11..e2babb7919 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java @@ -20,10 +20,11 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -179,14 +180,15 @@ public class PrepareUpdateAAIVfModuleTest extends WorkflowTest { @Deployment(resources = { "subprocess/PrepareUpdateAAIVfModule.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml"); MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404); + String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); variables.put("mso-request-id", "999-99-9999"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java index 846a14f45f..3eb7acd91a 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java @@ -33,7 +33,6 @@ import java.util.Map; import javax.ws.rs.core.Response; -import org.camunda.bpm.engine.MismatchingMessageCorrelationException; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.test.Deployment; @@ -44,9 +43,10 @@ import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader; import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest; import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse; import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; -import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterExceptionResponse; +import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterErrorResponse; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup; import org.openecomp.mso.bpmn.mock.FileUtil; /** @@ -129,7 +129,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceFinished(pid); //System.out.println("SDNCAdapter sunny day flow Completed!"); @@ -167,7 +167,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceNotFinished(pid); checkForTimeout(pid); @@ -212,7 +212,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceNotFinished(pid); assertEquals(true, (Boolean) (getVariable(pid, "continueListening"))); @@ -221,7 +221,7 @@ public class SDNCAdapterV1Test extends WorkflowTest { sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertFalse(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); + assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); assertProcessInstanceFinished(pid); assertEquals(false, (Boolean) (getVariable(pid, "continueListening"))); @@ -241,10 +241,14 @@ public class SDNCAdapterV1Test extends WorkflowTest { @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn", "subprocess/GenericNotificationService.bpmn" }) - public void badCorrelationIdTest() throws InterruptedException { + public void badCorrelationIdTest() throws InterruptedException, IOException { mockSDNCAdapter(200); + Map urnProperties = PropertyConfigurationSetup.createBpmnUrnProperties(); + urnProperties.put("mso.correlation.timeout", "5"); + PropertyConfigurationSetup.addProperties(urnProperties, 10000); + //System.out.println("SDNCAdapter bad RequestId test Started!"); ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest); @@ -267,8 +271,8 @@ public class SDNCAdapterV1Test extends WorkflowTest { SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); //System.out.println("Back from executing process again"); - assertTrue(sdncAdapterResponse instanceof SDNCAdapterExceptionResponse); - assertTrue(((SDNCAdapterExceptionResponse) sdncAdapterResponse).getException() instanceof IllegalStateException); + assertTrue(sdncAdapterResponse instanceof SDNCAdapterErrorResponse); + assertTrue(((SDNCAdapterErrorResponse) sdncAdapterResponse).getError().contains("No process is waiting for sdncAdapterCallbackRequest")); assertProcessInstanceNotFinished(pid); //System.out.println("SDNCAdapter bad RequestId test Completed!"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java index 18fb5acbce..1573c8f757 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java @@ -20,11 +20,12 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -144,7 +145,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { @Deployment(resources = { "subprocess/UpdateAAIGenericVnf.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); @@ -152,6 +153,7 @@ public class UpdateAAIGenericVnfTest extends WorkflowTest { MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); MockPutGenericVnf_Bad("skask", 404); + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java index 035f097be2..d081fcc7f6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java @@ -20,11 +20,12 @@ package org.openecomp.mso.bpmn.common; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; import java.io.IOException; import java.util.HashMap; @@ -111,13 +112,14 @@ public class UpdateAAIVfModuleTest extends WorkflowTest { @Deployment(resources = { "subprocess/UpdateAAIVfModule.bpmn" }) - public void badPut() throws IOException { + public void badPatch() throws IOException { logStart(); String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml"); MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool"); MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200); + MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java index 46bbb72e56..49ad6d6e34 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java @@ -109,6 +109,16 @@ public class WorkflowTest { @Rule public final WireMockRule wireMockRule; + /** + * Content-Type for XML. + */ + protected static final String XML = "application/xml"; + + /** + * Content-Type for JSON. + */ + protected static final String JSON = "application/json; charset=UTF-8"; + /** * Constructor. */ @@ -197,15 +207,15 @@ public class WorkflowTest { * @param businessKey a unique key that will identify the process instance * @param injectedVariables variables to inject into the process */ - protected void invokeSubProcess(String processKey, String businessKey, - Map injectedVariables) { + protected void invokeSubProcess(String processKey, String businessKey, Map injectedVariables) { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List arguments = runtimeMxBean.getInputArguments(); System.out.println("JVM args = " + arguments); msoRequestId = (String) injectedVariables.get("mso-request-id"); + String requestId = (String) injectedVariables.get("msoRequestId"); - if (msoRequestId == null) { + if (msoRequestId == null && requestId == null) { String msg = "mso-request-id variable was not provided"; System.out.println(msg); fail(msg); @@ -242,7 +252,7 @@ public class WorkflowTest { * @param injectedVariables optional variables to inject into the process * @return a TestAsyncResponse object associated with the test */ - public TestAsyncResponse invokeAsyncProcess(String processKey, + protected TestAsyncResponse invokeAsyncProcess(String processKey, String schemaVersion, String businessKey, String request, Map injectedVariables) { @@ -438,7 +448,7 @@ public class WorkflowTest { * @param timeout the timeout in milliseconds * @return the WorkflowResponse */ - public WorkflowResponse receiveResponse(String businessKey, + protected WorkflowResponse receiveResponse(String businessKey, TestAsyncResponse asyncResponse, long timeout) { System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey + " to send a response"); @@ -512,24 +522,34 @@ public class WorkflowTest { } String content = null; + String contentType = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; System.out.println(msg); fail(msg); } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); } else if ("ERR".equals(modifier)) { content = "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}"; + contentType = JSON; } else { String msg = "Invalid SDNC program modifier: '" + modifier + "'"; System.out.println(msg); fail(msg); } - if (!injectSDNCRestCallback(content, 10000)) { + if (contentType == null) { + // Default for backward compatibility with existing tests. + contentType = JSON; + } + + if (!injectSDNCRestCallback(contentType, content, 10000)) { fail("Failed to inject SDNC '" + action + "' callback"); } @@ -548,67 +568,14 @@ public class WorkflowTest { *
 	 *     event1, event2
 	 * 
+ * NOTE: Each callback must have a message type associated with it, e.g. + * "SDNCAEvent". * Errors are handled with junit assertions and will cause the test to fail. - * Defaults the Event Type to "SDNCAEvent" for backward compatibility. * @param callbacks an object containing event data for the program * @param program the program to execute */ protected void injectSDNCEvents(CallbackSet callbacks, String program) { - injectSDNCEvents(callbacks, program, "SDNCAEvent"); - } - - /** - * Runs a program to inject SDNC events into the test environment. - * A program is essentially just a list of keys that identify event data - * to be injected, in sequence. An example program: - *
-	 *     event1, event2
-	 * 
- * Errors are handled with junit assertions and will cause the test to fail. - * @param callbacks an object containing event data for the program - * @param program the program to execute - * @param eventType (i.e. "SDNCAEvent", "SNIROResponse", etc.) - */ - protected void injectSDNCEvents(CallbackSet callbacks, String program, String eventType) { - - String[] cmds = program.replaceAll("\\s+", "").split(","); - - for (String cmd : cmds) { - String action = cmd; - String modifier = "STD"; - - if (cmd.contains(":")) { - String[] parts = cmd.split(":"); - action = parts[0]; - modifier = parts[1]; - } - - String content = null; - - if ("STD".equals(modifier)) { - content = callbacks.get(action); - - if (content == null) { - String msg = "No SDNC event callback defined for '" + action + "'"; - System.out.println(msg); - fail(msg); - } - } else { - String msg = "Invalid SDNC program modifier: '" + modifier + "'"; - System.out.println(msg); - fail(msg); - } - - if (!injectWorkflowMessage(eventType, content, 10000)) { - fail("Failed to inject SDNC '" + action + "' event"); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - fail("Interrupted after injection of SDNC '" + action + "' event"); - } - } + injectWorkflowMessages(callbacks, program); } /** @@ -622,7 +589,7 @@ public class WorkflowTest { * @param callbacks an object containing callback data for the program * @param program the program to execute */ - public void injectSDNCCallbacks(CallbackSet callbacks, String program) { + protected void injectSDNCCallbacks(CallbackSet callbacks, String program) { String[] cmds = program.replaceAll("\\s+", "").split(","); @@ -641,14 +608,15 @@ public class WorkflowTest { String respMsg = "OK"; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; System.out.println(msg); fail(msg); } + content = callbackData.getContent(); respCode = 200; respMsg = "OK"; } else if ("ERR".equals(modifier)) { @@ -684,7 +652,7 @@ public class WorkflowTest { * @param callbacks an object containing callback data for the program * @param program the program to execute */ - public void injectVNFRestCallbacks(CallbackSet callbacks, String program) { + protected void injectVNFRestCallbacks(CallbackSet callbacks, String program) { String[] cmds = program.replaceAll("\\s+", "").split(","); @@ -699,24 +667,34 @@ public class WorkflowTest { } String content = null; + String contentType = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF REST request"; System.out.println(msg); fail(msg); } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); } else if ("ERR".equals(modifier)) { content = "SIMULATED ERROR FROM VNF ADAPTER"; + contentType = "text/plain"; } else { String msg = "Invalid VNF REST program modifier: '" + modifier + "'"; System.out.println(msg); fail(msg); } - if (!injectVnfAdapterRestCallback(content, 10000)) { + if (contentType == null) { + // Default for backward compatibility with existing tests. + contentType = XML; + } + + if (!injectVnfAdapterRestCallback(contentType, content, 10000)) { fail("Failed to inject VNF REST '" + action + "' callback"); } @@ -756,14 +734,15 @@ public class WorkflowTest { String content = null; if ("STD".equals(modifier)) { - content = callbacks.get(action); + CallbackData callbackData = callbacks.get(action); - if (content == null) { + if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF request"; System.out.println(msg); fail(msg); } + content = callbackData.getContent(); } else if ("ERR".equals(modifier)) { String msg = "Currently unsupported VNF program modifier: '" + modifier + "'"; System.out.println(msg); @@ -805,7 +784,7 @@ public class WorkflowTest { * @param count the desired count * @param timeout the timeout in milliseconds */ - public void waitForRunningProcessCount(String processKey, int count, long timeout) { + protected void waitForRunningProcessCount(String processKey, int count, long timeout) { System.out.println("Waiting " + timeout + "ms for there to be " + count + " " + processKey + " instances"); @@ -916,11 +895,12 @@ public class WorkflowTest { * may contain the placeholder string ((REQUEST-ID)) which is replaced with * the actual SDNC request ID. Note: this is not the requestId in the original * MSO request. + * @param contentType the HTTP content type for the callback * @param content the content of the callback * @param timeout the timeout in milliseconds * @return true if the callback could be injected, false otherwise */ - protected boolean injectSDNCRestCallback(String content, long timeout) { + protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) { String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1", "SDNCAResponse_CORRELATOR", timeout); @@ -935,7 +915,7 @@ public class WorkflowTest { System.out.println("Injecting SDNC adapter callback"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver("SDNCAResponse", sdncRequestId, content); + Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content); System.out.println("Workflow response to SDNC adapter callback: " + response); return true; } @@ -986,11 +966,12 @@ public class WorkflowTest { * may contain the placeholder string ((MESSAGE-ID)) which is replaced with * the actual message ID. Note: this is not the requestId in the original * MSO request. + * @param contentType the HTTP content type for the callback * @param content the content of the callback * @param timeout the timeout in milliseconds * @return true if the callback could be injected, false otherwise */ - protected boolean injectVnfAdapterRestCallback(String content, long timeout) { + protected boolean injectVnfAdapterRestCallback(String contentType, String content, long timeout) { String messageId = (String) getProcessVariable("vnfAdapterRestV1", "VNFAResponse_CORRELATOR", timeout); @@ -1005,7 +986,7 @@ public class WorkflowTest { System.out.println("Injecting VNF adapter callback"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver("VNFAResponse", messageId, content); + Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content); System.out.println("Workflow response to VNF adapter callback: " + response); return true; } @@ -1307,16 +1288,84 @@ public class WorkflowTest { return true; } + /** + * Runs a program to inject workflow messages into the test environment. + * A program is essentially just a list of keys that identify event data + * to be injected, in sequence. An example program: + *
+	 *     event1, event2
+	 * 
+ * Errors are handled with junit assertions and will cause the test to fail. + * NOTE: Each callback must have a workflow message type associated with it. + * @param callbacks an object containing event data for the program + * @param program the program to execute + */ + protected void injectWorkflowMessages(CallbackSet callbacks, String program) { + + String[] cmds = program.replaceAll("\\s+", "").split(","); + + for (String cmd : cmds) { + String action = cmd; + String modifier = "STD"; + + if (cmd.contains(":")) { + String[] parts = cmd.split(":"); + action = parts[0]; + modifier = parts[1]; + } + + String messageType = null; + String content = null; + String contentType = null; + + if ("STD".equals(modifier)) { + CallbackData callbackData = callbacks.get(action); + + if (callbackData == null) { + String msg = "No '" + action + "' workflow message callback is defined"; + System.out.println(msg); + fail(msg); + } + + messageType = callbackData.getMessageType(); + + if (messageType == null || messageType.trim().equals("")) { + String msg = "No workflow message type is defined in the '" + action + "' callback"; + System.out.println(msg); + fail(msg); + } + + content = callbackData.getContent(); + contentType = callbackData.getContentType(); + } else { + String msg = "Invalid workflow message program modifier: '" + modifier + "'"; + System.out.println(msg); + fail(msg); + } + + if (!injectWorkflowMessage(contentType, messageType, content, 10000)) { + fail("Failed to inject '" + action + "' workflow message"); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + fail("Interrupted after injection of '" + action + "' workflow message"); + } + } + } + /** * Injects a workflow message. The specified callback data may contain the * placeholder string ((CORRELATOR)) which is replaced with the actual * correlator value. - * @param content the message type - * @param content the message content + * @param contentType the HTTP contentType for the message (possibly null) + * @param messageType the message type + * @param content the message content (possibly null) * @param timeout the timeout in milliseconds - * @return true if the event could be injected, false otherwise + * @return true if the message could be injected, false otherwise */ - protected boolean injectWorkflowMessage(String messageType, String content, long timeout) { + protected boolean injectWorkflowMessage(String contentType, String messageType, String content, long timeout) { String correlator = (String) getProcessVariable("ReceiveWorkflowMessage", messageType + "_CORRELATOR", timeout); @@ -1324,12 +1373,14 @@ public class WorkflowTest { return false; } - content = content.replace("((CORRELATOR))", correlator); + if (content != null) { + content = content.replace("((CORRELATOR))", correlator); + } System.out.println("Injecting " + messageType + " message"); WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource(); workflowMessageResource.setProcessEngineServices4junit(processEngineRule); - Response response = workflowMessageResource.deliver(messageType, correlator, content); + Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content); System.out.println("Workflow response to " + messageType + " message: " + response); return true; } @@ -1339,7 +1390,7 @@ public class WorkflowTest { * @param businessKey the process business key * @param timeout the amount of time to wait, in milliseconds */ - public void waitForProcessEnd(String businessKey, long timeout) { + protected void waitForProcessEnd(String businessKey, long timeout) { System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey + " to end"); @@ -1377,7 +1428,7 @@ public class WorkflowTest { * @param variable the variable name * @param value the expected variable value */ - public void checkVariable(String businessKey, String variable, Object value) { + protected void checkVariable(String businessKey, String variable, Object value) { if (!isProcessEnded(businessKey)) { fail("Cannot get historic variable " + variable + " because process with business key " + businessKey + " has not ended"); @@ -1405,7 +1456,7 @@ public class WorkflowTest { * @return the variable value, or null if the variable could not be * obtained */ - public Object getVariableFromHistory(String businessKey, String variableName) { + protected Object getVariableFromHistory(String businessKey, String variableName) { try { HistoricProcessInstance processInstance = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult(); @@ -1426,6 +1477,8 @@ public class WorkflowTest { } /** + * @author cb645j + * * Gets the value of a subflow variable from the specified subflow's * historical process instance. * @@ -1440,6 +1493,10 @@ public class WorkflowTest { List processInstanceList = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + if (processInstanceList == null) { + return null; + } + Collections.sort(processInstanceList, new Comparator() { public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { return m1.getStartTime().compareTo(m2.getStartTime()); @@ -1448,10 +1505,6 @@ public class WorkflowTest { HistoricProcessInstance processInstance = processInstanceList.get(0); - if (processInstanceList == null) { - return null; - } - HistoricVariableInstance v = processEngineRule.getHistoryService() .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) .variableName(variableName).singleResult(); @@ -1464,6 +1517,8 @@ public class WorkflowTest { } /** + * @author cb645j + * * Gets the value of a subflow variable from the subflow's * historical process x instance. * @@ -1478,6 +1533,10 @@ public class WorkflowTest { List processInstanceList = processEngineRule.getHistoryService() .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list(); + if (processInstanceList == null) { + return null; + } + Collections.sort(processInstanceList, new Comparator() { public int compare(HistoricProcessInstance m1, HistoricProcessInstance m2) { return m1.getStartTime().compareTo(m2.getStartTime()); @@ -1486,10 +1545,6 @@ public class WorkflowTest { HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex); - if (processInstanceList == null) { - return null; - } - HistoricVariableInstance v = processEngineRule.getHistoryService() .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()) .variableName(variableName).singleResult(); @@ -1594,15 +1649,36 @@ public class WorkflowTest { * An object that contains callback data for a "program". */ public class CallbackSet { - private final Map map = new HashMap(); + private final Map map = new HashMap(); /** - * Add callback data to the set. + * Add untyped callback data to the set. * @param action the action with which the data is associated * @param content the callback data */ public void put(String action, String content) { - map.put(action, content); + map.put(action, new CallbackData(null, null, content)); + } + + /** + * Add callback data to the set. + * @param action the action with which the data is associated + * @param messageType the callback message type + * @param content the callback data + */ + public void put(String action, String messageType, String content) { + map.put(action, new CallbackData(null, messageType, content)); + } + + /** + * Add callback data to the set. + * @param action the action with which the data is associated + * @param contentType the callback HTTP content type + * @param messageType the callback message type + * @param content the callback data + */ + public void put(String action, String contentType, String messageType, String content) { + map.put(action, new CallbackData(contentType, messageType, content)); } /** @@ -1610,11 +1686,53 @@ public class WorkflowTest { * @param action the action with which the data is associated * @return the callback data, or null if there is none for the specified operation */ - public String get(String action) { + public CallbackData get(String action) { return map.get(action); } } + /** + * Represents a callback data item. + */ + public class CallbackData { + private final String contentType; + private final String messageType; + private final String content; + + /** + * Constructor + * @param contentType the HTTP content type (optional) + * @param type the callback message type (optional) + * @param content the content + */ + public CallbackData(String contentType, String messageType, String content) { + this.contentType = contentType; + this.messageType = messageType; + this.content = content; + } + + /** + * Gets the callback HTTP content type, possibly null. + */ + public String getContentType() { + return contentType; + } + + /** + * Gets the callback message type, possibly null. + */ + public String getMessageType() { + return messageType; + } + + /** + * Gets the callback content. + */ + public String getContent() { + return content; + } + } + /** * A tool for evaluating XPath expressions. */ @@ -1772,7 +1890,7 @@ public class WorkflowTest { * Helper class to make it easier to create this type. */ private static class CreateVnfNotificationOutputs - extends org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs { + extends CreateVnfNotification.Outputs { public void add(String key, String value) { Entry entry = new Entry(); entry.setKey(key); @@ -1785,7 +1903,7 @@ public class WorkflowTest { * Helper class to make it easier to create this type. */ private static class UpdateVnfNotificationOutputs - extends org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs { + extends UpdateVnfNotification.Outputs { public void add(String key, String value) { Entry entry = new Entry(); entry.setKey(key); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql index 10e9930720..6ebc6e221e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/drop_mariadb_engine_7.5.6.sql @@ -1,76 +1,75 @@ --- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- -use camundabpmn; -/* -Drop a archive tables -*/ -/*-- TMP_ARCHIVING_PROCINST */ -DROP TABLE IF EXISTS TMP_ARCHIVING_PROCINST; - -/*-- TMP_ARCHIVING_BYTEARRAY */ -DROP TABLE IF EXISTS TMP_ARCHIVING_BYTEARRAY; - -/*-- TMP LOG TABLE */ -DROP TABLE IF EXISTS TMPLOGTABLE; - -/* -- Camunda Hi Tables --*/ -DROP TABLE IF EXISTS Camunda_Hi_Tables; - -/* drop own extentions columns: -alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_VARINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_DETAIL DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); -*/ - -/*--#1 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_PROCINST; -/*--#2 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ACTINST; -/*--#3 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_TASKINST; -/*--#4 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_VARINST; -/*--#5 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_DETAIL; -/*--#6 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_COMMENT; -/*--#7 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ATTACHMENT; -/*--#8 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_OP_LOG; -/*--#9 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_HI_INCIDENT; -/*--#10 */ -DROP TABLE IF EXISTS ARCHIVE_ACT_GE_BYTEARRAY; - -/* drop PL SQL procedures: */ -DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; -DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; - -/*-- Sequence */ --- as sequence drop doesn't work automatically in MariaDB, use this procedure to drop sequence - DROP PROCEDURE IF EXISTS DropSequence; - - DELIMITER // - - CREATE PROCEDURE DropSequence (vname VARCHAR(30)) - BEGIN - -- Drop the sequence - DELETE FROM _sequences WHERE name = vname; - END - // - DELIMITER ; - --- use the above procedure to drop sequence -CALL DropSequence('STAT_EXECUTION_SEQ'); - -/*-- To Drop the MariaDB specific user defined procedures and functions */ -DROP FUNCTION IF EXISTS NextVal; -DROP PROCEDURE IF EXISTS CreateSequence; -DROP PROCEDURE IF EXISTS DropSequence; +use camundabpmn; +/* +Drop a archive tables +*/ +/*-- TMP_ARCHIVING_PROCINST */ +DROP TABLE IF EXISTS TMP_ARCHIVING_PROCINST; + +/*-- TMP_ARCHIVING_BYTEARRAY */ +DROP TABLE IF EXISTS TMP_ARCHIVING_BYTEARRAY; + +/*-- TMP LOG TABLE */ +DROP TABLE IF EXISTS TMPLOGTABLE; + +/* -- Camunda Hi Tables --*/ +DROP TABLE IF EXISTS Camunda_Hi_Tables; + +/* drop own extentions columns: +alter table ARCHIVE_ACT_HI_PROCINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ACTINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_TASKINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_VARINST DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_DETAIL DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_COMMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_ATTACHMENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_OP_LOG DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +alter table ARCHIVE_ACT_HI_INCIDENT DROP (STAT_EXECUTION_ID, STAT_EXECUTION_TS); +*/ + +/*--#1 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_PROCINST; +/*--#2 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ACTINST; +/*--#3 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_TASKINST; +/*--#4 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_VARINST; +/*--#5 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_DETAIL; +/*--#6 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_COMMENT; +/*--#7 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_ATTACHMENT; +/*--#8 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_OP_LOG; +/*--#9 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_HI_INCIDENT; +/*--#10 */ +DROP TABLE IF EXISTS ARCHIVE_ACT_GE_BYTEARRAY; + +/* drop PL SQL procedures: */ +DROP PROCEDURE IF EXISTS ARCHIVE_CAMUNDA_HISTORY; +DROP PROCEDURE IF EXISTS ROLLB_ARCHIVE_CAMUNDA_HISTORY; + +/*-- Sequence */ +-- as sequence drop doesn't work automatically in MariaDB, use this procedure to drop sequence + DROP PROCEDURE IF EXISTS DropSequence; + + DELIMITER // + + CREATE PROCEDURE DropSequence (vname VARCHAR(30)) + BEGIN + -- Drop the sequence + DELETE FROM _sequences WHERE name = vname; + END + // + DELIMITER ; + +-- use the above procedure to drop sequence +CALL DropSequence('STAT_EXECUTION_SEQ'); + +/*-- To Drop the MariaDB specific user defined procedures and functions */ +DROP FUNCTION IF EXISTS NextVal; +DROP PROCEDURE IF EXISTS CreateSequence; +DROP PROCEDURE IF EXISTS DropSequence; DROP TABLE IF EXISTS _sequences; \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql index 8c7faa0792..c5b69c7a34 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/CamundaDBScripts/Archive/mariadb_engine_7.5_patch_7.5.6.sql @@ -1,222 +1,221 @@ --- Fix for https://itrack.web.att.com/browse/AJSCCMDA-90 -- -use camundabpmn; -/* - 1. Add some Camunda Indexes to history schema part (for Archiving) -*/ -create INDEX IF NOT EXISTS IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_); -create INDEX IF NOT EXISTS IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_); - - -/* - 2. Create Archiving Tables in current schema -*/ - -/*-- TMP_ARCHIVING_PROCINST */ -CREATE TABLE TMP_ARCHIVING_PROCINST -( PROC_INST_ID_ varchar(64) not null, - END_TIME_ datetime(3) -); -CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_); - -/*-- TMP_ARCHIVING_BYTEARRAY */ -CREATE TABLE TMP_ARCHIVING_BYTEARRAY -( BYTEARRAY_ID_ varchar(64) not null, - PROC_INST_ID_ varchar(64) -); -CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_); - - -/*--#1 ARCHIVE_ACT_HI_PROCINST; */ -create TABLE ARCHIVE_ACT_HI_PROCINST -AS ( select * from ACT_HI_PROCINST where 1=0); - -create index AI_HI_PROCINST_END_TIME on ARCHIVE_ACT_HI_PROCINST(END_TIME_); -ALTER TABLE ARCHIVE_ACT_HI_PROCINST ADD CONSTRAINT ARCHIVE_ACT_HI_PROCINST_UQ UNIQUE ( PROC_INST_ID_); - -/*--#2 ARCHIVE_ACT_HI_ACTINST; */ -create TABLE ARCHIVE_ACT_HI_ACTINST -AS ( select * from ACT_HI_ACTINST where 1=0); - -create index AI_HI_ACTINST_PROC_INST_ID on ARCHIVE_ACT_HI_ACTINST(PROC_INST_ID_); -create index AI_HI_ACTINST_END_TIME on ARCHIVE_ACT_HI_ACTINST(END_TIME_); - -/*--#3 ARCHIVE_ACT_HI_TASKINST; */ -create TABLE ARCHIVE_ACT_HI_TASKINST -AS ( select * from ACT_HI_TASKINST where 1=0); - -create index AI_HI_TASKINST_PROC_INST_ID on ARCHIVE_ACT_HI_TASKINST(PROC_INST_ID_); -create index AI_HI_TASKINST_END_TIME on ARCHIVE_ACT_HI_TASKINST(END_TIME_); - -/*--#4 ARCHIVE_ACT_HI_VARINST; */ -create TABLE ARCHIVE_ACT_HI_VARINST -AS ( select * from ACT_HI_VARINST where 1=0); - -create index AI_HI_VARINST_PROC_INST_ID on ARCHIVE_ACT_HI_VARINST(PROC_INST_ID_); - -/*--#5 ARCHIVE_ACT_HI_DETAIL; */ -create TABLE ARCHIVE_ACT_HI_DETAIL -AS ( select * from ACT_HI_DETAIL where 1=0); - -create index AI_HI_DETAIL_PROC_INST_ID on ARCHIVE_ACT_HI_DETAIL(PROC_INST_ID_); -create index AI_HI_DETAIL_TIME on ARCHIVE_ACT_HI_DETAIL(TIME_); - -/*--#6 ARCHIVE_ACT_HI_COMMENT; */ -create TABLE ARCHIVE_ACT_HI_COMMENT -AS ( select * from ACT_HI_COMMENT where 1=0); - -create index AI_HI_COMMENT_PROC_INST_ID on ARCHIVE_ACT_HI_COMMENT(PROC_INST_ID_); -create index AI_HI_COMMENT_TIME on ARCHIVE_ACT_HI_COMMENT(TIME_); - -/*--#7 ARCHIVE_ACT_HI_ATTACHMENT; */ -create TABLE ARCHIVE_ACT_HI_ATTACHMENT -AS ( select * from ACT_HI_ATTACHMENT where 1=0); - -create index AI_HI_ATTACHMENT_PROC_INST_ID on ARCHIVE_ACT_HI_ATTACHMENT(PROC_INST_ID_); - -/*--#8 ARCHIVE_ACT_HI_OP_LOG; */ -create TABLE ARCHIVE_ACT_HI_OP_LOG -AS ( select * from ACT_HI_OP_LOG where 1=0); - -create index AI_HI_OP_LOG_PROC_INST_ID on ARCHIVE_ACT_HI_OP_LOG(PROC_INST_ID_); -create index AI_HI_OP_LOG_TIMESTAMP on ARCHIVE_ACT_HI_OP_LOG(TIMESTAMP_); - -/*--#9 ARCHIVE_ACT_HI_INCIDENT; */ -create TABLE ARCHIVE_ACT_HI_INCIDENT -AS ( select * from ACT_HI_INCIDENT where 1=0); - -create index AI_HI_INCIDENT_PROC_INST_ID on ARCHIVE_ACT_HI_INCIDENT(PROC_INST_ID_); - -/*--#10 ARCHIVE_ACT_GE_BYTEARRAY; */ -create TABLE ARCHIVE_ACT_GE_BYTEARRAY -AS ( select * from ACT_GE_BYTEARRAY where 1=0); - -create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_); - -/* ----------------------------------------------------------------------------- -Extend a ARCHIVE: Table by two attributes: STAT_EXECUTION_ID, STAT_EXECUTION_TS -*/ - -/* ---TEMPLATE: -alter table ARCHIVE_%TableName% - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_%TableName%_EXE_ID ON ARCHIVE_%TableName%(STAT_EXECUTION_ID); -*/ - - -/*--#1 ACT_HI_PROCINST */ -alter table ARCHIVE_ACT_HI_PROCINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_PROCINST_EXE_ID ON ARCHIVE_ACT_HI_PROCINST(STAT_EXECUTION_ID); - -/*--#2 ACT_HI_ACTINST */ -alter table ARCHIVE_ACT_HI_ACTINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_ACTINST_EXE_ID ON ARCHIVE_ACT_HI_ACTINST(STAT_EXECUTION_ID); - -/*--#3 ACT_HI_TASKINST */ -alter table ARCHIVE_ACT_HI_TASKINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_TASKINST_EXE_ID ON ARCHIVE_ACT_HI_TASKINST(STAT_EXECUTION_ID); - -/*--#4 ACT_HI_VARINST */ -alter table ARCHIVE_ACT_HI_VARINST - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_VARINST_EXE_ID ON ARCHIVE_ACT_HI_VARINST(STAT_EXECUTION_ID); - -/*--#5 ACT_HI_DETAIL */ -alter table ARCHIVE_ACT_HI_DETAIL - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_DETAIL_EXE_ID ON ARCHIVE_ACT_HI_DETAIL(STAT_EXECUTION_ID); - -/*--#6 ACT_HI_COMMENT */ -alter table ARCHIVE_ACT_HI_COMMENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_COMMENT_EXE_ID ON ARCHIVE_ACT_HI_COMMENT(STAT_EXECUTION_ID); - -/*--#7 ACT_HI_ATTACHMENT */ -alter table ARCHIVE_ACT_HI_ATTACHMENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_ATTACHMENT_EXE_ID ON ARCHIVE_ACT_HI_ATTACHMENT(STAT_EXECUTION_ID); - -/*--#8 ACT_HI_OP_LOG */ -alter table ARCHIVE_ACT_HI_OP_LOG - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_OP_LOG_EXE_ID ON ARCHIVE_ACT_HI_OP_LOG(STAT_EXECUTION_ID); - -/*--#9 ACT_HI_INCIDENT */ -alter table ARCHIVE_ACT_HI_INCIDENT - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_HI_INCIDENT_EXE_ID ON ARCHIVE_ACT_HI_INCIDENT(STAT_EXECUTION_ID); - -/*--#10 ACT_GE_BYTEARRAY */ -alter table ARCHIVE_ACT_GE_BYTEARRAY - add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID); - - -/* -- Next Val as a user defined function needed only in MariaDB--*/ -DROP FUNCTION IF EXISTS NextVal; - DELIMITER // - CREATE FUNCTION NextVal (vname VARCHAR(30)) - RETURNS INT - BEGIN - -- Retrieve and update in single statement - UPDATE _sequences - SET next = next + 1 - WHERE name = vname; - - RETURN (SELECT next FROM _sequences LIMIT 1); - END - // - DELIMITER ; - -/* -- History tables for use in archive procedure, there is no array type in MariaDB --*/ -Create Table Camunda_Hi_Tables (id_ MEDIUMINT NOT NULL AUTO_INCREMENT, - TableName_ varchar(80) NOT NULL, - PRIMARY KEY (id_)); - -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_PROCINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ACTINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_TASKINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_VARINST'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_DETAIL'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_COMMENT'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ATTACHMENT'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_OP_LOG'); -Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_INCIDENT'); - -/*-- log table --*/ -CREATE TABLE TMPLOGTABLE (LogMessage Varchar(700)); - - -/* -- Below user defined functions and procedures needed only in MariaDB, they are in-built in Oracle --*/ -/*-- Create a sequence SP */ -DROP PROCEDURE IF EXISTS CreateSequence; - DELIMITER // - CREATE PROCEDURE CreateSequence (name VARCHAR(30), start INT, inc INT) - BEGIN - -- Create a table to store sequences - CREATE TABLE IF NOT EXISTS _sequences - ( - name VARCHAR(70) NOT NULL UNIQUE, - next INT NOT NULL, - inc INT NOT NULL - ); - - -- Add the new sequence - INSERT INTO _sequences VALUES (name, start, inc); - END - // - DELIMITER ; - -/*-------------------------------------------------------------------------------------------------- - Add Meta to Archive - -------------------------------------------------------------------------------------------------- */ - -/* Create STAT_EXECUTION_SEQ: each Archive Entry has a same Execution ID during one Archiving Run */ -CALL CreateSequence('STAT_EXECUTION_SEQ', 1, 1); +use camundabpmn; +/* + 1. Add some Camunda Indexes to history schema part (for Archiving) +*/ +create INDEX IF NOT EXISTS IDX_ACT_HI_TASKINST_PIID ON ACT_HI_TASKINST (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_COMMENT_PIID ON ACT_HI_COMMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ATTACHMENT_PIID ON ACT_HI_ATTACHMENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_OP_LOG_PIID ON ACT_HI_OP_LOG (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_INCIDENT_PIID ON ACT_HI_INCIDENT (PROC_INST_ID_); +create INDEX IF NOT EXISTS IDX_ACT_HI_ACTINST_PIID ON ACT_HI_ACTINST(PROC_INST_ID_); + + +/* + 2. Create Archiving Tables in current schema +*/ + +/*-- TMP_ARCHIVING_PROCINST */ +CREATE TABLE TMP_ARCHIVING_PROCINST +( PROC_INST_ID_ varchar(64) not null, + END_TIME_ datetime(3) +); +CREATE INDEX AI_TMP_ARCH_PROCINST_PI_ID ON TMP_ARCHIVING_PROCINST(PROC_INST_ID_); + +/*-- TMP_ARCHIVING_BYTEARRAY */ +CREATE TABLE TMP_ARCHIVING_BYTEARRAY +( BYTEARRAY_ID_ varchar(64) not null, + PROC_INST_ID_ varchar(64) +); +CREATE INDEX AI_TMP_ARCH_BYTEARRAY_BAID ON TMP_ARCHIVING_BYTEARRAY(BYTEARRAY_ID_); + + +/*--#1 ARCHIVE_ACT_HI_PROCINST; */ +create TABLE ARCHIVE_ACT_HI_PROCINST +AS ( select * from ACT_HI_PROCINST where 1=0); + +create index AI_HI_PROCINST_END_TIME on ARCHIVE_ACT_HI_PROCINST(END_TIME_); +ALTER TABLE ARCHIVE_ACT_HI_PROCINST ADD CONSTRAINT ARCHIVE_ACT_HI_PROCINST_UQ UNIQUE ( PROC_INST_ID_); + +/*--#2 ARCHIVE_ACT_HI_ACTINST; */ +create TABLE ARCHIVE_ACT_HI_ACTINST +AS ( select * from ACT_HI_ACTINST where 1=0); + +create index AI_HI_ACTINST_PROC_INST_ID on ARCHIVE_ACT_HI_ACTINST(PROC_INST_ID_); +create index AI_HI_ACTINST_END_TIME on ARCHIVE_ACT_HI_ACTINST(END_TIME_); + +/*--#3 ARCHIVE_ACT_HI_TASKINST; */ +create TABLE ARCHIVE_ACT_HI_TASKINST +AS ( select * from ACT_HI_TASKINST where 1=0); + +create index AI_HI_TASKINST_PROC_INST_ID on ARCHIVE_ACT_HI_TASKINST(PROC_INST_ID_); +create index AI_HI_TASKINST_END_TIME on ARCHIVE_ACT_HI_TASKINST(END_TIME_); + +/*--#4 ARCHIVE_ACT_HI_VARINST; */ +create TABLE ARCHIVE_ACT_HI_VARINST +AS ( select * from ACT_HI_VARINST where 1=0); + +create index AI_HI_VARINST_PROC_INST_ID on ARCHIVE_ACT_HI_VARINST(PROC_INST_ID_); + +/*--#5 ARCHIVE_ACT_HI_DETAIL; */ +create TABLE ARCHIVE_ACT_HI_DETAIL +AS ( select * from ACT_HI_DETAIL where 1=0); + +create index AI_HI_DETAIL_PROC_INST_ID on ARCHIVE_ACT_HI_DETAIL(PROC_INST_ID_); +create index AI_HI_DETAIL_TIME on ARCHIVE_ACT_HI_DETAIL(TIME_); + +/*--#6 ARCHIVE_ACT_HI_COMMENT; */ +create TABLE ARCHIVE_ACT_HI_COMMENT +AS ( select * from ACT_HI_COMMENT where 1=0); + +create index AI_HI_COMMENT_PROC_INST_ID on ARCHIVE_ACT_HI_COMMENT(PROC_INST_ID_); +create index AI_HI_COMMENT_TIME on ARCHIVE_ACT_HI_COMMENT(TIME_); + +/*--#7 ARCHIVE_ACT_HI_ATTACHMENT; */ +create TABLE ARCHIVE_ACT_HI_ATTACHMENT +AS ( select * from ACT_HI_ATTACHMENT where 1=0); + +create index AI_HI_ATTACHMENT_PROC_INST_ID on ARCHIVE_ACT_HI_ATTACHMENT(PROC_INST_ID_); + +/*--#8 ARCHIVE_ACT_HI_OP_LOG; */ +create TABLE ARCHIVE_ACT_HI_OP_LOG +AS ( select * from ACT_HI_OP_LOG where 1=0); + +create index AI_HI_OP_LOG_PROC_INST_ID on ARCHIVE_ACT_HI_OP_LOG(PROC_INST_ID_); +create index AI_HI_OP_LOG_TIMESTAMP on ARCHIVE_ACT_HI_OP_LOG(TIMESTAMP_); + +/*--#9 ARCHIVE_ACT_HI_INCIDENT; */ +create TABLE ARCHIVE_ACT_HI_INCIDENT +AS ( select * from ACT_HI_INCIDENT where 1=0); + +create index AI_HI_INCIDENT_PROC_INST_ID on ARCHIVE_ACT_HI_INCIDENT(PROC_INST_ID_); + +/*--#10 ARCHIVE_ACT_GE_BYTEARRAY; */ +create TABLE ARCHIVE_ACT_GE_BYTEARRAY +AS ( select * from ACT_GE_BYTEARRAY where 1=0); + +create index AI_GE_BYTEARRAY_ID_ on ARCHIVE_ACT_GE_BYTEARRAY(ID_); + +/* ----------------------------------------------------------------------------- +Extend a ARCHIVE: Table by two attributes: STAT_EXECUTION_ID, STAT_EXECUTION_TS +*/ + +/* +--TEMPLATE: +alter table ARCHIVE_%TableName% + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_%TableName%_EXE_ID ON ARCHIVE_%TableName%(STAT_EXECUTION_ID); +*/ + + +/*--#1 ACT_HI_PROCINST */ +alter table ARCHIVE_ACT_HI_PROCINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_PROCINST_EXE_ID ON ARCHIVE_ACT_HI_PROCINST(STAT_EXECUTION_ID); + +/*--#2 ACT_HI_ACTINST */ +alter table ARCHIVE_ACT_HI_ACTINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ACTINST_EXE_ID ON ARCHIVE_ACT_HI_ACTINST(STAT_EXECUTION_ID); + +/*--#3 ACT_HI_TASKINST */ +alter table ARCHIVE_ACT_HI_TASKINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_TASKINST_EXE_ID ON ARCHIVE_ACT_HI_TASKINST(STAT_EXECUTION_ID); + +/*--#4 ACT_HI_VARINST */ +alter table ARCHIVE_ACT_HI_VARINST + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_VARINST_EXE_ID ON ARCHIVE_ACT_HI_VARINST(STAT_EXECUTION_ID); + +/*--#5 ACT_HI_DETAIL */ +alter table ARCHIVE_ACT_HI_DETAIL + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_DETAIL_EXE_ID ON ARCHIVE_ACT_HI_DETAIL(STAT_EXECUTION_ID); + +/*--#6 ACT_HI_COMMENT */ +alter table ARCHIVE_ACT_HI_COMMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_COMMENT_EXE_ID ON ARCHIVE_ACT_HI_COMMENT(STAT_EXECUTION_ID); + +/*--#7 ACT_HI_ATTACHMENT */ +alter table ARCHIVE_ACT_HI_ATTACHMENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_ATTACHMENT_EXE_ID ON ARCHIVE_ACT_HI_ATTACHMENT(STAT_EXECUTION_ID); + +/*--#8 ACT_HI_OP_LOG */ +alter table ARCHIVE_ACT_HI_OP_LOG + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_OP_LOG_EXE_ID ON ARCHIVE_ACT_HI_OP_LOG(STAT_EXECUTION_ID); + +/*--#9 ACT_HI_INCIDENT */ +alter table ARCHIVE_ACT_HI_INCIDENT + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_HI_INCIDENT_EXE_ID ON ARCHIVE_ACT_HI_INCIDENT(STAT_EXECUTION_ID); + +/*--#10 ACT_GE_BYTEARRAY */ +alter table ARCHIVE_ACT_GE_BYTEARRAY + add (STAT_EXECUTION_ID bigint, STAT_EXECUTION_TS timestamp(0) DEFAULT CURRENT_TIMESTAMP ); +CREATE INDEX AI_ACT_GE_BYTEARRAY_EXE_ID ON ARCHIVE_ACT_GE_BYTEARRAY(STAT_EXECUTION_ID); + + +/* -- Next Val as a user defined function needed only in MariaDB--*/ +DROP FUNCTION IF EXISTS NextVal; + DELIMITER // + CREATE FUNCTION NextVal (vname VARCHAR(30)) + RETURNS INT + BEGIN + -- Retrieve and update in single statement + UPDATE _sequences + SET next = next + 1 + WHERE name = vname; + + RETURN (SELECT next FROM _sequences LIMIT 1); + END + // + DELIMITER ; + +/* -- History tables for use in archive procedure, there is no array type in MariaDB --*/ +Create Table Camunda_Hi_Tables (id_ MEDIUMINT NOT NULL AUTO_INCREMENT, + TableName_ varchar(80) NOT NULL, + PRIMARY KEY (id_)); + +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_PROCINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ACTINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_TASKINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_VARINST'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_DETAIL'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_COMMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_ATTACHMENT'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_OP_LOG'); +Insert Into Camunda_Hi_Tables(TableName_) Values ('ACT_HI_INCIDENT'); + +/*-- log table --*/ +CREATE TABLE TMPLOGTABLE (LogMessage Varchar(700)); + + +/* -- Below user defined functions and procedures needed only in MariaDB, they are in-built in Oracle --*/ +/*-- Create a sequence SP */ +DROP PROCEDURE IF EXISTS CreateSequence; + DELIMITER // + CREATE PROCEDURE CreateSequence (name VARCHAR(30), start INT, inc INT) + BEGIN + -- Create a table to store sequences + CREATE TABLE IF NOT EXISTS _sequences + ( + name VARCHAR(70) NOT NULL UNIQUE, + next INT NOT NULL, + inc INT NOT NULL + ); + + -- Add the new sequence + INSERT INTO _sequences VALUES (name, start, inc); + END + // + DELIMITER ; + +/*-------------------------------------------------------------------------------------------------- + Add Meta to Archive + -------------------------------------------------------------------------------------------------- */ + +/* Create STAT_EXECUTION_SEQ: each Archive Entry has a same Execution ID during one Archiving Run */ +CALL CreateSequence('STAT_EXECUTION_SEQ', 1, 1); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml index 8a690403c4..7b72812f1a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml @@ -1,10 +1,10 @@ - - skask - supercool - slowburn - complete - 78987 - introvert - 3.14 - myhost.appl.com + + skask + supercool + slowburn + complete + 78987 + introvert + 3.14 + myhost.appl.com \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 3370e33ce2..ee09c9bc4a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -5,8 +5,8 @@ pending-create false 330-89 - introvert - 2.0 + introvert + 2.0 volume-group diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties index 133f58593c..1ac75e9456 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -57,7 +57,7 @@ aai.endpoint=http://localhost:28090 # Example to override default version for a resource: #mso.workflow.default.aai.vce.version=6 #mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce - +mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ mso.workflow.global.default.aai.version=8 mso.workflow.default.aai.cloud-region.version=9 mso.workflow.default.aai.generic-vnf.version=9 @@ -83,4 +83,11 @@ log.debug.FalloutHandler=true log.debug.GenericGetService=true log.debug.sdncAdapter=true log.debug.UpdateNetworkInstanceInfra=true -log.debug.VnfAdapterRestV1=true \ No newline at end of file +log.debug.VnfAdapterRestV1=true +log.debug.GenericGetNetwork=true +log.debug.GenericGetVnf=true +log.debug.GenericDeleteService=true +log.debug.GenericDeleteNetwork=true +log.debug.GenericDeleteVnf=true +log.debug.vnfAdapterCreateV1=true +log.debug.vnfAdapterRestV1=true -- cgit 1.2.3-korg