Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / ConfirmVolumeGroupTenantIT.java
1 /*
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
3  */
4 /*- 
5  * ============LICENSE_START======================================================= 
6  * ONAP - SO 
7  * ================================================================================ 
8  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. 
9  * ================================================================================ 
10  * Licensed under the Apache License, Version 2.0 (the "License"); 
11  * you may not use this file except in compliance with the License. 
12  * You may obtain a copy of the License at 
13  * 
14  *      http://www.apache.org/licenses/LICENSE-2.0 
15  * 
16  * Unless required by applicable law or agreed to in writing, software 
17  * distributed under the License is distributed on an "AS IS" BASIS, 
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
19  * See the License for the specific language governing permissions and 
20  * limitations under the License. 
21  * ============LICENSE_END========================================================= 
22  */
23
24 package org.onap.so.bpmn.common;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
28 import java.util.HashMap;
29 import java.util.Map;
30 import java.util.UUID;
31 import org.junit.Test;
32 import org.onap.so.BaseIntegrationTest;
33
34 /**
35  * Please describe the ConfirmVolumeGroupTenantTest.java class
36  *
37  */
38
39 public class ConfirmVolumeGroupTenantIT extends BaseIntegrationTest {
40
41     @Test
42     public void testRemoveLayer3Service_success() throws Exception {
43         MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58",
44                 "CRTGVNF_queryAAIResponseVolume.xml");
45
46         Map<String, Object> variables = new HashMap<>();
47         setVariables(variables);
48
49         String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
50
51         String actualNameMatch =
52                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch", processId);
53         String actualIdMatch =
54                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch", processId);
55         String actualResponse =
56                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "volumeHeatStackId", processId);
57
58         assertEquals("Response", "true", actualNameMatch);
59         assertEquals("Response", "true", actualIdMatch);
60         assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse);
61     }
62
63     @Test
64     public void testRemoveLayer3Service_idsNotMatch() throws Exception {
65         MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58",
66                 "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
67
68         Map<String, Object> variables = new HashMap<>();
69         setVariables(variables);
70
71         String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);
72
73
74         String actualNameMatch =
75                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch", processId);
76         String actualIdMatch =
77                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch", processId);
78         String actualResponse =
79                 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "WorkflowException", processId);
80
81         assertEquals("Response", "true", actualNameMatch);
82         assertEquals("Response", "false", actualIdMatch);
83         assertEquals("Response",
84                 "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant,workStep=*]",
85                 actualResponse);
86
87     }
88
89     private void setVariables(Map<String, Object> variables) {
90         variables.put("isDebugLogEnabled", "true");
91         variables.put("volumeGroupId", "a8399879-31b3-4973-be26-0a0cbe776b58");
92         variables.put("tenantId", "7dd5365547234ee8937416c65507d266");
93         variables.put("aicCloudRegion", "MDTWNJ21");
94         variables.put("mso-request-id", UUID.randomUUID().toString());
95     }
96 }