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.MockAAIVfModuleBadPatch;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
29 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
30 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
32 import java.io.IOException;
33 import java.util.HashMap;
35 import java.util.UUID;
37 import org.camunda.bpm.engine.test.Deployment;
38 import org.junit.Assert;
39 import org.junit.Ignore;
40 import org.junit.Test;
41 import org.onap.so.BaseIntegrationTest;
42 import org.onap.so.bpmn.mock.FileUtil;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
47 * Unit tests for UpdateAAIVfModuleTest.bpmn.
50 public class UpdateAAIVfModuleIT extends BaseIntegrationTest {
52 Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
56 * Test the happy path through the flow.
60 public void happyPath() throws IOException {
63 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
64 MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
65 MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
66 MockPatchVfModuleId("skask", "supercool");
68 String businessKey = UUID.randomUUID().toString();
69 Map<String, Object> variables = new HashMap<>();
70 variables.put("mso-request-id", UUID.randomUUID().toString());
71 variables.put("isDebugLogEnabled","true");
72 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
73 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
75 Assert.assertTrue(isProcessEnded(businessKey));
76 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
77 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
78 logger.debug("Subflow response code: {}", responseCode);
79 logger.debug("Subflow response: {}", response);
80 Assert.assertEquals(200, responseCode.intValue());
86 * Test the case where the GET to AAI returns a 404.
90 public void badGet() throws IOException {
94 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
95 MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
97 String businessKey = UUID.randomUUID().toString();
98 Map<String, Object> variables = new HashMap<>();
99 variables.put("mso-request-id", UUID.randomUUID().toString());
100 variables.put("isDebugLogEnabled","true");
101 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
102 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
104 Assert.assertTrue(isProcessEnded(businessKey));
105 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
106 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
107 logger.debug("Subflow response code: {}", responseCode);
108 logger.debug("Subflow response: {}", response);
109 Assert.assertEquals(404, responseCode.intValue());
115 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
119 public void badPatch() throws IOException {
123 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
124 MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
125 MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
126 MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
128 String businessKey = UUID.randomUUID().toString();
129 Map<String, Object> variables = new HashMap<>();
130 variables.put("mso-request-id", UUID.randomUUID().toString());
131 variables.put("isDebugLogEnabled","true");
132 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
133 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
135 Assert.assertTrue(isProcessEnded(businessKey));
136 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
137 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
138 logger.debug("Subflow response code: {}", responseCode);
139 logger.debug("Subflow response: {}", response);
140 Assert.assertEquals(404, responseCode.intValue());