2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common;
25 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVfModuleId;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleId;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
29 import java.io.IOException;
30 import java.util.HashMap;
32 import java.util.UUID;
33 import org.junit.Assert;
34 import org.junit.Test;
35 import org.onap.so.BaseIntegrationTest;
36 import org.onap.so.bpmn.mock.FileUtil;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
41 * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn.
44 public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
46 Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleVolumeGroupIT.class);
49 * Test the happy path through the flow.
52 public void happyPath() throws IOException {
56 String updateAAIVfModuleRequest =
57 FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
58 MockGetGenericVnfByIdWithPriority(wireMockServer, "skask", "lukewarm", 200,
59 "VfModularity/VfModule-lukewarm.xml", 2);
60 MockPutVfModuleIdNoResponse(wireMockServer, "skask", "PCRF", "lukewarm");
62 String businessKey = UUID.randomUUID().toString();
63 Map<String, Object> variables = new HashMap<>();
64 variables.put("mso-request-id", "999-99-9999");
65 variables.put("isDebugLogEnabled", "true");
66 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
67 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
69 Assert.assertTrue(isProcessEnded(businessKey));
70 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
71 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
72 logger.debug("Subflow response code: {}", responseCode);
73 logger.debug("Subflow response: {}", response);
74 Assert.assertEquals(200, responseCode.intValue());
80 * Test the case where the GET to AAI returns a 404.
83 public void badGet() throws IOException {
87 String updateAAIVfModuleRequest =
88 FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
89 MockGetVfModuleId(wireMockServer, "skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
91 String businessKey = UUID.randomUUID().toString();
92 Map<String, Object> variables = new HashMap<>();
93 variables.put("mso-request-id", "999-99-9999");
94 variables.put("isDebugLogEnabled", "true");
95 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
96 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
97 Assert.assertTrue(isProcessEnded(businessKey));
98 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
99 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
100 logger.debug("Subflow response code: {}", responseCode);
101 logger.debug("Subflow response: {}", response);
102 Assert.assertEquals(404, responseCode.intValue());
108 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
111 public void badPatch() throws IOException {
115 String updateAAIVfModuleRequest =
116 FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
117 MockGetVfModuleId(wireMockServer, "skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
118 MockPutVfModuleId(wireMockServer, "skask", "lukewarm", 404);
120 String businessKey = UUID.randomUUID().toString();
121 Map<String, Object> variables = new HashMap<>();
122 variables.put("mso-request-id", "999-99-9999");
123 variables.put("isDebugLogEnabled", "true");
124 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
125 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
127 Assert.assertTrue(isProcessEnded(businessKey));
128 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
129 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
130 logger.debug("Subflow response code: {}", responseCode);
131 logger.debug("Subflow response: {}", response);
132 Assert.assertEquals(404, responseCode.intValue());