aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/java
diff options
context:
space:
mode:
authorArthur Martella <amartell@research.att.com>2017-09-21 16:09:46 -0400
committerArthur Martella <amartell@research.att.com>2017-09-21 16:09:46 -0400
commit902ec7ef30248c03096cf03da47e6bcca4372525 (patch)
treefcb000e29ade08e673d07e85b2358669ceb1e140 /bpmn/MSOCommonBPMN/src/test/java
parentc894e1dc433d49acd1b5adc4bcd338b1d148e465 (diff)
Move Homing Building Block into ONAP
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>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java457
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java122
2 files changed, 579 insertions, 0 deletions
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
index 0000000000..562a4d0731
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java
@@ -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
index 0000000000..e9373eeaf9
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java
@@ -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();
+ }
+}