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