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;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.onap.so.BaseIntegrationTest;
29 import org.onap.so.bpmn.core.WorkflowException;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * Unit test for DeleteAAIVfModule.bpmn.
37 public class DeleteAAIVfModuleIT extends BaseIntegrationTest {
38 private static final String EOL = "\n";
40 Logger logger = LoggerFactory.getLogger(DeleteAAIVfModuleIT.class);
43 public void TestDeleteGenericVnfSuccess_200() {
44 // delete the Base Module and Generic Vnf
45 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
46 new MockAAIGenericVnfSearch(wireMockServer);
47 new MockAAIDeleteGenericVnf(wireMockServer);
48 new MockAAIDeleteVfModule(wireMockServer);
50 Map<String, Object> variables = new HashMap<>();
51 variables.put("isDebugLogEnabled", "true");
52 variables.put("mso-request-id", UUID.randomUUID().toString());
53 variables.put("DeleteAAIVfModuleRequest",
54 "<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",
57 "DAAIVfMod_deleteGenericVnfResponseCode", processId);
58 String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
59 "DAAIVfMod_deleteGenericVnfResponseCode", processId);
60 Assert.assertEquals("200", responseCode);
61 logger.debug(response);
65 public void TestDeleteVfModuleSuccess_200() {
66 // delete Add-on Vf Module for existing Generic Vnf
67 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75
68 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
69 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
70 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
71 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
72 + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL
73 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL
74 + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
75 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
78 new MockAAIGenericVnfSearch(wireMockServer);
79 new MockAAIDeleteGenericVnf(wireMockServer);
80 new MockAAIDeleteVfModule(wireMockServer);
82 Map<String, Object> variables = new HashMap<>();
83 variables.put("isDebugLogEnabled", "true");
84 variables.put("mso-request-id", UUID.randomUUID().toString());
85 variables.put("DeleteAAIVfModuleRequest", request);
86 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
87 String response = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
88 "DAAIVfMod_deleteVfModuleResponseCode", processId);
89 String responseCode = BPMNUtil.getVariable(processEngine, "DeleteAAIVfModule",
90 "DAAIVfMod_deleteVfModuleResponseCode", processId);
91 Assert.assertEquals("200", responseCode);
92 logger.debug(response);
96 public void TestQueryGenericVnfFailure_5000() {
97 // query Generic Vnf failure (non-404) with A&AI
98 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71
99 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
100 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
101 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
102 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL
103 + " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL
104 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL
105 + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
106 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
108 new MockAAIGenericVnfSearch(wireMockServer);
109 new MockAAIDeleteGenericVnf(wireMockServer);
110 new MockAAIDeleteVfModule(wireMockServer);
112 Map<String, Object> variables = new HashMap<>();
113 variables.put("isDebugLogEnabled", "true");
114 variables.put("mso-request-id", UUID.randomUUID().toString());
115 variables.put("DeleteAAIVfModuleRequest", request);
116 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
117 WorkflowException exception =
118 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
119 Assert.assertEquals(5000, exception.getErrorCode());
120 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
121 logger.debug(exception.getErrorMessage());
125 public void TestQueryGenericVnfFailure_1002() {
126 // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)
127 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72
128 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
129 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
130 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
131 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL
132 + " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL
133 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL
134 + " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
135 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
137 new MockAAIGenericVnfSearch(wireMockServer);
138 new MockAAIDeleteGenericVnf(wireMockServer);
139 new MockAAIDeleteVfModule(wireMockServer);
141 Map<String, Object> variables = new HashMap<>();
142 variables.put("isDebugLogEnabled", "true");
143 variables.put("mso-request-id", UUID.randomUUID().toString());
144 variables.put("DeleteAAIVfModuleRequest", request);
145 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
146 WorkflowException exception =
147 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
148 Assert.assertEquals(1002, exception.getErrorCode());
149 Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
150 logger.debug(exception.getErrorMessage());
154 public void TestDeleteGenericVnfFailure_5000() {
155 // A&AI failure (non-200) when attempting to delete a Generic Vnf
156 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78
157 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
158 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
159 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
160 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL
161 + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL
162 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL
163 + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
164 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
166 new MockAAIGenericVnfSearch(wireMockServer);
167 new MockAAIDeleteGenericVnf(wireMockServer);
168 new MockAAIDeleteVfModule(wireMockServer);
170 Map<String, Object> variables = new HashMap<>();
171 variables.put("isDebugLogEnabled", "true");
172 variables.put("mso-request-id", UUID.randomUUID().toString());
173 variables.put("DeleteAAIVfModuleRequest", request);
174 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
175 WorkflowException exception =
176 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
177 Assert.assertEquals(5000, exception.getErrorCode());
178 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
179 logger.debug(exception.getErrorMessage());
183 public void TestDeleteVfModuleFailure_5000() {
184 // A&AI failure (non-200) when attempting to delete a Vf Module
185 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77
186 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
187 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
188 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
189 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL
190 + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL
191 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL
192 + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
193 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
195 new MockAAIGenericVnfSearch(wireMockServer);
196 new MockAAIDeleteGenericVnf(wireMockServer);
197 new MockAAIDeleteVfModule(wireMockServer);
199 Map<String, Object> variables = new HashMap<>();
200 variables.put("isDebugLogEnabled", "true");
201 variables.put("mso-request-id", UUID.randomUUID().toString());
202 variables.put("DeleteAAIVfModuleRequest", request);
203 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
204 WorkflowException exception =
205 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
206 Assert.assertEquals(5000, exception.getErrorCode());
207 Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
208 logger.debug(exception.getErrorMessage());
212 public void TestDeleteVfModuleFailure_1002_1() {
213 // failure attempting to delete Base Module when not the last Vf Module
214 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74
215 String request = "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL
216 + " <request-info>" + EOL + " <action>DELETE_VF_MODULE</action>" + EOL
217 + " <source>PORTAL</source>" + EOL + " </request-info>" + EOL + " <vnf-inputs>" + EOL
218 + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
219 + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL
220 + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL
221 + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL + " </vnf-inputs>" + EOL
222 + " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL + "</vnf-request>"
224 new MockAAIGenericVnfSearch(wireMockServer);
225 new MockAAIDeleteGenericVnf(wireMockServer);
226 new MockAAIDeleteVfModule(wireMockServer);
228 Map<String, Object> variables = new HashMap<>();
229 variables.put("isDebugLogEnabled", "true");
230 variables.put("mso-request-id", UUID.randomUUID().toString());
231 variables.put("DeleteAAIVfModuleRequest", request);
232 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
233 WorkflowException exception =
234 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
235 Assert.assertEquals(1002, exception.getErrorCode());
236 Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));
237 logger.debug(exception.getErrorMessage());
241 public void TestDeleteVfModuleFailure_1002_2() {
242 // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
243 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
244 new MockAAIGenericVnfSearch(wireMockServer);
245 new MockAAIDeleteGenericVnf(wireMockServer);
246 new MockAAIDeleteVfModule(wireMockServer);
248 Map<String, Object> variables = new HashMap<>();
249 variables.put("isDebugLogEnabled", "true");
250 variables.put("mso-request-id", UUID.randomUUID().toString());
251 variables.put("DeleteAAIVfModuleRequest",
252 "<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>");
253 String processId = invokeSubProcess("DeleteAAIVfModule", variables);
254 WorkflowException exception =
255 BPMNUtil.getRawVariable(processEngine, "DeleteAAIVfModule", "WorkflowException", processId);
256 Assert.assertEquals(1002, exception.getErrorCode());
257 Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));
258 logger.debug(exception.getErrorMessage());