fd1f7c1a2b084fd535dcbd2c08b82217c7fc39a2
[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
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.util.UUID;
32
33 import org.junit.Test;
34 import org.onap.so.BaseIntegrationTest;
35
36 /**
37  * Please describe the ConfirmVolumeGroupTenantTest.java class
38  *
39  */
40
41 public class ConfirmVolumeGroupTenantIT extends BaseIntegrationTest {
42
43         @Test   
44         public void testRemoveLayer3Service_success() throws Exception{
45                 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml");
46
47                 Map<String, Object> variables = new HashMap<>();
48                 setVariables(variables);
49
50                 String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);     
51
52                 String actualNameMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch",processId);
53                 String actualIdMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch",processId);
54                 String actualResponse = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "volumeHeatStackId",processId);
55
56                 assertEquals("Response", "true", actualNameMatch);
57                 assertEquals("Response", "true", actualIdMatch);
58                 assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse);
59         }
60
61         @Test   
62         public void testRemoveLayer3Service_idsNotMatch() throws Exception{
63                 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
64
65                 Map<String, Object> variables = new HashMap<>();
66                 setVariables(variables);
67
68                 String processId = invokeSubProcess("ConfirmVolumeGroupTenant", variables);     
69                 
70
71                 String actualNameMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "groupNamesMatch",processId);
72                 String actualIdMatch = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "tenantIdsMatch",processId);
73                 String actualResponse = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupTenant", "WorkflowException",processId);
74
75                 assertEquals("Response", "true", actualNameMatch);
76                 assertEquals("Response", "false", actualIdMatch);
77                 assertEquals("Response", "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant,workStep=*]", actualResponse);
78
79         }
80
81         private void setVariables(Map<String, Object> variables) {
82                 variables.put("isDebugLogEnabled", "true");
83                 variables.put("volumeGroupId","a8399879-31b3-4973-be26-0a0cbe776b58");
84                 variables.put("tenantId", "7dd5365547234ee8937416c65507d266");
85                 variables.put("aicCloudRegion", "MDTWNJ21");
86                 variables.put("mso-request-id", UUID.randomUUID().toString());
87         }
88 }