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 java.util.HashMap;
25 import java.util.UUID;
27 import org.junit.Assert;
28 import org.junit.Test;
29 import org.onap.so.BaseIntegrationTest;
30 import org.onap.so.bpmn.core.WorkflowException;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * Unit test for DeleteAAIVfModule.bpmn.
38 public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
39 private static final String EOL = "\n";
41 Logger logger = LoggerFactory.getLogger(DeleteAAIVfModuleIT.class);
44 public void TestDeleteGenericVnfSuccess_200() {
45 // delete the Base Module and Generic Vnf
46 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
47 new MockAAIGenericVnfSearch(wireMockServer);
48 new MockAAIDeleteGenericVnf(wireMockServer);
49 new MockAAIDeleteVfModule(wireMockServer);
51 Map<String, Object> variables = new HashMap<>();
52 variables.put("isDebugLogEnabled","true");
53 variables.put("mso-request-id", UUID.randomUUID().toString());
54 variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
55 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
56 String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode",processId);
57 String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode",processId);
58 Assert.assertEquals("200", responseCode);
59 logger.debug(response);
63 public void TestDeleteVfModuleSuccess_200() {
64 // delete Add-on Vf Module for existing Generic Vnf
65 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75
67 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
68 " <request-info>" + EOL +
69 " <action>DELETE_VF_MODULE</action>" + EOL +
70 " <source>PORTAL</source>" + EOL +
71 " </request-info>" + EOL +
72 " <vnf-inputs>" + EOL +
73 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
74 " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
75 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
76 " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
77 " </vnf-inputs>" + EOL +
78 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
79 "</vnf-request>" + EOL;
81 new MockAAIGenericVnfSearch(wireMockServer);
82 new MockAAIDeleteGenericVnf(wireMockServer);
83 new MockAAIDeleteVfModule(wireMockServer);
85 Map<String, Object> variables = new HashMap<>();
86 variables.put("isDebugLogEnabled","true");
87 variables.put("mso-request-id", UUID.randomUUID().toString());
88 variables.put("DeleteAAIVfModuleRequest",request);
89 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
90 String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode",processId);
91 String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode",processId);
92 Assert.assertEquals("200", responseCode);
93 logger.debug(response);
97 public void TestQueryGenericVnfFailure_5000() {
98 // query Generic Vnf failure (non-404) with A&AI
99 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71
101 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
102 " <request-info>" + EOL +
103 " <action>DELETE_VF_MODULE</action>" + EOL +
104 " <source>PORTAL</source>" + EOL +
105 " </request-info>" + EOL +
106 " <vnf-inputs>" + EOL +
107 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL +
108 " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL +
109 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL +
110 " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
111 " </vnf-inputs>" + EOL +
112 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
113 "</vnf-request>" + EOL;
114 new MockAAIGenericVnfSearch(wireMockServer);
115 new MockAAIDeleteGenericVnf(wireMockServer);
116 new MockAAIDeleteVfModule(wireMockServer);
118 Map<String, Object> variables = new HashMap<>();
119 variables.put("isDebugLogEnabled","true");
120 variables.put("mso-request-id", UUID.randomUUID().toString());
121 variables.put("DeleteAAIVfModuleRequest",request);
122 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
123 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
124 Assert.assertEquals(5000, exception.getErrorCode());
125 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
126 logger.debug(exception.getErrorMessage());
130 public void TestQueryGenericVnfFailure_1002() {
131 // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)
132 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72
134 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
135 " <request-info>" + EOL +
136 " <action>DELETE_VF_MODULE</action>" + EOL +
137 " <source>PORTAL</source>" + EOL +
138 " </request-info>" + EOL +
139 " <vnf-inputs>" + EOL +
140 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL +
141 " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +
142 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL +
143 " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL +
144 " </vnf-inputs>" + EOL +
145 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
146 "</vnf-request>" + EOL;
147 new MockAAIGenericVnfSearch(wireMockServer);
148 new MockAAIDeleteGenericVnf(wireMockServer);
149 new MockAAIDeleteVfModule(wireMockServer);
151 Map<String, Object> variables = new HashMap<>();
152 variables.put("isDebugLogEnabled","true");
153 variables.put("mso-request-id", UUID.randomUUID().toString());
154 variables.put("DeleteAAIVfModuleRequest",request);
155 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
156 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
157 Assert.assertEquals(1002, exception.getErrorCode());
158 Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
159 logger.debug(exception.getErrorMessage());
163 public void TestDeleteGenericVnfFailure_5000() {
164 // A&AI failure (non-200) when attempting to delete a Generic Vnf
165 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78
167 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
168 " <request-info>" + EOL +
169 " <action>DELETE_VF_MODULE</action>" + EOL +
170 " <source>PORTAL</source>" + EOL +
171 " </request-info>" + EOL +
172 " <vnf-inputs>" + EOL +
173 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
174 " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
175 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
176 " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
177 " </vnf-inputs>" + EOL +
178 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
179 "</vnf-request>" + EOL;
180 new MockAAIGenericVnfSearch(wireMockServer);
181 new MockAAIDeleteGenericVnf(wireMockServer);
182 new MockAAIDeleteVfModule(wireMockServer);
184 Map<String, Object> variables = new HashMap<>();
185 variables.put("isDebugLogEnabled","true");
186 variables.put("mso-request-id", UUID.randomUUID().toString());
187 variables.put("DeleteAAIVfModuleRequest",request);
188 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
189 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
190 Assert.assertEquals(5000, exception.getErrorCode());
191 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
192 logger.debug(exception.getErrorMessage());
196 public void TestDeleteVfModuleFailure_5000() {
197 // A&AI failure (non-200) when attempting to delete a Vf Module
198 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77
200 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
201 " <request-info>" + EOL +
202 " <action>DELETE_VF_MODULE</action>" + EOL +
203 " <source>PORTAL</source>" + EOL +
204 " </request-info>" + EOL +
205 " <vnf-inputs>" + EOL +
206 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
207 " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
208 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
209 " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
210 " </vnf-inputs>" + EOL +
211 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
212 "</vnf-request>" + EOL;
213 new MockAAIGenericVnfSearch(wireMockServer);
214 new MockAAIDeleteGenericVnf(wireMockServer);
215 new MockAAIDeleteVfModule(wireMockServer);
217 Map<String, Object> variables = new HashMap<>();
218 variables.put("isDebugLogEnabled","true");
219 variables.put("mso-request-id", UUID.randomUUID().toString());
220 variables.put("DeleteAAIVfModuleRequest",request);
221 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
222 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
223 Assert.assertEquals(5000, exception.getErrorCode());
224 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
225 logger.debug(exception.getErrorMessage());
229 public void TestDeleteVfModuleFailure_1002_1() {
230 // failure attempting to delete Base Module when not the last Vf Module
231 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74
233 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
234 " <request-info>" + EOL +
235 " <action>DELETE_VF_MODULE</action>" + EOL +
236 " <source>PORTAL</source>" + EOL +
237 " </request-info>" + EOL +
238 " <vnf-inputs>" + EOL +
239 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
240 " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
241 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
242 " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
243 " </vnf-inputs>" + EOL +
244 " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
245 "</vnf-request>" + EOL;
246 new MockAAIGenericVnfSearch(wireMockServer);
247 new MockAAIDeleteGenericVnf(wireMockServer);
248 new MockAAIDeleteVfModule(wireMockServer);
250 Map<String, Object> variables = new HashMap<>();
251 variables.put("isDebugLogEnabled","true");
252 variables.put("mso-request-id", UUID.randomUUID().toString());
253 variables.put("DeleteAAIVfModuleRequest",request);
254 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
255 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
256 Assert.assertEquals(1002, exception.getErrorCode());
257 Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));
258 logger.debug(exception.getErrorMessage());
262 public void TestDeleteVfModuleFailure_1002_2() {
263 // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
264 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
265 new MockAAIGenericVnfSearch(wireMockServer);
266 new MockAAIDeleteGenericVnf(wireMockServer);
267 new MockAAIDeleteVfModule(wireMockServer);
269 Map<String, Object> variables = new HashMap<>();
270 variables.put("isDebugLogEnabled","true");
271 variables.put("mso-request-id", UUID.randomUUID().toString());
272 variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
273 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
274 WorkflowException exception = BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException",processId);
275 Assert.assertEquals(1002, exception.getErrorCode());
276 Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));
277 logger.debug(exception.getErrorMessage());