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.openecomp.mso.bpmn.common;
23 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
28 import java.io.IOException;
29 import java.util.HashMap;
31 import java.util.UUID;
33 import org.camunda.bpm.engine.test.Deployment;
34 import org.junit.Assert;
35 import org.junit.Test;
36 import org.openecomp.mso.bpmn.mock.FileUtil;
39 * Unit tests for UpdateAAIVfModuleTest.bpmn.
41 public class UpdateAAIVfModuleTest extends WorkflowTest {
44 * Test the happy path through the flow.
47 @Deployment(resources = {
48 "subprocess/UpdateAAIVfModule.bpmn"
50 public void happyPath() throws IOException {
53 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
54 MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
55 MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
57 String businessKey = UUID.randomUUID().toString();
58 Map<String, Object> variables = new HashMap<String, Object>();
59 variables.put("mso-request-id", "999-99-9999");
60 variables.put("isDebugLogEnabled","true");
61 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
62 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
64 Assert.assertTrue(isProcessEnded(businessKey));
65 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
66 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
67 System.out.println("Subflow response code: " + responseCode);
68 System.out.println("Subflow response: " + response);
69 Assert.assertEquals(200, responseCode.intValue());
75 * Test the case where the GET to AAI returns a 404.
78 @Deployment(resources = {
79 "subprocess/UpdateAAIVfModule.bpmn"
81 public void badGet() throws IOException {
85 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
86 MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
88 String businessKey = UUID.randomUUID().toString();
89 Map<String, Object> variables = new HashMap<String, Object>();
90 variables.put("mso-request-id", "999-99-9999");
91 variables.put("isDebugLogEnabled","true");
92 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
93 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
95 Assert.assertTrue(isProcessEnded(businessKey));
96 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
97 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
98 System.out.println("Subflow response code: " + responseCode);
99 System.out.println("Subflow response: " + response);
100 Assert.assertEquals(404, responseCode.intValue());
106 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
109 @Deployment(resources = {
110 "subprocess/UpdateAAIVfModule.bpmn"
112 public void badPut() throws IOException {
116 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
117 MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
118 MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
120 String businessKey = UUID.randomUUID().toString();
121 Map<String, Object> variables = new HashMap<String, Object>();
122 variables.put("mso-request-id", "999-99-9999");
123 variables.put("isDebugLogEnabled","true");
124 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
125 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
127 Assert.assertTrue(isProcessEnded(businessKey));
128 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
129 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
130 System.out.println("Subflow response code: " + responseCode);
131 System.out.println("Subflow response: " + response);
132 Assert.assertEquals(404, responseCode.intValue());