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.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
24 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVfModuleId;
25 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleId;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
28 import java.io.IOException;
29 import java.util.HashMap;
31 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.onap.so.logger.MsoLogger;
40 * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn.
43 public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest {
45 MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleVolumeGroupIT.class);
48 * Test the happy path through the flow.
51 public void happyPath() throws IOException {
55 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
56 MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
57 MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm");
59 String businessKey = UUID.randomUUID().toString();
60 Map<String, Object> variables = new HashMap<>();
61 variables.put("mso-request-id", "999-99-9999");
62 variables.put("isDebugLogEnabled","true");
63 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
64 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
66 Assert.assertTrue(isProcessEnded(businessKey));
67 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
68 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
69 logger.debug("Subflow response code: " + responseCode);
70 logger.debug("Subflow response: " + response);
71 Assert.assertEquals(200, responseCode.intValue());
77 * Test the case where the GET to AAI returns a 404.
80 public void badGet() throws IOException {
84 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
85 MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
87 String businessKey = UUID.randomUUID().toString();
88 Map<String, Object> variables = new HashMap<>();
89 variables.put("mso-request-id", "999-99-9999");
90 variables.put("isDebugLogEnabled","true");
91 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
92 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
93 Assert.assertTrue(isProcessEnded(businessKey));
94 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
95 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
96 logger.debug("Subflow response code: " + responseCode);
97 logger.debug("Subflow response: " + response);
98 Assert.assertEquals(404, responseCode.intValue());
104 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
107 public void badPatch() throws IOException {
111 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
112 MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
113 MockPutVfModuleId("skask", "lukewarm", 404);
115 String businessKey = UUID.randomUUID().toString();
116 Map<String, Object> variables = new HashMap<>();
117 variables.put("mso-request-id", "999-99-9999");
118 variables.put("isDebugLogEnabled","true");
119 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
120 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
122 Assert.assertTrue(isProcessEnded(businessKey));
123 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
124 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
125 logger.debug("Subflow response code: " + responseCode);
126 logger.debug("Subflow response: " + response);
127 Assert.assertEquals(404, responseCode.intValue());