Merge "Cleanup project's name in Sonar"
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / infrastructure / DoCreateServiceInstanceTest.java
1 package org.openecomp.mso.bpmn.infrastructure;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer;
5 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
6 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
7 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;
8 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
9 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
10 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
11
12 import java.io.IOException;
13 import java.util.HashMap;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import org.camunda.bpm.engine.test.Deployment;
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.openecomp.mso.bpmn.common.BPMNUtil;
21 import org.openecomp.mso.bpmn.common.WorkflowTest;
22
23 /**
24  * Unit test cases for DoCreateServiceInstance.bpmn
25  */
26 public class DoCreateServiceInstanceTest extends WorkflowTest {
27         private static final String EOL = "\n";
28         private final CallbackSet callbacks = new CallbackSet();
29         private final String sdncAdapterCallback =
30                         "<output xmlns=\"com:att:sdnctl:l3api\">" + EOL +
31                         "  <svc-request-id>((REQUEST-ID))</svc-request-id>" + EOL +
32                         "  <ack-final-indicator>Y</ack-final-indicator>" + EOL +
33                         "</output>" + EOL;
34                 
35         public DoCreateServiceInstanceTest() throws IOException {
36                 callbacks.put("assign", sdncAdapterCallback);
37         }
38                 
39         /**
40          * Sunny day VID scenario.
41          *
42          * @throws Exception
43          */
44         //@Ignore // File not found - unable to run the test.  Also, Stubs need updating..
45         @Test
46         @Deployment(resources = {
47                         "subprocess/DoCreateServiceInstance.bpmn",
48                         "subprocess/SDNCAdapterV1.bpmn",
49                         "subprocess/GenericGetService.bpmn",
50                         "subprocess/GenericPutService.bpmn",
51                         "subprocess/CompleteMsoProcess.bpmn",
52                         "subprocess/DoCreateServiceInstanceRollback.bpmn",
53                         "subprocess/FalloutHandler.bpmn" })
54         public void sunnyDay() throws Exception {
55
56                 logStart();
57
58                 //AAI
59                 MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml");
60                 MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", "");
61                 MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", "GenericFlows/getServiceInstance.xml");
62                 MockNodeQueryServiceInstanceByName("RAATest-si", "");
63                 
64                 MockNodeQueryServiceInstanceById("RaaTest-si-id", "");
65                 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml");
66                 MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
67                 //SDNC
68                 mockSDNCAdapter(200);
69                 //DB
70                 mockUpdateRequestDB(200, "DBUpdateResponse.xml");
71                 String businessKey = UUID.randomUUID().toString();
72
73                 Map<String, Object> variables =  new HashMap<String, Object>();
74                 setupVariables(variables);
75                 invokeSubProcess("DoCreateServiceInstance", businessKey, variables);
76                 injectSDNCCallbacks(callbacks, "assign");
77                 waitForProcessEnd(businessKey, 10000);
78                 Assert.assertTrue(isProcessEnded(businessKey));
79                 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateServiceInstance", "WorkflowException");
80                 System.out.println("workflowException:\n" + workflowException);
81                 assertEquals(null, workflowException);
82
83                 logEnd();
84         }
85
86         // Success Scenario
87         private void setupVariables(Map<String, Object> variables) {
88                 variables.put("mso-request-id", "RaaDSITest1");
89                 variables.put("isDebugLogEnabled", "true");
90                 variables.put("msoRequestId", "RaaDSITestRequestId-1");
91                 variables.put("serviceInstanceId","RaaTest-si-id");
92                 variables.put("serviceModelInfo", "{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"}");
93                 variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
94                 variables.put("globalSubscriberId", "MCBH-1610");
95                 variables.put("subscriptionServiceType", "viprsvc");
96                 variables.put("instanceName", "RAATest-1");
97         }
98 }