replace all fixed wiremock ports
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / ConfirmVolumeGroupNameIT.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.onap.so.bpmn.common;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
25
26 import java.util.HashMap;
27 import java.util.Map;
28 import java.util.UUID;
29
30 import org.camunda.bpm.engine.RuntimeService;
31 import org.camunda.bpm.engine.test.Deployment;
32 import org.junit.Ignore;
33 import org.junit.Test;
34 import org.onap.so.BaseIntegrationTest;
35
36 /**
37  * Unit test cases for ConfirmVolumeGroupName.bpmn
38  */
39
40 public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
41         /**
42          * Sunny day scenario.
43          * 
44          * @throws Exception
45          */
46         @Test   
47         public void sunnyDay() throws Exception {
48                 logStart();
49                 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");                
50                 
51                 Map<String, Object> variables = new HashMap<>();
52                 variables.put("isDebugLogEnabled","true");
53                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
54                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
55                 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
56                 variables.put("mso-request-id", UUID.randomUUID().toString());
57                 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
58                 String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode",processId);
59                                         
60                 assertEquals("200", responseCode);
61         
62                 logEnd();
63         }
64         
65         /**
66          * Rainy day scenario - nonexisting volume group id.
67          * 
68          * @throws Exception
69          */
70         @Test
71         public void rainyDayNoVolumeGroupId() throws Exception {
72                 logStart();
73                 
74                 // does not exist would return a 404 from AAI
75                 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST", "aai-volume-group-id-info.xml", 404);
76                                         
77                 Map<String, Object> variables = new HashMap<>();
78                 variables.put("isDebugLogEnabled","true");
79                 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
80                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST");
81                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg");
82                 variables.put("mso-request-id", UUID.randomUUID().toString());
83                 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);       
84                 String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode",processId);
85                                         
86                 assertEquals("404", responseCode);
87                 
88                 logEnd();
89         }
90         
91         /**
92          * Rainy day scenario - volume group name does not match the name in AAI
93          *
94          * 
95          * @throws Exception
96          */
97         @Test
98         public void rainyDayNameDoesNotMatch() throws Exception {
99                 logStart();
100                 
101                 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
102                                 
103                 Map<String, Object> variables = new HashMap<>();
104                 variables.put("isDebugLogEnabled","true");
105                 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
106                 variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
107                 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
108                 variables.put("mso-request-id", UUID.randomUUID().toString());
109                 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);               
110                 String volumeGroupNameMatches = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_volumeGroupNameMatches",processId);
111                 
112                 assertEquals("false", volumeGroupNameMatches);
113                 
114                 logEnd();
115         }
116 }