Move Homing Building Block into ONAP 51/14351/1
authorArthur Martella <amartell@research.att.com>
Thu, 21 Sep 2017 20:09:46 +0000 (16:09 -0400)
committerArthur Martella <amartell@research.att.com>
Thu, 21 Sep 2017 20:09:46 +0000 (16:09 -0400)
Files regarding the Homing building blocks added for use in vCPE flows.

Change-Id: Iae9eb70b81ec7d473e6c4e9c821a9282dc40baa9
Issue-id: SO-138
Signed-off-by: Arthur Martella <amartell@research.att.com>
17 files changed:
bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy [new file with mode: 0755]
bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/catalogResp.json [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackInfraVnf [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroRequest_infravnf [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties
bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java [new file with mode: 0644]

diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy
new file mode 100755 (executable)
index 0000000..dcbb73c
--- /dev/null
@@ -0,0 +1,259 @@
+/*\r
+ * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
+ */\r
+package org.openecomp.mso.bpmn.common.scripts\r
+\r
+import org.camunda.bpm.engine.delegate.BpmnError\r
+import org.camunda.bpm.engine.runtime.Execution\r
+\r
+import org.openecomp.mso.bpmn.common.scripts.AaiUtil\r
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
+import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils\r
+import org.openecomp.mso.bpmn.core.domain.InventoryType\r
+import org.openecomp.mso.bpmn.core.domain.Resource\r
+import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition\r
+import org.openecomp.mso.bpmn.core.domain.Subscriber\r
+import org.openecomp.mso.bpmn.core.json.JsonUtils\r
+import org.openecomp.mso.rest.APIResponse\r
+import org.openecomp.mso.rest.RESTClient\r
+import org.openecomp.mso.rest.RESTConfig\r
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
+\r
+import org.json.JSONArray\r
+import org.json.JSONObject\r
+\r
+import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*;\r
+\r
+/**\r
+ * This class is contains the scripts used\r
+ * by the Homing Subflow building block. The\r
+ * subflow attempts to home the provided\r
+ * resources by calling sniro.\r
+ *\r
+ * @author cb645j\r
+ *\r
+ */\r
+class Homing extends AbstractServiceTaskProcessor{\r
+\r
+       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+       JsonUtils jsonUtil = new JsonUtils()\r
+       SNIROUtils sniroUtils = new SNIROUtils(this)\r
+\r
+       /**\r
+        * This method validates the incoming variables.\r
+        * The method then prepares the sniro request\r
+        * and posts it to sniro's rest api.\r
+        *\r
+        * @param execution\r
+        *\r
+        * @author cb645j\r
+        */\r
+       public void callSniro(Execution execution){\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               execution.setVariable("prefix","HOME_")\r
+               utils.log("DEBUG", "*** Started Homing Call Sniro ***", isDebugEnabled)\r
+               try{\r
+                       execution.setVariable("rollbackData", null)\r
+                       execution.setVariable("rolledBack", false)\r
+\r
+                       String requestId = execution.getVariable("msoRequestId")\r
+                       utils.log("DEBUG", "Incoming Request Id is: "  + requestId, isDebugEnabled)\r
+                       String serviceInstanceId = execution.getVariable("serviceInstanceId")\r
+                       utils.log("DEBUG", "Incoming Service Instance Id is: "  + serviceInstanceId, isDebugEnabled)\r
+                       ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")\r
+                       utils.log("DEBUG", "Incoming Service Decomposition is: "  + serviceDecomposition, isDebugEnabled)\r
+                       String subscriberInfo = execution.getVariable("subscriberInfo")\r
+                       utils.log("DEBUG", "Incoming Subscriber Information is: "  + subscriberInfo, isDebugEnabled)\r
+\r
+                       if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")\r
+                       }else{\r
+                               String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")\r
+                               String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")\r
+                               String subCommonSiteId = ""\r
+                               if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){\r
+                                       subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")\r
+                               }\r
+                               Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId)\r
+\r
+                               String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used\r
+                               String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format\r
+\r
+                               //Authentication\r
+                               def authHeader = ""\r
+                               String basicAuth = execution.getVariable("URN_mso_sniro_auth")\r
+                               String msokey = execution.getVariable("URN_mso_msoKey")\r
+                               String basicAuthValue = utils.encrypt(basicAuth, msokey)\r
+                               if(basicAuthValue != null){\r
+                                       utils.log("DEBUG", "Obtained BasicAuth username and password for SNIRO Adapter: " + basicAuthValue, isDebugEnabled)\r
+                                       try {\r
+                                               authHeader = utils.getBasicAuth(basicAuthValue, msokey)\r
+                                               execution.setVariable("BasicAuthHeaderValue",authHeader)\r
+                                       } catch (Exception ex) {\r
+                                               utils.log("DEBUG", "Unable to encode username and password string: " + ex, isDebugEnabled)\r
+                                               exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to encode username and password string")\r
+                                       }\r
+                               }else{\r
+                                       utils.log("DEBUG", "Unable to obtain BasicAuth - BasicAuth value null" , isDebugEnabled)\r
+                                       exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth value null")\r
+                               }\r
+\r
+                               //Prepare Callback\r
+                               String timeout = execution.getVariable("timeout")\r
+                               if(isBlank(timeout)){\r
+                                       timeout = execution.getVariable("URN_mso_sniro_timeout");\r
+                                       if(isBlank(timeout)) {\r
+                                               timeout = "PT30M";\r
+                                       }\r
+                               }\r
+                               utils.log("DEBUG", "Async Callback Timeout will be: " + timeout, isDebugEnabled)\r
+\r
+                               execution.setVariable("timeout", timeout);\r
+                               execution.setVariable("correlator", requestId);\r
+                               execution.setVariable("messageType", "SNIROResponse");\r
+\r
+                               //Build Request & Call Sniro\r
+                               String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)\r
+                               execution.setVariable("sniroRequest", sniroRequest)\r
+                               utils.log("DEBUG", "SNIRO Request is: " + sniroRequest, isDebugEnabled)\r
+\r
+                               String endpoint = execution.getVariable("URN_mso_service_agnostic_sniro_endpoint")\r
+                               String host = execution.getVariable("URN_mso_service_agnostic_sniro_host")\r
+                               String url = host + endpoint\r
+                               utils.log("DEBUG", "Posting to Sniro Url: " + url, isDebugEnabled)\r
+\r
+                               logDebug( "URL to be used is: " + url, isDebugEnabled)\r
+                               \r
+                               String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))\r
+                               \r
+                               RESTConfig config = new RESTConfig(url);\r
+                               RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json")\r
+                               if (basicAuthCred != null && !"".equals(basicAuthCred)) {\r
+                                       client.addAuthorizationHeader(basicAuthCred)\r
+                               }\r
+                               APIResponse response = client.httpPost(sniroRequest)\r
+                               \r
+                               int responseCode = response.getStatusCode()\r
+                               execution.setVariable("syncResponseCode", responseCode);\r
+                               logDebug("SNIRO sync response code is: " + responseCode, isDebugEnabled)\r
+                               String syncResponse = response.getResponseBodyAsString()\r
+                               execution.setVariable("syncResponse", syncResponse);\r
+                               logDebug("SNIRO sync response is: " + syncResponse, isDebugEnabled)\r
+\r
+                               utils.log("DEBUG", "*** Completed Homing Call Sniro ***", isDebugEnabled)\r
+                       }\r
+               }catch(BpmnError b){\r
+                       throw b\r
+               }catch(Exception e){\r
+                       utils.log("DEBUG", "Error encountered within Homing CallSniro method: " + e, isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * This method processes the callback response\r
+        * and the contained homing solution. It sets\r
+        * homing solution assignment and license\r
+        * information to the corresponding resources\r
+        *\r
+        * @param execution\r
+        *\r
+        * @author cb645j\r
+        */\r
+       public void processHomingSolution(Execution execution){\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled)\r
+               try{\r
+                       String response = execution.getVariable("asyncCallbackResponse")\r
+                       utils.log("DEBUG", "Sniro Async Callback Response is: " + response, isDebugEnabled)\r
+                       utils.logAudit("Sniro Async Callback Response is: " + response)\r
+\r
+                       sniroUtils.validateCallbackResponse(execution, response)\r
+                       String placements = jsonUtil.getJsonValue(response, "solutionInfo.placement")\r
+\r
+                       ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")\r
+                       utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled)\r
+\r
+                       List<Resource> resourceList = decomposition.getServiceResources()\r
+                       JSONArray arr = new JSONArray(placements)\r
+                       for(int i = 0; i < arr.length(); i++){\r
+                               JSONObject placement = arr.getJSONObject(i)\r
+                               String jsonServiceResourceId = placement.getString("serviceResourceId")\r
+                               for(Resource resource:resourceList){\r
+                                       String serviceResourceId = resource.getResourceId()\r
+                                       if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){\r
+                                               //match\r
+                                               String inventoryType = placement.getString("inventoryType")\r
+                                               resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))\r
+                                               resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId"))\r
+                                               JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")\r
+                                               Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue")\r
+                                               resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner"))\r
+                                               resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli"))\r
+                                               resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion"))\r
+                                               if(inventoryType.equalsIgnoreCase("service")){\r
+                                                       resource.getHomingSolution().setVnfHostname(assignmentMap.get("vnfHostName"));\r
+                                                       resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId"));\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){\r
+                               String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")\r
+                               JSONArray licenseArr = new JSONArray(licenseInfo)\r
+                               for(int l = 0; l < licenseArr.length(); l++){\r
+                                       JSONObject license = licenseArr.getJSONObject(l)\r
+                                       String jsonServiceResourceId = license.getString("serviceResourceId")\r
+                                       for(Resource resource:resourceList){\r
+                                               String serviceResourceId = resource.getResourceId()\r
+                                               if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){\r
+                                                       //match\r
+                                                       String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList")\r
+                                                       List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList)\r
+                                                       resource.getHomingSolution().setEntitlementPoolList(entitlementPoolList)\r
+\r
+                                                       String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList")\r
+                                                       List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList)\r
+                                                       resource.getHomingSolution().setLicenseKeyGroupList(licenseKeyGroupList)\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                       execution.setVariable("serviceDecomposition", decomposition)\r
+                       execution.setVariable("homingSolution", placements) //TODO - can be removed as output variable\r
+\r
+                       utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled)\r
+               }catch(BpmnError b){\r
+                       throw b\r
+               }catch(Exception e){\r
+                       utils.log("DEBUG", "Error encountered within Homing ProcessHomingSolution method: " + e, isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing ProcessHomingSolution")\r
+               }\r
+       }\r
+\r
+       /**\r
+        * This method logs the start of DHVCreateService\r
+        * to make debugging easier.\r
+        *\r
+        * @param - execution\r
+        * @author cb645j\r
+        */\r
+       public String logStart(Execution execution){\r
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+               String requestId = execution.getVariable("testReqId")\r
+               if(isBlank(requestId)){\r
+                       requestId = execution.getVariable("msoRequestId")\r
+               }\r
+               execution.setVariable("DHVCS_requestId", requestId)\r
+               utils.log("DEBUG", "***** STARTED Homing Subflow for request: "  + requestId + " *****", "true")\r
+               utils.log("DEBUG", "****** Homing Subflow Global Debug Enabled: " + isDebugEnabled  + " *****", "true")\r
+               utils.logAudit("***** STARTED Homing Subflow for request: "  + requestId + " *****")\r
+       }\r
+\r
+\r
+       /**\r
+        * Auto-generated method stub\r
+        */\r
+       public void preProcessRequest(Execution execution){}\r
+\r
+}\r
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy
new file mode 100644 (file)
index 0000000..6ad03ab
--- /dev/null
@@ -0,0 +1,109 @@
+package org.openecomp.mso.bpmn.common.scripts\r
+\r
+import groovy.json.*\r
+\r
+import org.apache.commons.lang3.*\r
+import org.camunda.bpm.engine.delegate.BpmnError\r
+import org.camunda.bpm.engine.runtime.Execution\r
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
+\r
+\r
+class ReceiveWorkflowMessage extends AbstractServiceTaskProcessor {\r
+\r
+       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+\r
+       /**\r
+        * Process the incoming variables.\r
+        *\r
+        * @param execution The flow's execution instance.\r
+        */\r
+public void preProcessRequest (Execution execution) {\r
+               def method = getClass().getSimpleName() + '.preProcessRequest(' +\r
+                       'execution=' + execution.getId() +\r
+                       ')'\r
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
+               logDebug('Entered ' + method, isDebugLogEnabled)\r
+\r
+               def prefix="RCVWFMSG_"\r
+               execution.setVariable("prefix", prefix)\r
+               setSuccessIndicator(execution, false)\r
+\r
+               try {\r
+                       \r
+                       // Confirm that timeout value has been provided in 'RCVWFMSG_timeout'.\r
+                       def timeout = execution.getVariable('RCVWFMSG_timeout')\r
+                       logDebug('Timeout value is \'' + timeout + '\'', isDebugLogEnabled)\r
+                       if ((timeout == null) || (timeout.isEmpty())) {\r
+                               String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_timeout\''\r
+                               logDebug(msg, isDebugLogEnabled)\r
+                               logError(msg)\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
+                       }\r
+                       \r
+                       // Confirm that message type has been provided in 'RCVWFMSG_messageType'\r
+                       def messageType = execution.getVariable('RCVWFMSG_messageType')\r
+                       logDebug('Message type is \'' + messageType + '\'', isDebugLogEnabled)\r
+                       if ((messageType == null) || (messageType.isEmpty())) {\r
+                               String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_messageType\''\r
+                               logDebug(msg, isDebugLogEnabled)\r
+                               logError(msg)\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
+                       }\r
+                       \r
+                       // Confirm that correlator value has been provided in 'RCVWFMSG_correlator'\r
+                       def correlator = execution.getVariable('RCVWFMSG_correlator')\r
+                       logDebug('Correlator value is \'' + correlator + '\'', isDebugLogEnabled)\r
+                       if ((correlator == null) || (correlator.isEmpty())) {\r
+                               String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_correlator\''\r
+                               logDebug(msg, isDebugLogEnabled)\r
+                               logError(msg)\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
+                       }\r
+                       execution.setVariable(messageType + '_CORRELATOR', correlator)\r
+                       \r
+                       logDebug('Exited ' + method, isDebugLogEnabled)\r
+               } catch (BpmnError e) {\r
+                       throw e\r
+               } catch (Exception e) {\r
+                       String msg = 'Caught exception in ' + method + ": " + e\r
+                       logDebug(msg, isDebugLogEnabled)\r
+                       logError(msg)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Process a received message.\r
+        *\r
+        * @param execution The flow's execution instance.\r
+        */\r
+       public void processReceivedMessage(Execution execution){\r
+               def method = getClass().getSimpleName() + '.processReceivedMessage(' +\r
+                       'execution=' + execution.getId() +\r
+                       ')'\r
+               def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')\r
+               logDebug('Entered ' + method, isDebugLogEnabled)\r
+\r
+               String messageType = null;\r
+               String receivedMessage = null;\r
+\r
+               try {\r
+                       messageType = execution.getVariable('RCVWFMSG_messageType')\r
+                       receivedMessage = execution.getVariable(messageType + '_MESSAGE')\r
+                       logDebug(getProcessKey(execution) + ": received message:\n" + receivedMessage, isDebugLogEnabled)\r
+\r
+                       // The received message is made available to the calling flow in WorkflowResponse\r
+                       execution.setVariable("WorkflowResponse", receivedMessage)\r
+                       \r
+                       setSuccessIndicator(execution, true)\r
+\r
+                       logDebug('Exited ' + method, isDebugLogEnabled)\r
+               } catch (Exception e) {\r
+                       receivedMessage = receivedMessage == null || String.valueOf(receivedMessage).isEmpty() ? "NONE" : receivedMessage\r
+                       String msg = "Error processing received workflow message: " + receivedMessage\r
+                       logDebug(getProcessKey(execution) + ': ' + msg, isDebugLogEnabled)\r
+                       exceptionUtil.buildWorkflowException(execution, 7020, msg)\r
+               }\r
+       }\r
+}\r
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy
new file mode 100644 (file)
index 0000000..aba2b78
--- /dev/null
@@ -0,0 +1,262 @@
+package org.openecomp.mso.bpmn.common.scripts\r
+\r
+import org.camunda.bpm.engine.runtime.Execution\r
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil\r
+import org.openecomp.mso.bpmn.common.scripts.MsoUtils\r
+import org.openecomp.mso.bpmn.core.domain.*\r
+import org.openecomp.mso.bpmn.core.json.JsonUtils\r
+import org.apache.commons.lang3.StringUtils\r
+\r
+import static  org.openecomp.mso.bpmn.common.scripts.GenericUtils.*\r
+\r
+class SNIROUtils{\r
+\r
+       ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+       JsonUtils jsonUtil = new JsonUtils()\r
+\r
+       private AbstractServiceTaskProcessor utils\r
+\r
+       public MsoUtils msoUtils = new MsoUtils()\r
+\r
+       public SNIROUtils(AbstractServiceTaskProcessor taskProcessor) {\r
+               this.utils = taskProcessor\r
+       }\r
+\r
+       /**\r
+        * This method builds the service-agnostic\r
+        * sniro json request to get a homing solution\r
+        * and license solution\r
+        *\r
+        * @param execution\r
+        * @param requestId\r
+        * @param decomposition - ServiceDecomposition object\r
+        * @param subscriber - Subscriber information\r
+        * @param homingParams - Homing/Request parameters\r
+        *\r
+        * @return request - sniro v2 payload\r
+        *\r
+        * @author cb645j\r
+        */\r
+       public String buildRequest(Execution execution, String requestId, ServiceDecomposition decomposition, Subscriber subscriber, String homingParams){\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               utils.log("DEBUG", "Started Building Sniro Request", isDebugEnabled)\r
+               def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(execution, "SNIROResponse", requestId)\r
+               def transactionId = requestId\r
+               //ServiceInstance Info\r
+               ServiceInstance serviceInstance = decomposition.getServiceInstance()\r
+               def serviceInstanceId\r
+               if(serviceInstance == null){\r
+                       utils.log("DEBUG", "Unable to obtain Service Instance Id, ServiceInstance Object is null" , isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to obtain Service Instance Id, ServiceInstance Object is null")\r
+               }else{\r
+                       serviceInstanceId = serviceInstance.getInstanceId()\r
+               }\r
+               //Model Info\r
+               ModelInfo model = decomposition.getModelInfo()\r
+               String modelType = model.getModelType()\r
+               String modelInvariantId = model.getModelInvariantUuid()\r
+               String modelVersionId = model.getModelUuid()\r
+               String modelName = model.getModelName()\r
+               String modelVersion = model.getModelVersion()\r
+               //Subscriber Info\r
+               String subscriberId = subscriber.getGlobalId()\r
+               String subscriberName = subscriber.getName()\r
+               String commonSiteId = subscriber.getCommonSiteId()\r
+               //OrderInfo\r
+               String orderInfo\r
+               if(!isBlank(homingParams)){\r
+                       orderInfo = homingParams.replaceAll("\"", "\\\\\"").replaceAll("\n", "").replaceAll("\r", "")\r
+                       orderInfo = StringUtils.normalizeSpace(orderInfo)\r
+               }\r
+\r
+               //Demands\r
+               String placementDemands = ""\r
+               StringBuilder sb = new StringBuilder()\r
+               List<Resource> resourceList = decomposition.getServiceAllottedResources()\r
+               List<VnfResource> vnfResourceList = decomposition.getServiceVnfs()\r
+\r
+               // TODO: We should include both alloted resources and service resources in the placementDeamnds- not one or the other.\r
+               if(resourceList.isEmpty() || resourceList == null){\r
+                       utils.log("DEBUG", "Allotted Resources List is empty - will try to get service VNFs instead.", isDebugEnabled)\r
+                       resourceList = decomposition.getServiceVnfs()\r
+               }\r
+               \r
+               if(resourceList.isEmpty() || resourceList == null){\r
+                       utils.log("DEBUG", "Resources List is Empty", isDebugEnabled)\r
+               }else{\r
+                       for(Resource resource:resourceList){\r
+                               ModelInfo resourceModelInfo = resource.getModelInfo()\r
+                               ResourceInstance resourceInstance = resource.getResourceInstance()\r
+                               def resourceInstanceType = resource.getResourceType()\r
+                               def serviceResourceId = resource.getResourceId() //TODO - resourceId versus instanceId - should be what is put in AAI, whatever we put here will be what is in response, used to correlate\r
+                               def resourceModuleName = resourceModelInfo.getModelInstanceName()\r
+                               def resouceModelCustomizationId = resourceModelInfo.getModelCustomizationUuid()\r
+                               def resouceModelInvariantId = resourceModelInfo.getModelInvariantUuid()\r
+                               def resouceModelName = resourceModelInfo.getModelName()\r
+                               def resouceModelVersion = resourceModelInfo.getModelVersion()\r
+                               def resouceModelVersionId = resourceModelInfo.getModelUuid()\r
+                               def resouceModelType = resourceModelInfo.getModelType()\r
+                               def tenantId = "" //Optional\r
+                               def tenantName = "" //Optional\r
+       \r
+                               String demand =\r
+                                       """{\r
+                                               "resourceInstanceType": "${resourceInstanceType}",\r
+                                               "serviceResourceId": "${serviceResourceId}",\r
+                                               "resourceModuleName": "${resourceModuleName}",\r
+                                               "resourceModelInfo": {\r
+                                                       "modelCustomizationId": "${resouceModelCustomizationId}",\r
+                                                       "modelInvariantId": "${resouceModelInvariantId}",\r
+                                                       "modelName": "${resouceModelName}",\r
+                                                       "modelVersion": "${resouceModelVersion}",\r
+                                                       "modelVersionId": "${resouceModelVersionId}",\r
+                                                       "modelType": "${resouceModelType}"\r
+                                               },\r
+                                               "tenantId": "${tenantId}",\r
+                                               "tenantName": "${tenantName}"\r
+                                       },"""\r
+       \r
+                               placementDemands = sb.append(demand)\r
+                       }\r
+                       placementDemands = placementDemands.substring(0, placementDemands.length() - 1);\r
+               }\r
+\r
+               String licenseDemands = ""\r
+               sb = new StringBuilder()\r
+               if(vnfResourceList.isEmpty() || vnfResourceList == null){\r
+                       utils.log("DEBUG", "Vnf Resources List is Empty", isDebugEnabled)\r
+               }else{  \r
+                       for(VnfResource vnfResource:vnfResourceList){\r
+                               ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo()\r
+                               ResourceInstance vnfResourceInstance = vnfResource.getResourceInstance()\r
+                               def resourceInstanceType = vnfResource.getResourceType()\r
+                               def serviceResourceId = vnfResource.getResourceId()\r
+                               def resourceModuleName = vnfResourceModelInfo.getModelInstanceName()\r
+                               def resouceModelCustomizationId = vnfResourceModelInfo.getModelCustomizationUuid()\r
+                               def resouceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid()\r
+                               def resouceModelName = vnfResourceModelInfo.getModelName()\r
+                               def resouceModelVersion = vnfResourceModelInfo.getModelVersion()\r
+                               def resouceModelVersionId = vnfResourceModelInfo.getModelUuid()\r
+                               def resouceModelType = vnfResourceModelInfo.getModelType()\r
+       \r
+                               String demand =\r
+                               """{\r
+                                               "resourceInstanceType": "${resourceInstanceType}",\r
+                                               "serviceResourceId": "${serviceResourceId}",\r
+                                               "resourceModuleName": "${resourceModuleName}",\r
+                                               "resourceModelInfo": {\r
+                                                       "modelCustomizationId": "${resouceModelCustomizationId}",\r
+                                                       "modelInvariantId": "${resouceModelInvariantId}",\r
+                                                       "modelName": "${resouceModelName}",\r
+                                                       "modelVersion": "${resouceModelVersion}",\r
+                                                       "modelVersionId": "${resouceModelVersionId}",\r
+                                                       "modelType": "${resouceModelType}"\r
+                                               }\r
+                                       },"""\r
+       \r
+                                       licenseDemands = sb.append(demand)\r
+                       }\r
+                       licenseDemands = licenseDemands.substring(0, licenseDemands.length() - 1);\r
+               }\r
+                       \r
+               String request =\r
+                               """{\r
+               "requestInfo": {\r
+                               "transactionId": "${transactionId}",\r
+                               "requestId": "${requestId}",\r
+                               "callbackUrl": "${callbackUrl}",\r
+                               "sourceId": "mso",\r
+                               "optimizer": [\r
+                                       "placement",\r
+                                       "license"\r
+                               ],\r
+                               "numSolutions": 1,\r
+                               "timeout": 600\r
+                               },\r
+               "placementInfo": {\r
+                       "serviceModelInfo": {\r
+                               "modelType": "${modelType}",\r
+                               "modelInvariantId": "${modelInvariantId}",\r
+                               "modelVersionId": "${modelVersionId}",\r
+                               "modelName": "${modelName}",\r
+                               "modelVersion": "${modelVersion}"\r
+                               },\r
+                       "subscriberInfo": {\r
+                               "globalSubscriberId": "${subscriberId}",\r
+                               "subscriberName": "${subscriberName}",\r
+                               "subscriberCommonSiteId": "${commonSiteId}"\r
+                               },\r
+                       "demandInfo": {\r
+                               "placementDemand": [\r
+                                       ${placementDemands}\r
+                               ],\r
+                               "licenseDemand": [\r
+                                       ${licenseDemands}\r
+                               ]\r
+                       },\r
+                       "policyId": [],\r
+                       "serviceInstanceId": "${serviceInstanceId}",\r
+                       "orderInfo": "{\\\"requestParameters\\\": ${orderInfo}}"\r
+               }\r
+         }"""\r
+\r
+               utils.log("DEBUG", "Completed Building Sniro Request", isDebugEnabled)\r
+               return request\r
+       }\r
+\r
+       /**\r
+        * This method validates the callback response\r
+        * from Sniro. If the response contains an\r
+        * exception the method will build and throw\r
+        * a workflow exception.\r
+        *\r
+        * @param execution\r
+        * @param response - the async callback response from sniro\r
+        *\r
+        * @author cb645j\r
+        */\r
+       public void validateCallbackResponse(Execution execution, String response){\r
+               def isDebugEnabled = execution.getVariable("isDebugLogEnabled")\r
+               String placements = ""\r
+               if(isBlank(response)){\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Sniro Async Callback Response is Empty")\r
+               }else{\r
+                       if(JsonUtils.jsonElementExist(response, "solutionInfo.placement")){\r
+                               placements = jsonUtil.getJsonValue(response, "solutionInfo.placement")\r
+                               if(isBlank(placements) || placements.equalsIgnoreCase("[]")){\r
+                                       String statusMessage = jsonUtil.getJsonValue(response, "statusMessage")\r
+                                       if(isBlank(statusMessage)){\r
+                                               utils.log("DEBUG", "Error Occured in Homing: Sniro Async Callback Response does not contain placement solution.", isDebugEnabled)\r
+                                               exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Sniro Async Callback Response does not contain placement solution.")\r
+                                       }else{\r
+                                               utils.log("DEBUG", "Error Occured in Homing: " + statusMessage, isDebugEnabled)\r
+                                               exceptionUtil.buildAndThrowWorkflowException(execution, 400, statusMessage)\r
+                                       }\r
+                               }else{\r
+                                       return\r
+                               }\r
+                       }else if(JsonUtils.jsonElementExist(response, "requestError") == true){\r
+                               String errorMessage = ""\r
+                               if(response.contains("policyException")){\r
+                                       String text = jsonUtil.getJsonValue(response, "requestError.policyException.text")\r
+                                       errorMessage = "Sniro Async Callback Response contains a Request Error Policy Exception: " + text\r
+                               }else if(response.contains("serviceException")){\r
+                                       String text = jsonUtil.getJsonValue(response, "requestError.serviceException.text")\r
+                                       errorMessage = "Sniro Async Callback Response contains a Request Error Service Exception: " + text\r
+                               }else{\r
+                                       errorMessage = "Sniro Async Callback Response contains a Request Error. Unable to determine the Request Error Exception."\r
+                               }\r
+                               utils.log("DEBUG", "Error Occured in Homing: " + errorMessage, isDebugEnabled)\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 400, errorMessage)\r
+\r
+                       }else{\r
+                               utils.log("DEBUG", "Error Occured in Homing: Received an Unknown Async Callback Response from Sniro.", isDebugEnabled)\r
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Received an Unknown Async Callback Response from Sniro.")\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn
new file mode 100644 (file)
index 0000000..a432417
--- /dev/null
@@ -0,0 +1,259 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="_vwRmIBsREeeIQtzUKIjH4g" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+  <bpmn2:process id="Homing" name="Homing" isExecutable="true">
+    <bpmn2:startEvent id="StartEvent_1">
+      <bpmn2:outgoing>SequenceFlow_1x9usa6</bpmn2:outgoing>
+    </bpmn2:startEvent>
+    <bpmn2:scriptTask id="callSniro" name="Call Sniro" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_1x9usa6</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_10x3ocp</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*
+Homing sniro = new Homing()
+sniro.callSniro(execution)]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="SequenceFlow_1x9usa6" sourceRef="StartEvent_1" targetRef="callSniro" />
+    <bpmn2:subProcess id="bpmnErrorSubprocess" name="Error Handling Subprocess" triggeredByEvent="true">
+      <bpmn2:endEvent id="EndEvent_07tjq3v">
+        <bpmn2:incoming>SequenceFlow_1rf4vs8</bpmn2:incoming>
+        <bpmn2:terminateEventDefinition />
+      </bpmn2:endEvent>
+      <bpmn2:startEvent id="StartEvent_1qiitb2">
+        <bpmn2:outgoing>SequenceFlow_00nlh7l</bpmn2:outgoing>
+        <bpmn2:errorEventDefinition />
+      </bpmn2:startEvent>
+      <bpmn2:scriptTask id="processMsoWorkflowException" name="Process Error" scriptFormat="groovy">
+        <bpmn2:incoming>SequenceFlow_00nlh7l</bpmn2:incoming>
+        <bpmn2:outgoing>SequenceFlow_1rf4vs8</bpmn2:outgoing>
+        <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*\r
+ExceptionUtil ex = new ExceptionUtil()\r
+ex.processSubflowsBPMNException(execution)]]></bpmn2:script>
+      </bpmn2:scriptTask>
+      <bpmn2:sequenceFlow id="SequenceFlow_1rf4vs8" sourceRef="processMsoWorkflowException" targetRef="EndEvent_07tjq3v" />
+      <bpmn2:sequenceFlow id="SequenceFlow_00nlh7l" sourceRef="StartEvent_1qiitb2" targetRef="processMsoWorkflowException" />
+    </bpmn2:subProcess>
+    <bpmn2:subProcess id="javaExceptionSubProcess" name="Java Exception Sub Process" triggeredByEvent="true">
+      <bpmn2:scriptTask id="processJavaException" name="Process Error" scriptFormat="groovy">
+        <bpmn2:incoming>SequenceFlow_0kamg53</bpmn2:incoming>
+        <bpmn2:outgoing>SequenceFlow_1o7154s</bpmn2:outgoing>
+        <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*\r
+ExceptionUtil ex = new ExceptionUtil()\r
+ex.processJavaException(execution)]]></bpmn2:script>
+      </bpmn2:scriptTask>
+      <bpmn2:startEvent id="StartEvent_1fbpeuw">
+        <bpmn2:outgoing>SequenceFlow_0kamg53</bpmn2:outgoing>
+        <bpmn2:errorEventDefinition errorRef="Error_1lwpypa" />
+      </bpmn2:startEvent>
+      <bpmn2:endEvent id="EndEvent_0jbvnr0">
+        <bpmn2:incoming>SequenceFlow_1o7154s</bpmn2:incoming>
+        <bpmn2:terminateEventDefinition />
+      </bpmn2:endEvent>
+      <bpmn2:sequenceFlow id="SequenceFlow_0kamg53" name="" sourceRef="StartEvent_1fbpeuw" targetRef="processJavaException" />
+      <bpmn2:sequenceFlow id="SequenceFlow_1o7154s" name="" sourceRef="processJavaException" targetRef="EndEvent_0jbvnr0" />
+    </bpmn2:subProcess>
+    <bpmn2:scriptTask id="processHomingSolution" name="Process &#10;Homing Solutio&#10;" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_043r3j8</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_1h9opg9</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*
+Homing homing = new Homing()
+homing.processHomingSolution(execution)]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:exclusiveGateway id="responseCheck" name="Response Ok?" default="badResponse">
+      <bpmn2:incoming>SequenceFlow_10x3ocp</bpmn2:incoming>
+      <bpmn2:outgoing>badResponse</bpmn2:outgoing>
+      <bpmn2:outgoing>goodResponse</bpmn2:outgoing>
+    </bpmn2:exclusiveGateway>
+    <bpmn2:sequenceFlow id="SequenceFlow_10x3ocp" sourceRef="callSniro" targetRef="responseCheck" />
+    <bpmn2:scriptTask id="assignError" name="Assign Error" scriptFormat="groovy">
+      <bpmn2:incoming>badResponse</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_0clfkld</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[int responseCode = execution.getVariable("syncResponseCode") \r
+\r
+import org.openecomp.mso.bpmn.common.scripts.*\r
+ExceptionUtil ex = new ExceptionUtil()\r
+ex.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="badResponse" name="No" sourceRef="responseCheck" targetRef="assignError" />
+    <bpmn2:sequenceFlow id="SequenceFlow_0clfkld" sourceRef="assignError" targetRef="throwMSOWorkflowException" />
+    <bpmn2:endEvent id="throwMSOWorkflowException">
+      <bpmn2:incoming>SequenceFlow_0clfkld</bpmn2:incoming>
+      <bpmn2:errorEventDefinition errorRef="Error_10hit0u" />
+    </bpmn2:endEvent>
+    <bpmn2:sequenceFlow id="goodResponse" name="Yes" sourceRef="responseCheck" targetRef="receiveAsyncCallback">
+      <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("syncResponseCode") == 202}]]></bpmn2:conditionExpression>
+    </bpmn2:sequenceFlow>
+    <bpmn2:sequenceFlow id="SequenceFlow_043r3j8" sourceRef="receiveAsyncCallback" targetRef="processHomingSolution" />
+    <bpmn2:callActivity id="receiveAsyncCallback" name="Receive Async Callback" calledElement="ReceiveWorkflowMessage" camunda:modelerTemplate="receiveWorkflowMessage">
+      <bpmn2:extensionElements>
+        <camunda:in source="true" target="isDebugLogEnabled" />
+        <camunda:out source="WorkflowException" target="WorkflowException" />
+        <camunda:in source="messageType" target="RCVWFMSG_messageType" />
+        <camunda:in source="correlator" target="RCVWFMSG_correlator" />
+        <camunda:in source="timeout" target="RCVWFMSG_timeout" />
+        <camunda:out source="WorkflowResponse" target="asyncCallbackResponse" />
+      </bpmn2:extensionElements>
+      <bpmn2:incoming>goodResponse</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_043r3j8</bpmn2:outgoing>
+    </bpmn2:callActivity>
+    <bpmn2:sequenceFlow id="SequenceFlow_1h9opg9" sourceRef="processHomingSolution" targetRef="EndEvent_0n56tas" />
+    <bpmn2:endEvent id="EndEvent_0n56tas">
+      <bpmn2:incoming>SequenceFlow_1h9opg9</bpmn2:incoming>
+      <bpmn2:terminateEventDefinition />
+    </bpmn2:endEvent>
+  </bpmn2:process>
+  <bpmn2:error id="Error_10hit0u" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
+  <bpmn2:error id="Error_1lwpypa" name="Java Lang Exception" errorCode="java.lang.Exception" />
+  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Homing">
+      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+        <dc:Bounds x="147" y="275" width="36" height="36" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_0qmfpdr_di" bpmnElement="callSniro">
+        <dc:Bounds x="286" y="253" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1x9usa6_di" bpmnElement="SequenceFlow_1x9usa6">
+        <di:waypoint xsi:type="dc:Point" x="183" y="293" />
+        <di:waypoint xsi:type="dc:Point" x="286" y="293" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="235" y="278" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="SubProcess_16p12qo_di" bpmnElement="bpmnErrorSubprocess" isExpanded="true">
+        <dc:Bounds x="254" y="496" width="409" height="168" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="SubProcess_12gjiy8_di" bpmnElement="javaExceptionSubProcess" isExpanded="true">
+        <dc:Bounds x="284" y="679" width="350" height="159" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="EndEvent_07tjq3v_di" bpmnElement="EndEvent_07tjq3v">
+        <dc:Bounds x="579" y="570" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="597" y="611" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_1qiitb2_di" bpmnElement="StartEvent_1qiitb2">
+        <dc:Bounds x="299" y="570" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="317" y="611" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_03hs6s9_di" bpmnElement="processMsoWorkflowException">
+        <dc:Bounds x="406" y="548" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ScriptTask_19gqykh_di" bpmnElement="processJavaException">
+        <dc:Bounds x="410" y="727" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="StartEvent_1fbpeuw_di" bpmnElement="StartEvent_1fbpeuw">
+        <dc:Bounds x="318" y="749" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="336" y="790" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="EndEvent_0jbvnr0_di" bpmnElement="EndEvent_0jbvnr0">
+        <dc:Bounds x="567" y="749" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="585" y="790" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1rf4vs8_di" bpmnElement="SequenceFlow_1rf4vs8">
+        <di:waypoint xsi:type="dc:Point" x="506" y="588" />
+        <di:waypoint xsi:type="dc:Point" x="579" y="588" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="543" y="573" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_00nlh7l_di" bpmnElement="SequenceFlow_00nlh7l">
+        <di:waypoint xsi:type="dc:Point" x="335" y="588" />
+        <di:waypoint xsi:type="dc:Point" x="363" y="588" />
+        <di:waypoint xsi:type="dc:Point" x="363" y="588" />
+        <di:waypoint xsi:type="dc:Point" x="406" y="588" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="378" y="588" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0kamg53_di" bpmnElement="SequenceFlow_0kamg53">
+        <di:waypoint xsi:type="dc:Point" x="354" y="767" />
+        <di:waypoint xsi:type="dc:Point" x="410" y="767" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="382" y="752" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1o7154s_di" bpmnElement="SequenceFlow_1o7154s">
+        <di:waypoint xsi:type="dc:Point" x="510" y="767" />
+        <di:waypoint xsi:type="dc:Point" x="567" y="767" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="539" y="752" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_1aapkvq_di" bpmnElement="processHomingSolution">
+        <dc:Bounds x="630" y="325" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="ExclusiveGateway_03gt5b8_di" bpmnElement="responseCheck" isMarkerVisible="true">
+        <dc:Bounds x="419" y="268" width="50" height="50" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="474" y="287" width="74" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_10x3ocp_di" bpmnElement="SequenceFlow_10x3ocp">
+        <di:waypoint xsi:type="dc:Point" x="386" y="293" />
+        <di:waypoint xsi:type="dc:Point" x="419" y="293" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="403" y="278" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_0ikcqeo_di" bpmnElement="assignError">
+        <dc:Bounds x="490" y="176" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1m1c9nu_di" bpmnElement="badResponse">
+        <di:waypoint xsi:type="dc:Point" x="444" y="268" />
+        <di:waypoint xsi:type="dc:Point" x="444" y="216" />
+        <di:waypoint xsi:type="dc:Point" x="490" y="216" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="451" y="226" width="14" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_0clfkld_di" bpmnElement="SequenceFlow_0clfkld">
+        <di:waypoint xsi:type="dc:Point" x="590" y="216" />
+        <di:waypoint xsi:type="dc:Point" x="662" y="216" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="626" y="201" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="EndEvent_13ejfwp_di" bpmnElement="throwMSOWorkflowException">
+        <dc:Bounds x="662" y="198" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="680" y="234" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1o3br3u_di" bpmnElement="goodResponse">
+        <di:waypoint xsi:type="dc:Point" x="444" y="318" />
+        <di:waypoint xsi:type="dc:Point" x="444" y="365" />
+        <di:waypoint xsi:type="dc:Point" x="490" y="365" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="447" y="339.5" width="18" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_043r3j8_di" bpmnElement="SequenceFlow_043r3j8">
+        <di:waypoint xsi:type="dc:Point" x="590" y="365" />
+        <di:waypoint xsi:type="dc:Point" x="630" y="365" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="610" y="350" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="CallActivity_031b5m3_di" bpmnElement="receiveAsyncCallback">
+        <dc:Bounds x="490" y="325" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1h9opg9_di" bpmnElement="SequenceFlow_1h9opg9">
+        <di:waypoint xsi:type="dc:Point" x="730" y="365" />
+        <di:waypoint xsi:type="dc:Point" x="825" y="365" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="778" y="350" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="EndEvent_0ougemc_di" bpmnElement="EndEvent_0n56tas">
+        <dc:Bounds x="825" y="347" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="843" y="383" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+    </bpmndi:BPMNPlane>
+  </bpmndi:BPMNDiagram>
+</bpmn2:definitions>
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn
new file mode 100644 (file)
index 0000000..ad857ed
--- /dev/null
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_GraPIIyxEeWmdMDkx6Uftw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+  <bpmn2:process id="ReceiveWorkflowMessage" name="ReceiveWorkflowMessage" isExecutable="true">
+    <bpmn2:scriptTask id="ScriptTask_1" name="Pre-Process Request" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_1ps0nzi</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*
+def receiveWorkflowMessage = new ReceiveWorkflowMessage()
+receiveWorkflowMessage .preProcessRequest(execution)
+]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:startEvent id="StartEvent_1" name="Start">
+      <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing>
+    </bpmn2:startEvent>
+    <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="StartEvent_1" targetRef="ScriptTask_1" />
+    <bpmn2:scriptTask id="ScriptTask_5" name="Workflow Exception (timeout)" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_34</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*
+def exceptionUtil = new ExceptionUtil()
+exceptionUtil.buildWorkflowException(execution, 7010, "Receive Workflow Message Timeout Error")]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="SequenceFlow_34" name="" sourceRef="ScriptTask_5" targetRef="EndEvent_8" />
+    <bpmn2:endEvent id="EndEvent_8">
+      <bpmn2:incoming>SequenceFlow_34</bpmn2:incoming>
+      <bpmn2:errorEventDefinition id="_ErrorEventDefinition_21" errorRef="Error_1" />
+    </bpmn2:endEvent>
+    <bpmn2:scriptTask id="ScriptTask_setSuccess" name="Process Message and Set WorkflowResult" scriptFormat="groovy">
+      <bpmn2:incoming>SequenceFlow_44</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
+      <bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.common.scripts.*
+def receiveWorkflowMessage = new ReceiveWorkflowMessage()
+receiveWorkflowMessage.processReceivedMessage(execution)]]></bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ScriptTask_setSuccess" targetRef="EndEvent_6" />
+    <bpmn2:endEvent id="EndEvent_6" name="End">
+      <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
+    </bpmn2:endEvent>
+    <bpmn2:boundaryEvent id="BoundaryEvent_1" name="Timeout" attachedToRef="SubProcess_2">
+      <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing>
+      <bpmn2:timerEventDefinition id="TimerEventDefinition_1">
+        <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression">${RCVWFMSG_timeout}</bpmn2:timeDuration>
+      </bpmn2:timerEventDefinition>
+    </bpmn2:boundaryEvent>
+    <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="BoundaryEvent_1" targetRef="ScriptTask_5" />
+    <bpmn2:subProcess id="SubProcess_2" name="Wait for Workflow Message">
+      <bpmn2:incoming>SequenceFlow_1ps0nzi</bpmn2:incoming>
+      <bpmn2:outgoing>SequenceFlow_44</bpmn2:outgoing>
+      <bpmn2:startEvent id="StartEvent_3">
+        <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing>
+      </bpmn2:startEvent>
+      <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="StartEvent_3" targetRef="IntermediateCatchEvent_1" />
+      <bpmn2:endEvent id="EndEvent_12">
+        <bpmn2:incoming>SequenceFlow_41</bpmn2:incoming>
+      </bpmn2:endEvent>
+      <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="Catch Workflow Message">
+        <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming>
+        <bpmn2:outgoing>SequenceFlow_41</bpmn2:outgoing>
+        <bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_07j47nk" />
+      </bpmn2:intermediateCatchEvent>
+      <bpmn2:sequenceFlow id="SequenceFlow_41" name="" sourceRef="IntermediateCatchEvent_1" targetRef="EndEvent_12" />
+    </bpmn2:subProcess>
+    <bpmn2:sequenceFlow id="SequenceFlow_44" name="" sourceRef="SubProcess_2" targetRef="ScriptTask_setSuccess" />
+    <bpmn2:sequenceFlow id="SequenceFlow_1ps0nzi" sourceRef="ScriptTask_1" targetRef="SubProcess_2" />
+  </bpmn2:process>
+  <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
+  <bpmn2:message id="Message_1" name="SDNCAResponse" />
+  <bpmn2:message id="Message_07j47nk" name="WorkflowMessage" />
+  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ReceiveWorkflowMessage">
+      <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_56" bpmnElement="ScriptTask_1">
+        <dc:Bounds x="242" y="161" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="_BPMNShape_SubProcess_14" bpmnElement="SubProcess_2" isExpanded="true">
+        <dc:Bounds x="461" y="107" width="313" height="189" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_59" bpmnElement="ScriptTask_5">
+        <dc:Bounds x="857" y="382" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_24" bpmnElement="BoundaryEvent_1">
+        <dc:Bounds x="703" y="278" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="744" y="308" width="39" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_54" bpmnElement="StartEvent_1">
+        <dc:Bounds x="129" y="184" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="135" y="225" width="23" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_54" targetElement="_BPMNShape_ScriptTask_56">
+        <di:waypoint xsi:type="dc:Point" x="165" y="202" />
+        <di:waypoint xsi:type="dc:Point" x="242" y="201" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="204" y="186.5" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_55" bpmnElement="StartEvent_3">
+        <dc:Bounds x="493" y="185" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="511" y="226" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_StartEvent_55" targetElement="_BPMNShape_IntermediateCatchEvent_20">
+        <di:waypoint xsi:type="dc:Point" x="529" y="203" />
+        <di:waypoint xsi:type="dc:Point" x="588" y="203" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="791" y="201" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_BoundaryEvent_24" targetElement="_BPMNShape_ScriptTask_59">
+        <di:waypoint xsi:type="dc:Point" x="721" y="314" />
+        <di:waypoint xsi:type="dc:Point" x="721" y="422" />
+        <di:waypoint xsi:type="dc:Point" x="857" y="422" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="736" y="368" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="_BPMNShape_EndEvent_158" bpmnElement="EndEvent_6">
+        <dc:Bounds x="1022" y="184" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1031" y="225" width="19" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_8">
+        <dc:Bounds x="1022" y="404" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1040" y="445" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_36" bpmnElement="SequenceFlow_34" sourceElement="_BPMNShape_ScriptTask_59" targetElement="_BPMNShape_EndEvent_160">
+        <di:waypoint xsi:type="dc:Point" x="957" y="422" />
+        <di:waypoint xsi:type="dc:Point" x="1022" y="422" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="990" y="407" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_236" bpmnElement="ScriptTask_setSuccess">
+        <dc:Bounds x="858" y="160" width="97" height="83" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_ScriptTask_236" targetElement="_BPMNShape_EndEvent_158">
+        <di:waypoint xsi:type="dc:Point" x="955" y="201" />
+        <di:waypoint xsi:type="dc:Point" x="1022" y="202" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="989" y="186.5" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="_BPMNShape_EndEvent_219" bpmnElement="EndEvent_12">
+        <dc:Bounds x="681" y="185" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="699" y="226" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_44" bpmnElement="SequenceFlow_44" sourceElement="_BPMNShape_SubProcess_14" targetElement="_BPMNShape_ScriptTask_236">
+        <di:waypoint xsi:type="dc:Point" x="774" y="202" />
+        <di:waypoint xsi:type="dc:Point" x="858" y="201" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="816" y="186.5" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1ps0nzi_di" bpmnElement="SequenceFlow_1ps0nzi">
+        <di:waypoint xsi:type="dc:Point" x="342" y="201" />
+        <di:waypoint xsi:type="dc:Point" x="461" y="201" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="402" y="186" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_20" bpmnElement="IntermediateCatchEvent_1">
+        <dc:Bounds x="588" y="185" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="566" y="227" width="80" height="24" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_41" bpmnElement="SequenceFlow_41" sourceElement="_BPMNShape_IntermediateCatchEvent_20">
+        <di:waypoint xsi:type="dc:Point" x="624" y="203" />
+        <di:waypoint xsi:type="dc:Point" x="681" y="203" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="653" y="188" width="0" height="0" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+    </bpmndi:BPMNPlane>
+  </bpmndi:BPMNDiagram>
+</bpmn2:definitions>
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java
new file mode 100644 (file)
index 0000000..562a4d0
--- /dev/null
@@ -0,0 +1,457 @@
+/*
+ * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
+ */
+package org.openecomp.mso.bpmn.common;
+
+import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
+import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.camunda.bpm.engine.test.Deployment;
+import org.junit.Test;
+
+import org.openecomp.mso.bpmn.core.WorkflowException;
+import org.openecomp.mso.bpmn.core.domain.*;
+
+import org.openecomp.mso.bpmn.mock.FileUtil;
+import org.openecomp.mso.bpmn.common.WorkflowTest;
+
+
+/**
+ * Test the Homing subflow building block.
+ *
+ * @author cb645j
+ */
+public class HomingTest extends WorkflowTest {
+
+       ServiceDecomposition serviceDecomposition = new ServiceDecomposition();
+       String subscriber = "";
+       String subscriber2 = "";
+
+       private final CallbackSet callbacks = new CallbackSet();
+
+       public HomingTest() throws IOException {
+               String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf");
+               String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net");
+               String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf");
+               String sniroCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound");
+               String sniroCallbackPolicyException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException");
+               String sniroCallbackServiceException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException");
+               callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback);
+               callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2);
+               callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3);
+               callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution);
+               callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException);
+               callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException);
+
+               // Service Model
+               ModelInfo sModel = new ModelInfo();
+               sModel.setModelCustomizationUuid("testModelCustomizationUuid");
+               sModel.setModelInstanceName("testModelInstanceName");
+               sModel.setModelInvariantUuid("testModelInvariantId");
+               sModel.setModelName("testModelName");
+               sModel.setModelUuid("testModelUuid");
+               sModel.setModelVersion("testModelVersion");
+               // Service Instance
+               ServiceInstance si = new ServiceInstance();
+               si.setInstanceId("testServiceInstanceId123");
+               // Allotted Resources
+               List<AllottedResource> arList = new ArrayList<AllottedResource>();
+               AllottedResource ar = new AllottedResource();
+               ar.setResourceId("testResourceIdAR");
+               ar.setResourceInstanceName("testARInstanceName");
+               ModelInfo arModel = new ModelInfo();
+               arModel.setModelCustomizationUuid("testModelCustomizationUuidAR");
+               arModel.setModelInvariantUuid("testModelInvariantIdAR");
+               arModel.setModelName("testModelNameAR");
+               arModel.setModelVersion("testModelVersionAR");
+               arModel.setModelUuid("testARModelUuid");
+               arModel.setModelType("testModelTypeAR");
+               ar.setModelInfo(arModel);
+               AllottedResource ar2 = new AllottedResource();
+               ar2.setResourceId("testResourceIdAR2");
+               ar2.setResourceInstanceName("testAR2InstanceName");
+               ModelInfo arModel2 = new ModelInfo();
+               arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2");
+               arModel2.setModelInvariantUuid("testModelInvariantIdAR2");
+               arModel2.setModelName("testModelNameAR2");
+               arModel2.setModelVersion("testModelVersionAR2");
+               arModel2.setModelUuid("testAr2ModelUuid");
+               arModel2.setModelType("testModelTypeAR2");
+               ar2.setModelInfo(arModel2);
+               arList.add(ar);
+               arList.add(ar2);
+               // Vnfs
+               List<VnfResource> vnfList = new ArrayList<VnfResource>();
+               VnfResource vnf = new VnfResource();
+               vnf.setResourceId("testResourceIdVNF");
+               vnf.setResourceInstanceName("testVnfInstanceName");
+               ModelInfo vnfModel = new ModelInfo();
+               vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF");
+               vnfModel.setModelInvariantUuid("testModelInvariantIdVNF");
+               vnfModel.setModelName("testModelNameVNF");
+               vnfModel.setModelVersion("testModelVersionVNF");
+               vnfModel.setModelUuid("testVnfModelUuid");
+               vnfModel.setModelType("testModelTypeVNF");
+               vnf.setModelInfo(vnfModel);
+               vnfList.add(vnf);
+               System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString());
+               serviceDecomposition.setModelInfo(sModel);
+               serviceDecomposition.setServiceAllottedResources(arList);
+               serviceDecomposition.setServiceVnfs(vnfList);
+               serviceDecomposition.setServiceInstance(si);
+
+               // Subscriber
+               subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+               subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}";
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_success_2AR1Vnf() throws Exception {
+
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               injectWorkflowMessages(callbacks, "sniro");
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+               ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+               String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+
+               Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
+               HomingSolution resourceARHoming = resourceAR.getHomingSolution();
+               Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
+               HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
+               Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
+               HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
+               String resourceARHomingString = resourceARHoming.toString();
+               resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
+               String resourceARHoming2String = resourceARHoming2.toString();
+               resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
+               String resourceVNFHomingString = resourceVNFHoming.toString();
+               resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
+               expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
+               
+               assertNull(workflowException);
+               assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
+               assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String);
+               assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
+               assertEquals(verifySniroRequest(), expectedSniroRequest);
+
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_success_2AR1Vnf2Net() throws Exception {
+
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables2(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               injectWorkflowMessages(callbacks, "sniro2");
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+               ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+               String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+
+               Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR");
+               HomingSolution resourceARHoming = resourceAR.getHomingSolution();
+               Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2");
+               HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution();
+               Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF");
+               HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution();
+               Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet");
+               HomingSolution resourceNetHoming = resourceNet.getHomingSolution();
+               Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2");
+               HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution();
+
+               String resourceARHomingString = resourceARHoming.toString();
+               resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " ");
+               String resourceARHoming2String = resourceARHoming2.toString();
+               resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " ");
+               String resourceVNFHomingString = resourceVNFHoming.toString();
+               resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " ");
+               String resourceNetHomingString = resourceNetHoming.toString();
+               resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " ");
+               String resourceNetHoming2String = resourceNetHoming2.toString();
+               resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " ");
+               expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", "");
+
+               assertNull(workflowException);
+               assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString);
+               assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String);
+               assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString);
+               assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic", "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString);
+               assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String);
+               assertEquals(verifySniroRequest(), expectedSniroRequest);
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_success_vnfResourceList() throws Exception {
+
+               // Create a Service Decomposition 
+//System.out.println("At start of testHoming_success_vnfResourceList");
+               MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json");
+               String busKey = UUID.randomUUID().toString();
+               Map<String, Object> vars = new HashMap<String, Object>();
+               setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
+               invokeSubProcess("DecomposeService", busKey, vars);
+               
+               ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition");
+//System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd);
+               List<VnfResource> vnfResourceList = sd.getServiceVnfs();
+//System.out.println(" vnfResourceList = " + vnfResourceList);
+               vnfResourceList.get(0).setResourceId("test-resource-id-000");
+               
+               // Invoke Homing        
+               
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               variables.put("isDebugLogEnabled", "true");
+               variables.put("msoRequestId", "testRequestId");
+               variables.put("serviceInstanceId", "testServiceInstanceId");
+               variables.put("serviceDecomposition", sd);
+               variables.put("subscriberInfo", subscriber2);
+               
+               invokeSubProcess("Homing", businessKey, variables);
+               injectWorkflowMessages(callbacks, "sniro3");
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+               ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition");
+
+               Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000");
+               HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution();
+
+               String resourceVnfHomingString = resourceVnfHoming.toString();
+               resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " ");
+
+               assertNull(workflowException);
+
+               //Verify request
+               String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest");
+               assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""));
+               
+               assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "att-aic", "mtmnj1a", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString);
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_error_inputVariable() throws Exception {
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables3(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+               assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]", workflowException.toString());
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_error_badResponse() throws Exception {
+               mockSNIRO_500();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+               assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro.]", workflowException.toString());
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_error_sniroNoSolution() throws Exception {
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               injectWorkflowMessages(callbacks, "sniroNoSol");
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+               assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString());
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_error_sniroPolicyException() throws Exception {
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               injectWorkflowMessages(callbacks, "sniroPolicyEx");
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+               assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]", workflowException.toString());
+       }
+
+       @Test
+       @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"})
+       public void testHoming_error_sniroServiceException() throws Exception {
+               mockSNIRO();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               setVariables(variables);
+
+               invokeSubProcess("Homing", businessKey, variables);
+
+               injectWorkflowMessages(callbacks, "sniroServiceEx");
+
+               waitForProcessEnd(businessKey, 10000);
+
+               //Get Variables
+               WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+
+               assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", workflowException.toString());
+       }
+       
+
+
+       private void setVariables(Map<String, Object> variables) {
+               variables.put("isDebugLogEnabled", "true");
+       //      variables.put("mso-request-id", "testRequestId");
+               variables.put("msoRequestId", "testRequestId");
+               variables.put("serviceInstanceId", "testServiceInstanceId");
+               variables.put("serviceDecomposition", serviceDecomposition);
+               variables.put("subscriberInfo", subscriber2);
+
+       }
+
+       private void setVariables2(Map<String, Object> variables) {
+               List<NetworkResource> netList = new ArrayList<NetworkResource>();
+               NetworkResource net = new NetworkResource();
+               net.setResourceId("testResourceIdNet");
+               ModelInfo netModel = new ModelInfo();
+               netModel.setModelCustomizationUuid("testModelCustomizationUuidNet");
+               netModel.setModelInvariantUuid("testModelInvariantIdNet");
+               netModel.setModelName("testModelNameNet");
+               netModel.setModelVersion("testModelVersionNet");
+               net.setModelInfo(netModel);
+               netList.add(net);
+               NetworkResource net2 = new NetworkResource();
+               net2.setResourceId("testResourceIdNet2");
+               ModelInfo netModel2 = new ModelInfo();
+               netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2");
+               netModel2.setModelInvariantUuid("testModelInvariantIdNet2");
+               netModel2.setModelName("testModelNameNet2");
+               netModel2.setModelVersion("testModelVersionNet2");
+               net2.setModelInfo(netModel2);
+               netList.add(net2);
+               serviceDecomposition.setServiceNetworks(netList);
+
+               variables.put("isDebugLogEnabled", "true");
+               variables.put("msoRequestId", "testRequestId");
+               variables.put("serviceInstanceId", "testServiceInstanceId");
+               variables.put("serviceDecomposition", serviceDecomposition);
+               variables.put("subscriberInfo", subscriber2);
+       }
+
+       private void setVariables3(Map<String, Object> variables) {
+               variables.put("isDebugLogEnabled", "true");
+       //      variables.put("mso-request-id", "testRequestId");
+               variables.put("msoRequestId", "testRequestId");
+               variables.put("serviceInstanceId", "testServiceInstanceId");
+               variables.put("serviceDecomposition", null);
+               variables.put("subscriberInfo", subscriber2);
+
+       }
+
+       private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){
+               String solution = "";
+               if(enList == null){
+                       solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\" } }";
+               }else{
+                       solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"entitlementPoolList\" : [ " + enList +  " ], \"licenseKeyGroupList\" : [ " + licenseList +  " ] } }";
+               }
+               return solution;
+       }
+
+       private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){
+               String solution = "";
+               if(enList == null){
+                       solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\" } }";
+               }else{
+                       solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"entitlementPoolList\" : [ " + enList +  " ], \"licenseKeyGroupList\" : [ " + licenseList +  " ] } }";
+               }
+               return solution;
+       }
+       
+       private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) {
+               variables.put("isDebugLogEnabled", "true");
+               variables.put("mso-request-id", requestId);
+               variables.put("msoRequestId", requestId);
+               variables.put("serviceInstanceId",siId);
+
+               String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," +
+                               "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\"," +
+                               "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\"," +
+                               "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," +
+                               "\"modelVersion\": \"5.0\"," +
+                               "}";
+               variables.put("serviceModelInfo", serviceModelInfo);
+       }
+               
+       private String verifySniroRequest(){
+               String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:8090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":600},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}";
+               return request;
+       }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java
new file mode 100644 (file)
index 0000000..e9373ee
--- /dev/null
@@ -0,0 +1,122 @@
+package org.openecomp.mso.bpmn.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+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.Test;
+import org.openecomp.mso.bpmn.common.WorkflowTest;
+import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet;
+import org.openecomp.mso.bpmn.core.WorkflowException;
+
+/**
+ * Unit tests for SDNCAdapterRestV1.
+ */
+public class ReceiveWorkflowMessageTest extends WorkflowTest {
+
+       private static final String EOL = "\n";
+
+       private final CallbackSet callbacks = new CallbackSet();
+
+       public ReceiveWorkflowMessageTest() throws IOException {
+               callbacks.put("sdnc-event-success", JSON, "SDNCAEvent",
+                       "{" + EOL +
+                       "  \"SDNCEvent\": {" + EOL +
+                       "    \"eventType\": \"UCPE-ACTIVATION\"," + EOL +
+                       "    \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL +
+                       "    \"eventCorrelator\": \"((CORRELATOR))\"," + EOL +
+                       "    \"params\": {\"entry\":[" + EOL +
+                       "      {\"key\": \"success-indicator\", \"value\":\"Y\"}" + EOL +
+                       "        ]}" +EOL +
+                       "  }" + EOL +
+                       "}" + EOL);
+
+               callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent",
+                       "{" + EOL +
+                       "  \"SDNCEvent\": {" + EOL +
+                       "    \"eventType\": \"UCPE-ACTIVATION\"," + EOL +
+                       "    \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL +
+                       "    \"eventCorrelator\": \"((CORRELATOR))\"," + EOL +
+                       "    \"params\": {\"entry\":[" + EOL +
+                       "      {\"key\": \"success-indicator\", \"value\":\"N\"}" + EOL +
+                       "      {\"key\": \"error-message\", \"value\":\"SOMETHING BAD HAPPENED\"}" + EOL +
+                       "        ]}" +EOL +
+                       "  }" + EOL +
+                       "}" + EOL);
+       }
+
+       /**
+        * Test the happy path.
+        */
+       @Test
+       @Deployment(resources = {
+               "subprocess/ReceiveWorkflowMessage.bpmn"
+               })
+       public void happyPath() throws Exception {
+               
+               logStart();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
+               variables.put("isDebugLogEnabled", "true");
+               variables.put("RCVWFMSG_timeout", "PT1M");
+               variables.put("RCVWFMSG_messageType", "SDNCAEvent");
+               variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
+
+               invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
+               injectWorkflowMessages(callbacks, "sdnc-event-success");
+               waitForProcessEnd(businessKey, 10000);
+
+               String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
+               System.out.println("Response:\n" + response);
+               assertTrue(response.contains("\"SDNCEvent\""));
+               assertTrue((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
+               
+               logEnd();
+       }
+
+       /**
+        * Test the timeout scenario.
+        */
+       @Test
+       @Deployment(resources = {
+               "subprocess/ReceiveWorkflowMessage.bpmn"
+               })
+       public void timeout() throws Exception {
+               logStart();
+
+               String businessKey = UUID.randomUUID().toString();
+               Map<String, Object> variables = new HashMap<String, Object>();
+               variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312");
+               variables.put("isDebugLogEnabled", "true");
+               variables.put("RCVWFMSG_timeout", "PT0.1S");
+               variables.put("RCVWFMSG_messageType", "SDNCAEvent");
+               variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31");
+
+               invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables);
+
+               // No injection
+               
+               waitForProcessEnd(businessKey, 10000);
+               
+               // There is no response from SDNC, so the flow doesn't set WorkflowResponse.
+               String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse");
+               assertNull(response);
+               WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
+               assertNotNull(wfe);
+               System.out.println(wfe.toString());
+               assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage());
+               assertFalse((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator"));
+               
+               logEnd();
+       }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/catalogResp.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/catalogResp.json
new file mode 100644 (file)
index 0000000..0fdada5
--- /dev/null
@@ -0,0 +1,46 @@
+{
+   "serviceResources": {
+      "serviceType": null,
+      "serviceAllottedResources": [],
+      "modelInfo": {
+         "modelInvariantUuid": "1cc4e2e4-eb6e-404d-a66f-c8733cedcce8",
+         "modelName": "ADIOD vRouter vCE 011017 Service",
+         "modelVersion": "5.0",
+         "modelUuid": "2f7f309d-c842-4644-a2e4-34167be5eeb4"
+      },
+      "serviceRole": null,
+      "serviceVnfs": [
+         {
+            "toscaNodeType": "org.openecomp.resource.vf.AdiodVce",
+            "vfModules": [
+               {
+                  "initialCount": null,
+                  "vfModuleLabel": null,
+                  "modelInfo": {
+                     "modelInvariantUuid": "7fb428e1-8000-4800-a71a-f21b946973c5",
+                     "modelName": "AdiodVce..base_vCE..module-0",
+                     "modelVersion": "2",
+                     "modelCustomizationUuid": "1126e7e2-b377-4fd2-ad48-660a20caa829",
+                     "modelUuid": "435d57e1-93a2-4d58-aa5d-f2df2d126276"
+                  },
+                  "hasVolumeGroup": true,
+                  "isBase": true
+               }
+            ],
+            "modelInfo": {
+               "modelInvariantUuid": "fc72435b-4366-4257-a2f7-c70a3a998a7b",
+               "modelName": "ADIoD vCE",
+               "modelVersion": "2.0",
+               "modelCustomizationUuid": "bdaeed40-c964-4966-bdb8-51320dcaf587",
+               "modelInstanceName": "ADIoD vCE 0",
+               "modelUuid": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1"
+            },
+            "nfRole": "",
+            "nfType": "",
+            "nfFunction": "",
+            "nfNamingCode": ""
+         }
+      ],
+      "serviceNetworks": []
+   }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf
new file mode 100644 (file)
index 0000000..19f18cc
--- /dev/null
@@ -0,0 +1,107 @@
+{
+    "transactionId": "testRequestId",
+       "requestId": "testRequestId",
+       "requestState": "complete",
+       "statusMessage": "",
+    "solutionInfo": {
+        "licenseInfo": [
+            {
+                "entitlementPoolList": [
+                    "f1d563e8-e714-4393-8f99-cc480144a05e",
+                    "j1d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "licenseKeyGroupList": [
+                    "s1d563e8-e714-4393-8f99-cc480144a05e",
+                    "b1d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "resourceModuleName": "vHNPortalaaS_primary_1",
+                "serviceResourceId": "testResourceIdAR"
+            },
+            {
+                "entitlementPoolList": [
+                    "91d563e8-e714-4393-8f99-cc480144a05e",
+                    "21d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "licenseKeyGroupList": [
+                    "31d563e8-e714-4393-8f99-cc480144a05e",
+                    "71d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "resourceModuleName": "vHNPortalaaS_secondary_1",
+                "serviceResourceId": "testResourceIdVNF"
+            }
+        ],
+        "placement": [
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "vnfHostName",
+                        "variableValue": "MDTNJ01"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "KDTNJ01"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "dfwtx",
+                "inventoryType": "service",
+                "resourceModuleName": "ALLOTTED_RESOURCE",
+                "serviceInstanceId": "testSIID1",
+                "serviceResourceId": "testResourceIdAR"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "vnfHostName",
+                        "variableValue": "testVnfHostname2"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClli2"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionId2",
+                "inventoryType": "service",
+                "resourceModuleName": "ALLOTTED_RESOURCE",
+                "serviceInstanceId": "testSIID2",
+                "serviceResourceId": "testResourceIdAR2"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClli3"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionId3",
+                "inventoryType": "cloud",
+                "resourceModuleName": "VNF",
+                "serviceInstanceId": "",
+                "serviceResourceId": "testResourceIdVNF"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallback2AR1Vnf2Net
new file mode 100644 (file)
index 0000000..5a9ef4b
--- /dev/null
@@ -0,0 +1,165 @@
+{
+    "transactionId": "testRequestId",
+       "requestId": "testRequestId",
+       "requestState": "complete",
+       "statusMessage": "",
+    "solutionInfo": {
+        "licenseInfo": [
+            {
+                "entitlementPoolList": [
+                    "f1d563e8-e714-4393-8f99-cc480144a05e",
+                    "j1d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "licenseKeyGroupList": [
+                    "s1d563e8-e714-4393-8f99-cc480144a05e",
+                    "b1d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "resourceModuleName": "vHNPortalaaS_primary_1",
+                "serviceResourceId": "testResourceIdAR"
+            },
+            {
+                "entitlementPoolList": [
+                    "f1d563e8-e714-4393-8f99-cc480144a05n",
+                    "j1d563e8-e714-4393-8f99-cc480144a05n"
+                ],
+                "licenseKeyGroupList": [
+                    "s1d563e8-e714-4393-8f99-cc480144a05n",
+                    "b1d563e8-e714-4393-8f99-cc480144a05n"
+                ],
+                "resourceModuleName": "net",
+                "serviceResourceId": "testResourceIdNet2"
+            },
+            {
+                "entitlementPoolList": [
+                    "91d563e8-e714-4393-8f99-cc480144a05e",
+                    "21d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "licenseKeyGroupList": [
+                    "31d563e8-e714-4393-8f99-cc480144a05e",
+                    "71d563e8-e714-4393-8f99-cc480144a05e"
+                ],
+                "resourceModuleName": "vHNPortalaaS_secondary_1",
+                "serviceResourceId": "testResourceIdVNF"
+            }
+        ],
+        "placement": [
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "vnfHostName",
+                        "variableValue": "MDTNJ01"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "KDTNJ01"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "dfwtx",
+                "inventoryType": "service",
+                "resourceModuleName": "ALLOTTED_RESOURCE",
+                "serviceInstanceId": "testSIID1",
+                "serviceResourceId": "testResourceIdAR"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "vnfHostName",
+                        "variableValue": "testVnfHostname2"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClli2"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionId2",
+                "inventoryType": "service",
+                "resourceModuleName": "ALLOTTED_RESOURCE",
+                "serviceInstanceId": "testSIID2",
+                "serviceResourceId": "testResourceIdAR2"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "vnfHostName",
+                        "variableValue": "testVnfHostNameNet"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClliNet"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionIdNet",
+                "inventoryType": "service",
+                "resourceModuleName": "NETWORK",
+                "serviceInstanceId": "testServiceInstanceIdNet",
+                "serviceResourceId": "testResourceIdNet"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClliNet2"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionIdNet2",
+                "inventoryType": "cloud",
+                "resourceModuleName": "NETWORK",
+                "serviceInstanceId": "",
+                "serviceResourceId": "testResourceIdNet2"
+            },
+            {
+                "assignmentInfo": [
+                    {
+                        "variableName": "cloudOwner",
+                        "variableValue": "aic"
+                    },
+                    {
+                        "variableName": "aicClli",
+                        "variableValue": "testAicClli3"
+                    },
+                    {
+                        "variableName": "aicVersion",
+                        "variableValue": "3.0"
+                    }
+                ],
+                "cloudRegionId": "testCloudRegionId3",
+                "inventoryType": "cloud",
+                "resourceModuleName": "VNF",
+                "serviceInstanceId": "",
+                "serviceResourceId": "testResourceIdVNF"
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackInfraVnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackInfraVnf
new file mode 100644 (file)
index 0000000..f80ff65
--- /dev/null
@@ -0,0 +1,49 @@
+{
+   "transactionId": "testRequestId",
+   "requestId": "testRequestId",
+   "requestState": "complete",
+   "statusMessage": "",
+   "solutionInfo": {
+      "placement": [
+         {
+            "serviceResourceId": "test-resource-id-000",
+            "resourceModuleName": "ADIOD vRouter vCE",
+            "inventoryType": "service",
+            "serviceInstanceId": "service-instance-01234",
+            "cloudRegionId": "mtmnj1a",
+            "assignmentInfo": [
+               {
+                  "variableName": "cloudOwner",
+                  "variableValue": "att-aic"
+               },
+               {
+                  "variableName": "vnfHostName",
+                  "variableValue": "MDTNJ01"
+               },
+               {
+                  "variableName": "aicClli",
+                  "variableValue": "KDTNJ01"
+               },
+               {
+                  "variableName": "aicVersion",
+                  "variableValue": "3.0"
+               }
+            ]
+         }
+      ],
+      "licenseInfo": [
+         {
+            "serviceResourceId": "test-resource-id-000",
+            "resourceModuleName": "ADIOD vRouter vCE",
+            "entitlementPoolList": [
+               "f1d563e8-e714-4393-8f99-cc480144a05e",
+               "j1d563e8-e714-4393-8f99-cc480144a05e"
+            ],
+            "licenseKeyGroupList": [
+               "s1d563e8-e714-4393-8f99-cc480144a05e",
+               "b1d563e8-e714-4393-8f99-cc480144a05e"
+            ]
+         }
+      ]
+   }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackNoSolutionFound
new file mode 100644 (file)
index 0000000..5cb748a
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "requestState": "",
+  "responseTime": "",
+  "solutionInfo": {
+    "placement": [],
+    "licenseInfo": {
+      "featureGroupId": ""
+    }
+  },
+  "percentProgress": "",
+  "requestId": "02c2e322-5839-4c97-9d46-0a5fa6bb642e",
+  "startTime": "",
+  "statusMessage": "No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8",
+  "requestType": ""
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackPolicyException
new file mode 100644 (file)
index 0000000..b826884
--- /dev/null
@@ -0,0 +1,9 @@
+{
+       "requestError": {
+               "policyException": {
+                 "requestId": "ae81d9a8-c949-493a-999c-f76c80503233",
+                 "text": "Message content size exceeds the allowable limit",
+                 "messageId": "SVC0001"
+               }
+       }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroCallbackServiceException
new file mode 100644 (file)
index 0000000..6cc78a7
--- /dev/null
@@ -0,0 +1,12 @@
+{
+       "requestError": {
+               "serviceException": {
+               "variables": [
+               "severity", 400
+               ],
+                "requestId": "ae81d9a8-c949-493a-999c-f76c80503233",
+                 "text": "SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8",
+                  "messageId": "SVC0001"
+               }
+       }
+}
\ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroRequest_infravnf b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/sniroRequest_infravnf
new file mode 100644 (file)
index 0000000..2af6bf3
--- /dev/null
@@ -0,0 +1,65 @@
+{
+               "requestInfo": {
+                               "transactionId": "testRequestId",
+                               "requestId": "testRequestId",
+                               "callbackUrl": "http://localhost:8090/workflows/messages/message/SNIROResponse/testRequestId",
+                               "sourceId": "mso",
+                               "optimizer": [
+                                       "placement",
+                                       "license"
+                               ],
+                               "numSolutions": 1,
+                               "timeout": 600
+                               },
+               "placementInfo": {
+                       "serviceModelInfo": {
+                               "modelType": "",
+                               "modelInvariantId": "1cc4e2e4-eb6e-404d-a66f-c8733cedcce8",
+                               "modelVersionId": "2f7f309d-c842-4644-a2e4-34167be5eeb4",
+                               "modelName": "ADIOD vRouter vCE 011017 Service",
+                               "modelVersion": "5.0"
+                               },
+                       "subscriberInfo": {
+                               "globalSubscriberId": "SUB12_0322_DS_1201",
+                               "subscriberName": "SUB_12_0322_DS_1201",
+                               "subscriberCommonSiteId": ""
+                               },
+                       "demandInfo": {
+                               "placementDemand": [
+                                       {
+                                               "resourceInstanceType": "VNF",
+                                               "serviceResourceId": "test-resource-id-000",
+                                               "resourceModuleName": "ADIoD vCE 0",
+                                               "resourceModelInfo": {
+                                                       "modelCustomizationId": "bdaeed40-c964-4966-bdb8-51320dcaf587",
+                                                       "modelInvariantId": "fc72435b-4366-4257-a2f7-c70a3a998a7b",
+                                                       "modelName": "ADIoD vCE",
+                                                       "modelVersion": "2.0",
+                                                       "modelVersionId": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1",
+                                                       "modelType": ""
+                                               },
+                                               "tenantId": "",
+                                               "tenantName": ""
+                                       }
+                               ],
+                               "licenseDemand": [
+                                       {
+                                               "resourceInstanceType": "VNF",
+                                               "serviceResourceId": "test-resource-id-000",
+                                               "resourceModuleName": "ADIoD vCE 0",
+                                               "resourceModelInfo": {
+                                                       "modelCustomizationId": "bdaeed40-c964-4966-bdb8-51320dcaf587",
+                                                       "modelInvariantId": "fc72435b-4366-4257-a2f7-c70a3a998a7b",
+                                                       "modelName": "ADIoD vCE",
+                                                       "modelVersion": "2.0",
+                                                       "modelVersionId": "ec2bd873-5b2c-47e4-8858-f0495fa1dae1",
+                                                       "modelType": ""
+                                               }
+                                       }
+                               ]
+                       },
+                       "policyId": [],
+                       "serviceInstanceId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+                       "orderInfo": "{\"requestParameters\": null}"
+               }
+         }
\ No newline at end of file
index c764c7f..9829dda 100644 (file)
@@ -113,3 +113,11 @@ policyClientAuth=Basic bTAzNzQzOnBvbGljeVIwY2sk
 policyAuth=Basic dGVzdHBkcDphbHBoYTEyMw==\r
 policyEnvironment=TEST\r
 policyEndpoint=localhost:8080/pdp/api/getDecision\r
+\r
+mso.sniro.auth=test:testpwd\r
+mso.sniro.endpoint=http://localhost:28090/optimizationInstance/V1/create\r
+mso.sniro.callback=http://localhost:28090/adapters/rest/SDNCNotify/SNIROResponse\r
+mso.sniro.timeout=PT30M\r
+mso.service.agnostic.sniro.host=http://localhost:28090\r
+mso.service.agnostic.sniro.endpoint=/sniro/api/v2/placement\r
+mso.adapters.workflow.message.endpoint=http://localhost:8090/workflows/messages/message\r
diff --git a/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java b/bpmn/MSOMockServer/src/main/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java
new file mode 100644 (file)
index 0000000..a8152d6
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.\r
+ */\r
+package org.openecomp.mso.bpmn.mock;\r
+\r
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\r
+import static com.github.tomakehurst.wiremock.client.WireMock.post;\r
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\r
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;\r
+\r
+/**\r
+ * Please describe the StubResponseSNIRO.java class\r
+ *\r
+ * @author cb645j\r
+ */\r
+public class StubResponseSNIRO {\r
+\r
+       public static void setupAllMocks() {\r
+\r
+       }\r
+\r
+       public static void mockSNIRO() {\r
+               stubFor(post(urlEqualTo("/sniro/api/v2/placement"))\r
+                               .willReturn(aResponse()\r
+                                               .withStatus(202)\r
+                                               .withHeader("Content-Type", "application/json")));\r
+       }\r
+\r
+       public static void mockSNIRO(String responseFile) {\r
+               stubFor(post(urlEqualTo("/sniro/api/v2/placement"))\r
+                               .willReturn(aResponse()\r
+                                               .withStatus(202)\r
+                                               .withHeader("Content-Type", "application/json")\r
+                                               .withBodyFile(responseFile)));\r
+       }\r
+\r
+       public static void mockSNIRO_400() {\r
+               stubFor(post(urlEqualTo("/sniro/api/v2/placement"))\r
+                               .willReturn(aResponse()\r
+                                               .withStatus(400)\r
+                                               .withHeader("Content-Type", "application/json")));\r
+       }\r
+\r
+       public static void mockSNIRO_500() {\r
+               stubFor(post(urlEqualTo("/sniro/api/v2/placement"))\r
+                               .willReturn(aResponse()\r
+                                               .withStatus(500)\r
+                                               .withHeader("Content-Type", "application/json")));\r
+       }\r
+\r
+}\r