2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.mso.bpmn.common;
23 import static org.junit.Assert.assertEquals;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
26 import java.util.HashMap;
29 import org.camunda.bpm.engine.RuntimeService;
30 import org.camunda.bpm.engine.test.Deployment;
31 import org.junit.Test;
34 * Unit test cases for ConfirmVolumeGroupName.bpmn
36 public class ConfirmVolumeGroupNameTest extends WorkflowTest {
43 @Deployment(resources = {
44 "subprocess/ConfirmVolumeGroupName.bpmn"
46 public void sunnyDay() throws Exception {
49 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
51 System.out.println("Before starting process");
53 RuntimeService runtimeService = processEngineRule.getRuntimeService();
54 Map<String, Object> variables = new HashMap<String, Object>();
55 variables.put("isDebugLogEnabled","true");
56 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
57 variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
58 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
59 System.out.println("after setting variables");
60 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
61 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
62 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
64 assertEquals("200", responseCode);
65 System.out.println(response);
70 * Rainy day scenario - nonexisting volume group id.
75 @Deployment(resources = {
76 "subprocess/ConfirmVolumeGroupName.bpmn"
78 public void rainyDayNoVolumeGroupId() throws Exception {
81 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
83 System.out.println("Before starting process");
85 RuntimeService runtimeService = processEngineRule.getRuntimeService();
86 Map<String, Object> variables = new HashMap<String, Object>();
87 variables.put("isDebugLogEnabled","true");
88 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST");
89 variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg");
90 System.out.println("after setting variables");
91 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
92 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
93 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
95 assertEquals("404", responseCode);
96 System.out.println(response);
102 * Rainy day scenario - volume group name does not match the name in AAI
108 @Deployment(resources = {
109 "subprocess/ConfirmVolumeGroupName.bpmn"
111 public void rainyDayNameDoesNotMatch() throws Exception {
114 MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
116 System.out.println("Before starting process");
118 RuntimeService runtimeService = processEngineRule.getRuntimeService();
119 Map<String, Object> variables = new HashMap<String, Object>();
120 variables.put("isDebugLogEnabled","true");
121 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
122 variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
123 System.out.println("after setting variables");
124 runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables);
125 String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse");
126 String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode");
128 assertEquals("404", responseCode);
129 System.out.println(response);