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.onap.so.bpmn.common;
23 import static org.junit.Assert.assertEquals;
24 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById;
26 import java.util.HashMap;
28 import java.util.UUID;
30 import org.camunda.bpm.engine.RuntimeService;
31 import org.camunda.bpm.engine.test.Deployment;
32 import org.junit.Ignore;
33 import org.junit.Test;
34 import org.onap.so.BaseIntegrationTest;
37 * Unit test cases for ConfirmVolumeGroupName.bpmn
40 public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
47 public void sunnyDay() throws Exception {
49 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
51 Map<String, Object> variables = new HashMap<>();
52 variables.put("isDebugLogEnabled","true");
53 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
54 variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
55 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
56 variables.put("mso-request-id", UUID.randomUUID().toString());
57 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
58 String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode",processId);
60 assertEquals("200", responseCode);
66 * Rainy day scenario - nonexisting volume group id.
71 public void rainyDayNoVolumeGroupId() throws Exception {
74 // does not exist would return a 404 from AAI
75 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST", "aai-volume-group-id-info.xml", 404);
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", "CVGN_queryVolumeGroupResponseCode",processId);
86 assertEquals("404", responseCode);
92 * Rainy day scenario - volume group name does not match the name in AAI
98 public void rainyDayNameDoesNotMatch() throws Exception {
101 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
103 Map<String, Object> variables = new HashMap<>();
104 variables.put("isDebugLogEnabled","true");
105 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
106 variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
107 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
108 variables.put("mso-request-id", UUID.randomUUID().toString());
109 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
110 String volumeGroupNameMatches = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_volumeGroupNameMatches",processId);
112 assertEquals("false", volumeGroupNameMatches);