Change the header to SO
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / ConfirmVolumeGroupNameTest.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.common;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 import org.camunda.bpm.engine.RuntimeService;
30 import org.camunda.bpm.engine.test.Deployment;
31 import org.junit.Test;
32
33 /**
34  * Unit test cases for ConfirmVolumeGroupName.bpmn
35  */
36 public class ConfirmVolumeGroupNameTest extends WorkflowTest {
37         /**
38          * Sunny day scenario.
39          * 
40          * @throws Exception
41          */
42         @Test
43         @Deployment(resources = {
44                 "subprocess/ConfirmVolumeGroupName.bpmn"
45                 })
46         public void sunnyDay() throws Exception {
47                                 
48                 logStart();
49                 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
50                 
51                 System.out.println("Before starting process");
52                 
53                 RuntimeService runtimeService = processEngineRule.getRuntimeService();                          
54                 Map<String, Object> variables = new HashMap<String, Object>();          
55                 variables.put("isDebugLogEnabled","true");
56                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
57                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
58                 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
59                 System.out.println("after setting variables");
60                 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
61                 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
62                 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
63                                         
64                 assertEquals("200", responseCode);
65                 System.out.println(response);
66                 logEnd();
67         }
68         
69         /**
70          * Rainy day scenario - nonexisting volume group id.
71          * 
72          * @throws Exception
73          */
74         @Test
75         @Deployment(resources = {
76                 "subprocess/ConfirmVolumeGroupName.bpmn"
77                 })
78         public void rainyDayNoVolumeGroupId() throws Exception {
79                                 
80                 logStart();
81                 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
82                 
83                 System.out.println("Before starting process");
84                 
85                 RuntimeService runtimeService = processEngineRule.getRuntimeService();                          
86                 Map<String, Object> variables = new HashMap<String, Object>();          
87                 variables.put("isDebugLogEnabled","true");
88                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST");
89                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg");
90                 System.out.println("after setting variables");
91                 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
92                 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
93                 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
94                                         
95                 assertEquals("404", responseCode);
96                 System.out.println(response);
97                 
98                 logEnd();
99         }
100         
101         /**
102          * Rainy day scenario - volume group name does not match the name in AAI
103          *
104          * 
105          * @throws Exception
106          */
107         @Test
108         @Deployment(resources = {
109                 "subprocess/ConfirmVolumeGroupName.bpmn"
110                 })
111         public void rainyDayNameDoesNotMatch() throws Exception {
112                                 
113                 logStart();
114                 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
115                 
116                 System.out.println("Before starting process");
117                 
118                 RuntimeService runtimeService = processEngineRule.getRuntimeService();                          
119                 Map<String, Object> variables = new HashMap<String, Object>();          
120                 variables.put("isDebugLogEnabled","true");
121                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
122                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
123                 System.out.println("after setting variables");
124                 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
125                 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
126                 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
127                                         
128                 assertEquals("404", responseCode);
129                 System.out.println(response);
130                 
131                 logEnd();
132         }
133 }