e62742da307f25d61f7e8b83a94ab4f537d49df9
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / ConfirmVolumeGroupTenantTest.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  * OPENECOMP - MSO 
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.openecomp.mso.bpmn.common;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
28 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
30
31 import java.util.HashMap;
32 import java.util.Map;
33
34 import org.camunda.bpm.engine.test.Deployment;
35 import org.junit.Test;
36 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
37
38 /**
39  * Please describe the ConfirmVolumeGroupTenantTest.java class
40  *
41  */
42 public class ConfirmVolumeGroupTenantTest extends WorkflowTest {
43
44         @Test
45         @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"})
46         public void testRemoveLayer3Service_success() throws Exception{
47                 MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml");
48
49                 Map<String, String> variables = new HashMap<String, String>();
50                 setVariables(variables);
51
52                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables);
53                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
54
55                 String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch");
56                 String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch");
57                 String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "volumeHeatStackId");
58
59                 assertEquals("Response", "true", actualNameMatch);
60                 assertEquals("Response", "true", actualIdMatch);
61                 assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse);
62         }
63
64         @Test
65         @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"})
66         public void testRemoveLayer3Service_idsNotMatch() throws Exception{
67                 MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml");
68
69                 Map<String, String> variables = new HashMap<String, String>();
70                 setVariables(variables);
71
72                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables);
73                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
74
75                 String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch");
76                 String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch");
77                 String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "WorkflowException");
78
79                 assertEquals("Response", "true", actualNameMatch);
80                 assertEquals("Response", "false", actualIdMatch);
81                 assertEquals("Response", "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant]", actualResponse);
82
83         }
84
85         private void setVariables(Map<String, String> variables) {
86                 variables.put("isDebugLogEnabled", "true");
87                 variables.put("volumeGroupId","a8399879-31b3-4973-be26-0a0cbe776b58");
88                 variables.put("tenantId", "7dd5365547234ee8937416c65507d266");
89                 variables.put("aicCloudRegion", "MDTWNJ21");
90         }
91 }