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;
30 import java.io.IOException;
31 import java.util.HashMap;
33 import java.util.UUID;
35 import org.junit.Assert;
36 import org.junit.Test;
37 import org.onap.so.BaseIntegrationTest;
38 import org.onap.so.bpmn.mock.FileUtil;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
43 * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn.
46 public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
48 Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleVolumeGroupIT.class);
51 * Test the happy path through the flow.
54 public void happyPath() throws IOException {
58 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
59 MockGetGenericVnfByIdWithPriority(wireMockServer, "skask", "lukewarm", 200, "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 = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
88 MockGetVfModuleId(wireMockServer, "skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
90 String businessKey = UUID.randomUUID().toString();
91 Map<String, Object> variables = new HashMap<>();
92 variables.put("mso-request-id", "999-99-9999");
93 variables.put("isDebugLogEnabled","true");
94 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
95 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
96 Assert.assertTrue(isProcessEnded(businessKey));
97 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
98 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
99 logger.debug("Subflow response code: {}", responseCode);
100 logger.debug("Subflow response: {}", response);
101 Assert.assertEquals(404, responseCode.intValue());
107 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
110 public void badPatch() throws IOException {
114 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
115 MockGetVfModuleId(wireMockServer, "skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
116 MockPutVfModuleId(wireMockServer, "skask", "lukewarm", 404);
118 String businessKey = UUID.randomUUID().toString();
119 Map<String, Object> variables = new HashMap<>();
120 variables.put("mso-request-id", "999-99-9999");
121 variables.put("isDebugLogEnabled","true");
122 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
123 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
125 Assert.assertTrue(isProcessEnded(businessKey));
126 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
127 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
128 logger.debug("Subflow response code: {}", responseCode);
129 logger.debug("Subflow response: {}", response);
130 Assert.assertEquals(404, responseCode.intValue());