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.MockAAIVfModuleBadPatch;
24 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
25 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
30 import java.io.IOException;
31 import java.util.HashMap;
33 import java.util.UUID;
35 import org.camunda.bpm.engine.test.Deployment;
36 import org.junit.Assert;
37 import org.junit.Ignore;
38 import org.junit.Test;
39 import org.onap.so.BaseIntegrationTest;
40 import org.onap.so.bpmn.mock.FileUtil;
41 import org.onap.so.logger.MsoLogger;
44 * Unit tests for UpdateAAIVfModuleTest.bpmn.
47 public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
49 MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class);
53 * Test the happy path through the flow.
57 public void happyPath() throws IOException {
60 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
61 MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
62 MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
63 MockPatchVfModuleId("skask", "supercool");
65 String businessKey = UUID.randomUUID().toString();
66 Map<String, Object> variables = new HashMap<>();
67 variables.put("mso-request-id", UUID.randomUUID().toString());
68 variables.put("isDebugLogEnabled","true");
69 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
70 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
72 Assert.assertTrue(isProcessEnded(businessKey));
73 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
74 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
75 logger.debug("Subflow response code: " + responseCode);
76 logger.debug("Subflow response: " + response);
77 Assert.assertEquals(200, responseCode.intValue());
83 * Test the case where the GET to AAI returns a 404.
87 public void badGet() throws IOException {
91 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
92 MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
94 String businessKey = UUID.randomUUID().toString();
95 Map<String, Object> variables = new HashMap<>();
96 variables.put("mso-request-id", UUID.randomUUID().toString());
97 variables.put("isDebugLogEnabled","true");
98 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
99 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
101 Assert.assertTrue(isProcessEnded(businessKey));
102 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
103 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
104 logger.debug("Subflow response code: " + responseCode);
105 logger.debug("Subflow response: " + response);
106 Assert.assertEquals(404, responseCode.intValue());
112 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
116 public void badPatch() throws IOException {
120 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
121 MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
122 MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
123 MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
125 String businessKey = UUID.randomUUID().toString();
126 Map<String, Object> variables = new HashMap<>();
127 variables.put("mso-request-id", UUID.randomUUID().toString());
128 variables.put("isDebugLogEnabled","true");
129 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
130 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
132 Assert.assertTrue(isProcessEnded(businessKey));
133 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
134 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
135 logger.debug("Subflow response code: " + responseCode);
136 logger.debug("Subflow response: " + response);
137 Assert.assertEquals(404, responseCode.intValue());