Merge "Reorder modifiers"
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / infrastructure / DoCreateServiceInstanceV2Test.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.bpmn.infrastructure;\r
22 \r
23 import static org.junit.Assert.assertEquals;\r
24 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;\r
25 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;\r
26 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;\r
27 \r
28 import java.io.IOException;\r
29 import java.util.HashMap;\r
30 import java.util.Map;\r
31 import java.util.UUID;\r
32 \r
33 import org.camunda.bpm.engine.test.Deployment;\r
34 import org.junit.Assert;\r
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.openecomp.mso.bpmn.common.BPMNUtil;\r
38 import org.openecomp.mso.bpmn.common.WorkflowTest;\r
39 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;\r
40 import org.openecomp.mso.bpmn.mock.FileUtil;\r
41 /**\r
42  * Unit test cases for DoCreateServiceInstanceV2.bpmn\r
43  */\r
44 public class DoCreateServiceInstanceV2Test extends WorkflowTest {\r
45         \r
46         private final String input = FileUtil.readResourceFile("__files/CreateServiceInstance/DoCreateServiceInstanceInput.json");\r
47         ServiceDecomposition serviceDecomposition = new ServiceDecomposition("{\"serviceResources\":{\"project\": {\"projectName\": \"projectName\"},\"owningEntity\": {\"owningEntityId\": \"id123\",\"owningEntityName\": \"name123\"}}}","abc123");\r
48 \r
49         public DoCreateServiceInstanceV2Test() throws IOException {\r
50                 \r
51                 \r
52         }\r
53                 \r
54         /**\r
55          * Sunny day VID scenario.\r
56          *\r
57          * @throws Exception\r
58          */\r
59         @Ignore // 1802 merge\r
60         @Test\r
61         @Deployment(resources = {\r
62                         "subprocess/DoCreateServiceInstanceV2.bpmn",\r
63                         "subprocess/SDNCAdapterV1.bpmn",\r
64                         "subprocess/CompleteMsoProcess.bpmn",\r
65                         "subprocess/DoCreateServiceInstanceRollback.bpmn",\r
66                         "subprocess/DoCreateServiceInstanceRollbackV2.bpmn",\r
67                         "subprocess/FalloutHandler.bpmn" })\r
68         \r
69         public void sunnyDay() throws Exception {\r
70 \r
71                 logStart();\r
72                 \r
73                 //SDNC\r
74                 mockSDNCAdapter(200);\r
75                 //DB\r
76                 mockUpdateRequestDB(200, "DBUpdateResponse.xml");\r
77                 //Catalog DB\r
78                 MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef","InfrastructureFlows/DoCreateServiceInstance_request.json");\r
79                 \r
80                 String businessKey = UUID.randomUUID().toString();\r
81 \r
82                 Map<String, Object> variables =  new HashMap<String, Object>();\r
83                 setupVariables(variables);\r
84                 invokeSubProcess("DoCreateServiceInstanceV2", businessKey, variables);\r
85                 waitForProcessEnd(businessKey, 10000);\r
86                 Assert.assertTrue(isProcessEnded(businessKey));\r
87                 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateServiceInstanceV2", "WorkflowException");\r
88                 System.out.println("workflowException:\n" + workflowException);\r
89                 assertEquals(null, workflowException);\r
90                 \r
91                 logEnd();\r
92         }\r
93 \r
94         // Success Scenario\r
95         private void setupVariables(Map<String, Object> variables) {\r
96                 variables.put("isDebugLogEnabled", "true");\r
97                 variables.put("msoRequestId", "RaaDSITestRequestId-1");\r
98                 variables.put("serviceInstanceId","RaaTest-si-id");\r
99                 //variables.put("serviceModelInfo", "{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\",\"projectName\":\"proj123\",\"owningEntityId\":\"id123\",\"owningEntityName\":\"name123\"}");\r
100                 variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");\r
101                 variables.put("globalSubscriberId", "MCBH-1610");\r
102                 variables.put("subscriptionServiceType", "viprsvc");\r
103                 variables.put("serviceInstanceName", "RAT-123");\r
104                 variables.put("sdncVersion", "1611");\r
105                 variables.put("serviceModelInfo", input);\r
106                 variables.put("serviceDecomposition", serviceDecomposition);\r
107                 variables.put("serviceType", "12e");\r
108         }\r
109 }