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;
25 import java.util.HashMap;
27 import java.util.UUID;
28 import org.camunda.bpm.engine.RuntimeService;
29 import org.camunda.bpm.engine.test.Deployment;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.onap.so.BaseIntegrationTest;
35 * Unit test cases for ConfirmVolumeGroupName.bpmn
38 public class ConfirmVolumeGroupNameIT extends BaseIntegrationTest {
45 public void sunnyDay() throws Exception {
47 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml");
49 Map<String, Object> variables = new HashMap<>();
50 variables.put("isDebugLogEnabled", "true");
51 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
52 variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME");
53 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
54 variables.put("mso-request-id", UUID.randomUUID().toString());
55 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
56 String responseCode = BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName",
57 "CVGN_queryVolumeGroupResponseCode", processId);
59 assertEquals("200", responseCode);
65 * Rainy day scenario - nonexisting volume group id.
70 public void rainyDayNoVolumeGroupId() throws Exception {
73 // does not exist would return a 404 from AAI
74 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST",
75 "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",
85 "CVGN_queryVolumeGroupResponseCode", processId);
87 assertEquals("404", responseCode);
93 * Rainy day scenario - volume group name does not match the name in AAI
99 public void rainyDayNameDoesNotMatch() throws Exception {
102 MockGetVolumeGroupById(wireMockServer, "MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml", 200);
104 Map<String, Object> variables = new HashMap<>();
105 variables.put("isDebugLogEnabled", "true");
106 variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1");
107 variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME");
108 variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21");
109 variables.put("mso-request-id", UUID.randomUUID().toString());
110 String processId = invokeSubProcess("ConfirmVolumeGroupName", variables);
111 String volumeGroupNameMatches =
112 BPMNUtil.getVariable(processEngine, "ConfirmVolumeGroupName", "CVGN_volumeGroupNameMatches", processId);
114 assertEquals("false", volumeGroupNameMatches);