2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.common;
\r
23 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch;
\r
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
\r
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
\r
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
\r
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
\r
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
\r
30 import java.io.IOException;
\r
31 import java.util.HashMap;
\r
32 import java.util.Map;
\r
33 import java.util.UUID;
\r
35 import org.camunda.bpm.engine.test.Deployment;
\r
36 import org.junit.Assert;
\r
37 import org.junit.Test;
\r
38 import org.openecomp.mso.bpmn.mock.FileUtil;
\r
41 * Unit tests for UpdateAAIVfModuleTest.bpmn.
\r
43 public class UpdateAAIVfModuleTest extends WorkflowTest {
\r
46 * Test the happy path through the flow.
\r
49 @Deployment(resources = {
\r
50 "subprocess/UpdateAAIVfModule.bpmn"
\r
52 public void happyPath() throws IOException {
\r
55 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
\r
56 MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
\r
57 MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
\r
58 MockPatchVfModuleId("skask", "supercool");
\r
60 String businessKey = UUID.randomUUID().toString();
\r
61 Map<String, Object> variables = new HashMap<>();
\r
62 variables.put("mso-request-id", "999-99-9999");
\r
63 variables.put("isDebugLogEnabled","true");
\r
64 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
\r
65 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
\r
67 Assert.assertTrue(isProcessEnded(businessKey));
\r
68 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
\r
69 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
\r
70 System.out.println("Subflow response code: " + responseCode);
\r
71 System.out.println("Subflow response: " + response);
\r
72 Assert.assertEquals(200, responseCode.intValue());
\r
78 * Test the case where the GET to AAI returns a 404.
\r
81 @Deployment(resources = {
\r
82 "subprocess/UpdateAAIVfModule.bpmn"
\r
84 public void badGet() throws IOException {
\r
88 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
\r
89 MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
\r
91 String businessKey = UUID.randomUUID().toString();
\r
92 Map<String, Object> variables = new HashMap<>();
\r
93 variables.put("mso-request-id", "999-99-9999");
\r
94 variables.put("isDebugLogEnabled","true");
\r
95 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
\r
96 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
\r
98 Assert.assertTrue(isProcessEnded(businessKey));
\r
99 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
\r
100 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
\r
101 System.out.println("Subflow response code: " + responseCode);
\r
102 System.out.println("Subflow response: " + response);
\r
103 Assert.assertEquals(404, responseCode.intValue());
\r
109 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
\r
112 @Deployment(resources = {
\r
113 "subprocess/UpdateAAIVfModule.bpmn"
\r
115 public void badPatch() throws IOException {
\r
119 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
\r
120 MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
\r
121 MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
\r
122 MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
\r
124 String businessKey = UUID.randomUUID().toString();
\r
125 Map<String, Object> variables = new HashMap<>();
\r
126 variables.put("mso-request-id", "999-99-9999");
\r
127 variables.put("isDebugLogEnabled","true");
\r
128 variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
\r
129 invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
\r
131 Assert.assertTrue(isProcessEnded(businessKey));
\r
132 String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
\r
133 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
\r
134 System.out.println("Subflow response code: " + responseCode);
\r
135 System.out.println("Subflow response: " + response);
\r
136 Assert.assertEquals(404, responseCode.intValue());
\r