1 package org.openecomp.mso.bpmn.infrastructure;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
6 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
7 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer;
8 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
9 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
10 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;
11 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
12 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
13 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
15 import java.io.IOException;
16 import java.util.HashMap;
18 import java.util.UUID;
20 import org.camunda.bpm.engine.test.Deployment;
21 import org.junit.Test;
22 import org.openecomp.mso.bpmn.common.BPMNUtil;
23 import org.openecomp.mso.bpmn.common.WorkflowTest;
24 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
25 import org.openecomp.mso.bpmn.mock.FileUtil;
28 * Unit test cases for CreateGenericALaCarteServiceInstance.bpmn
30 public class CreateGenericALaCarteServiceInstanceTest extends WorkflowTest {
32 private final CallbackSet callbacks = new CallbackSet();
34 public CreateGenericALaCarteServiceInstanceTest() throws IOException {
35 callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCSITopologyAssignCallback.xml"));
39 * Sunny day VID scenario.
43 //@Ignore // File not found - unable to run the test. Also, Stubs need updating..
45 @Deployment(resources = {
46 "process/CreateGenericALaCarteServiceInstance.bpmn",
47 "subprocess/DoCreateServiceInstance.bpmn",
48 "subprocess/DoCreateServiceInstanceRollback.bpmn",
49 "subprocess/SDNCAdapterV1.bpmn",
50 "subprocess/GenericPutService.bpmn",
51 "subprocess/GenericGetService.bpmn",
52 "subprocess/CompleteMsoProcess.bpmn",
53 "subprocess/FalloutHandler.bpmn" })
54 public void sunnyDayAlaCarte() throws Exception {
59 MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml");
60 MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "");
61 MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "GenericFlows/getServiceInstance.xml");
62 MockNodeQueryServiceInstanceByName("RAATest-1", "");
63 MockNodeQueryServiceInstanceById("RaaTest-1-id", "");
67 mockUpdateRequestDB(200, "DBUpdateResponse.xml");
70 String businessKey = UUID.randomUUID().toString();
72 //String createVfModuleRequest = FileUtil.readResourceFile("__files/SIRequest.json");
74 Map<String, String> variables = setupVariables();
75 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateGenericALaCarteServiceInstance", variables);
76 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
78 String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowResponse");
79 //assertNotNull(workflowResp);
80 System.out.println("Workflow (Synch) Response:\n" + workflowResp);
81 String workflowException = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowException");
82 String completionReq = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "completionRequest");
83 System.out.println("completionReq:\n" + completionReq);
84 System.out.println("workflowException:\n" + workflowException);
85 assertNotNull(completionReq);
86 assertEquals(null, workflowException);
89 //injectSDNCCallbacks(callbacks, "assign");
95 private Map<String, String> setupVariables() {
96 Map<String, String> variables = new HashMap<String, String>();
97 variables.put("isDebugLogEnabled", "true");
98 variables.put("bpmnRequest", getRequest());
99 variables.put("mso-request-id", "RaaCSIRequestId-1");
100 variables.put("serviceInstanceId","RaaTest-1-id");
104 public String getRequest() {
105 String request = "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"},\"subscriberInfo\":{\"globalSubscriberId\":\"MCBH-1610\",\"subscriberName\":\"Kaneohe\"},\"requestInfo\":{\"instanceName\":\"RAATest-1\",\"source\":\"VID\",\"suppressRollback\":\"true\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\"},\"requestParameters\":{\"subscriptionServiceType\":\"viprsvc\",\"aLaCarte\":\"false\",\"userParams\":[]}}}";