Reduce log noise/warnings format to conventions
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / DeleteAAIVfModuleTest.java
1 /*- \r
2  * ============LICENSE_START======================================================= \r
3  * ONAP - SO \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
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0 \r
12  * \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
19  */\r
20 \r
21 package org.openecomp.mso.bpmn.common;\r
22 \r
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;\r
24 import static com.github.tomakehurst.wiremock.client.WireMock.delete;\r
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;\r
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;\r
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;\r
28 \r
29 import java.util.HashMap;\r
30 import java.util.Map;\r
31 \r
32 import org.camunda.bpm.engine.RuntimeService;\r
33 import org.camunda.bpm.engine.test.Deployment;\r
34 import org.junit.Assert;\r
35 import org.junit.Test;\r
36 import org.openecomp.mso.bpmn.core.WorkflowException;\r
37 \r
38 /**\r
39  * Unit test for DeleteAAIVfModule.bpmn.\r
40  */\r
41 public class DeleteAAIVfModuleTest extends WorkflowTest {\r
42     private static final String EOL = "\n";\r
43 \r
44     @Test\r
45     @Deployment(resources = {\r
46             "subprocess/DeleteAAIVfModule.bpmn"\r
47     })\r
48     public void TestDeleteGenericVnfSuccess_200() {\r
49         // delete the Base Module and Generic Vnf\r
50         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73\r
51         MockAAIGenericVnfSearch();\r
52         MockAAIDeleteGenericVnf();\r
53         MockAAIDeleteVfModule();\r
54         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
55         Map<String, Object> variables = new HashMap<>();\r
56         variables.put("isDebugLogEnabled", "true");\r
57         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>");\r
58         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
59         String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode");\r
60         String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode");\r
61         Assert.assertEquals("200", responseCode);\r
62         System.out.println(response);\r
63     }\r
64 \r
65     @Test\r
66     @Deployment(resources = {\r
67             "subprocess/DeleteAAIVfModule.bpmn"\r
68     })\r
69     public void TestDeleteVfModuleSuccess_200() {\r
70         // delete Add-on Vf Module for existing Generic Vnf\r
71         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75\r
72         String request =\r
73                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
74                         "  <request-info>" + EOL +\r
75                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
76                         "    <source>PORTAL</source>" + EOL +\r
77                         "  </request-info>" + EOL +\r
78                         "  <vnf-inputs>" + EOL +\r
79                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +\r
80                         "    <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +\r
81                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +\r
82                         "    <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +\r
83                         "  </vnf-inputs>" + EOL +\r
84                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
85                         "</vnf-request>" + EOL;\r
86 \r
87         MockAAIGenericVnfSearch();\r
88         MockAAIDeleteGenericVnf();\r
89         MockAAIDeleteVfModule();\r
90         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
91         Map<String, Object> variables = new HashMap<>();\r
92         variables.put("isDebugLogEnabled", "true");\r
93         variables.put("DeleteAAIVfModuleRequest", request);\r
94         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
95         String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode");\r
96         String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode");\r
97         Assert.assertEquals("200", responseCode);\r
98         System.out.println(response);\r
99     }\r
100 \r
101     @Test\r
102     @Deployment(resources = {\r
103             "subprocess/DeleteAAIVfModule.bpmn"\r
104     })\r
105     public void TestQueryGenericVnfFailure_5000() {\r
106         // query Generic Vnf failure (non-404) with A&AI\r
107         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71\r
108         String request =\r
109                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
110                         "  <request-info>" + EOL +\r
111                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
112                         "    <source>PORTAL</source>" + EOL +\r
113                         "  </request-info>" + EOL +\r
114                         "  <vnf-inputs>" + EOL +\r
115                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL +\r
116                         "    <vnf-name>STMTN5MMSC23</vnf-name>" + EOL +\r
117                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL +\r
118                         "    <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +\r
119                         "  </vnf-inputs>" + EOL +\r
120                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
121                         "</vnf-request>" + EOL;\r
122         MockAAIGenericVnfSearch();\r
123         MockAAIDeleteGenericVnf();\r
124         MockAAIDeleteVfModule();\r
125         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
126         Map<String, Object> variables = new HashMap<>();\r
127         variables.put("isDebugLogEnabled", "true");\r
128         variables.put("DeleteAAIVfModuleRequest", request);\r
129         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
130         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
131         Assert.assertEquals(5000, exception.getErrorCode());\r
132         Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));\r
133         System.out.println(exception.getErrorMessage());\r
134     }\r
135 \r
136     @Test\r
137     @Deployment(resources = {\r
138             "subprocess/DeleteAAIVfModule.bpmn"\r
139     })\r
140     public void TestQueryGenericVnfFailure_1002() {\r
141         // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)\r
142         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72\r
143         String request =\r
144                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
145                         "  <request-info>" + EOL +\r
146                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
147                         "    <source>PORTAL</source>" + EOL +\r
148                         "  </request-info>" + EOL +\r
149                         "  <vnf-inputs>" + EOL +\r
150                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL +\r
151                         "    <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +\r
152                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL +\r
153                         "    <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL +\r
154                         "  </vnf-inputs>" + EOL +\r
155                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
156                         "</vnf-request>" + EOL;\r
157         MockAAIGenericVnfSearch();\r
158         MockAAIDeleteGenericVnf();\r
159         MockAAIDeleteVfModule();\r
160         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
161         Map<String, Object> variables = new HashMap<>();\r
162         variables.put("isDebugLogEnabled", "true");\r
163         variables.put("DeleteAAIVfModuleRequest", request);\r
164         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
165         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
166         Assert.assertEquals(1002, exception.getErrorCode());\r
167         Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));\r
168         System.out.println(exception.getErrorMessage());\r
169     }\r
170 \r
171     @Test\r
172     @Deployment(resources = {\r
173             "subprocess/DeleteAAIVfModule.bpmn"\r
174     })\r
175     public void TestDeleteGenericVnfFailure_5000() {\r
176         // A&AI failure (non-200) when attempting to delete a Generic Vnf\r
177         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78\r
178         String request =\r
179                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
180                         "  <request-info>" + EOL +\r
181                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
182                         "    <source>PORTAL</source>" + EOL +\r
183                         "  </request-info>" + EOL +\r
184                         "  <vnf-inputs>" + EOL +\r
185                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +\r
186                         "    <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +\r
187                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +\r
188                         "    <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +\r
189                         "  </vnf-inputs>" + EOL +\r
190                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
191                         "</vnf-request>" + EOL;\r
192         MockAAIGenericVnfSearch();\r
193         MockAAIDeleteGenericVnf();\r
194         MockAAIDeleteVfModule();\r
195         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
196         Map<String, Object> variables = new HashMap<>();\r
197         variables.put("isDebugLogEnabled", "true");\r
198         variables.put("DeleteAAIVfModuleRequest", request);\r
199         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
200         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
201         Assert.assertEquals(5000, exception.getErrorCode());\r
202         Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));\r
203         System.out.println(exception.getErrorMessage());\r
204     }\r
205 \r
206     @Test\r
207     @Deployment(resources = {\r
208             "subprocess/DeleteAAIVfModule.bpmn"\r
209     })\r
210     public void TestDeleteVfModuleFailure_5000() {\r
211         // A&AI failure (non-200) when attempting to delete a Vf Module\r
212         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77\r
213         String request =\r
214                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
215                         "  <request-info>" + EOL +\r
216                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
217                         "    <source>PORTAL</source>" + EOL +\r
218                         "  </request-info>" + EOL +\r
219                         "  <vnf-inputs>" + EOL +\r
220                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +\r
221                         "    <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +\r
222                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +\r
223                         "    <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +\r
224                         "  </vnf-inputs>" + EOL +\r
225                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
226                         "</vnf-request>" + EOL;\r
227         MockAAIGenericVnfSearch();\r
228         MockAAIDeleteGenericVnf();\r
229         MockAAIDeleteVfModule();\r
230         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
231         Map<String, Object> variables = new HashMap<>();\r
232         variables.put("isDebugLogEnabled", "true");\r
233         variables.put("DeleteAAIVfModuleRequest", request);\r
234         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
235         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
236         Assert.assertEquals(5000, exception.getErrorCode());\r
237         Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));\r
238         System.out.println(exception.getErrorMessage());\r
239     }\r
240 \r
241     @Test\r
242     @Deployment(resources = {\r
243             "subprocess/DeleteAAIVfModule.bpmn"\r
244     })\r
245     public void TestDeleteVfModuleFailure_1002_1() {\r
246         // failure attempting to delete Base Module when not the last Vf Module\r
247         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74\r
248         String request =\r
249                 "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +\r
250                         "  <request-info>" + EOL +\r
251                         "    <action>DELETE_VF_MODULE</action>" + EOL +\r
252                         "    <source>PORTAL</source>" + EOL +\r
253                         "  </request-info>" + EOL +\r
254                         "  <vnf-inputs>" + EOL +\r
255                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +\r
256                         "    <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +\r
257                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +\r
258                         "    <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +\r
259                         "  </vnf-inputs>" + EOL +\r
260                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +\r
261                         "</vnf-request>" + EOL;\r
262         MockAAIGenericVnfSearch();\r
263         MockAAIDeleteGenericVnf();\r
264         MockAAIDeleteVfModule();\r
265         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
266         Map<String, Object> variables = new HashMap<>();\r
267         variables.put("isDebugLogEnabled", "true");\r
268         variables.put("DeleteAAIVfModuleRequest", request);\r
269         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
270         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
271         Assert.assertEquals(1002, exception.getErrorCode());\r
272         Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));\r
273         System.out.println(exception.getErrorMessage());\r
274     }\r
275 \r
276     @Test\r
277     @Deployment(resources = {\r
278             "subprocess/DeleteAAIVfModule.bpmn"\r
279     })\r
280     public void TestDeleteVfModuleFailure_1002_2() {\r
281         // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)\r
282         // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76\r
283         MockAAIGenericVnfSearch();\r
284         MockAAIDeleteGenericVnf();\r
285         MockAAIDeleteVfModule();\r
286         RuntimeService runtimeService = processEngineRule.getRuntimeService();\r
287         Map<String, Object> variables = new HashMap<>();\r
288         variables.put("isDebugLogEnabled", "true");\r
289         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>");\r
290         runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);\r
291         WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");\r
292         Assert.assertEquals(1002, exception.getErrorCode());\r
293         Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));\r
294         System.out.println(exception.getErrorMessage());\r
295     }\r
296 \r
297     // Start of VF Modularization A&AI mocks\r
298 \r
299     public static void MockAAIGenericVnfSearch() {\r
300         String body;\r
301 \r
302         // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule\r
303 \r
304         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))\r
305                 .willReturn(aResponse()\r
306                         .withStatus(500)\r
307                         .withHeader("Content-Type", "text/xml")\r
308                         .withBodyFile("aaiFault.xml")));\r
309 \r
310         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))\r
311                 .willReturn(aResponse()\r
312                         .withStatus(404)\r
313                         .withHeader("Content-Type", "text/xml")\r
314                         .withBody("Generic VNF Not Found")));\r
315         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))\r
316                 .willReturn(aResponse()\r
317                         .withStatus(404)\r
318                         .withHeader("Content-Type", "text/xml")\r
319                         .withBody("Generic VNF Not Found")));\r
320 \r
321         body =\r
322                 "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL +\r
323                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +\r
324                         "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +\r
325                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
326                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
327                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
328                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
329                         "  <in-maint>false</in-maint>" + EOL +\r
330                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
331                         "  <resource-version>1508691</resource-version>" + EOL +\r
332                         "  <vf-modules>" + EOL +\r
333                         "    <vf-module>" + EOL +\r
334                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +\r
335                         "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +\r
336                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +\r
337                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
338                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
339                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
340                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
341                         "      <resource-version>1508692</resource-version>" + EOL +\r
342                         "    </vf-module>" + EOL +\r
343                         "  </vf-modules>" + EOL +\r
344                         "  <relationship-list/>" + EOL +\r
345                         "  <l-interfaces/>" + EOL +\r
346                         "  <lag-interfaces/>" + EOL +\r
347                         "</generic-vnf>" + EOL;\r
348         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))\r
349                 .willReturn(aResponse()\r
350                         .withStatus(200)\r
351                         .withHeader("Content-Type", "text/xml")\r
352                         .withBody(body)));\r
353         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))\r
354                 .willReturn(aResponse()\r
355                         .withStatus(200)\r
356                         .withHeader("Content-Type", "text/xml")\r
357                         .withBody(body)));\r
358 \r
359         body =\r
360                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
361                         "  <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL +\r
362                         "  <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +\r
363                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
364                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
365                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
366                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
367                         "  <in-maint>false</in-maint>" + EOL +\r
368                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
369                         "  <resource-version>1508691</resource-version>" + EOL +\r
370                         "  <vf-modules>" + EOL +\r
371                         "    <vf-module>" + EOL +\r
372                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +\r
373                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +\r
374                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +\r
375                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
376                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
377                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
378                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
379                         "      <resource-version>1508692</resource-version>" + EOL +\r
380                         "    </vf-module>" + EOL +\r
381                         "    <vf-module>" + EOL +\r
382                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +\r
383                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +\r
384                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +\r
385                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
386                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +\r
387                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
388                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
389                         "      <resource-version>1508692</resource-version>" + EOL +\r
390                         "    </vf-module>" + EOL +\r
391                         "  </vf-modules>" + EOL +\r
392                         "  <relationship-list/>" + EOL +\r
393                         "  <l-interfaces/>" + EOL +\r
394                         "  <lag-interfaces/>" + EOL +\r
395                         "</generic-vnf>" + EOL;\r
396         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))\r
397                 .willReturn(aResponse()\r
398                         .withStatus(200)\r
399                         .withHeader("Content-Type", "text/xml")\r
400                         .withBody(body)));\r
401         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))\r
402                 .willReturn(aResponse()\r
403                         .withStatus(200)\r
404                         .withHeader("Content-Type", "text/xml")\r
405                         .withBody(body)));\r
406 \r
407         // The following stubs are for DeleteAAIVfModule\r
408 \r
409         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))\r
410                 .willReturn(aResponse()\r
411                         .withStatus(500)\r
412                         .withHeader("Content-Type", "text/xml")\r
413                         .withBodyFile("aaiFault.xml")));\r
414 \r
415         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))\r
416                 .willReturn(aResponse()\r
417                         .withStatus(404)\r
418                         .withHeader("Content-Type", "text/xml")\r
419                         .withBody("Generic VNF Not Found")));\r
420 \r
421         body =\r
422                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
423                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +\r
424                         "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +\r
425                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
426                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
427                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
428                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
429                         "  <in-maint>false</in-maint>" + EOL +\r
430                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
431                         "  <resource-version>0000021</resource-version>" + EOL +\r
432                         "  <vf-modules>" + EOL +\r
433                         "    <vf-module>" + EOL +\r
434                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +\r
435                         "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +\r
436                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +\r
437                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
438                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
439                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
440                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
441                         "      <resource-version>0000073</resource-version>" + EOL +\r
442                         "    </vf-module>" + EOL +\r
443                         "  </vf-modules>" + EOL +\r
444                         "  <relationship-list/>" + EOL +\r
445                         "  <l-interfaces/>" + EOL +\r
446                         "  <lag-interfaces/>" + EOL +\r
447                         "</generic-vnf>" + EOL;\r
448         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))\r
449                 .willReturn(aResponse()\r
450                         .withStatus(200)\r
451                         .withHeader("Content-Type", "text/xml")\r
452                         .withBody(body)));\r
453 \r
454         body =\r
455                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
456                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +\r
457                         "  <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +\r
458                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
459                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
460                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
461                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
462                         "  <in-maint>false</in-maint>" + EOL +\r
463                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
464                         "  <resource-version>0000020</resource-version>" + EOL +\r
465                         "  <vf-modules>" + EOL +\r
466                         "    <vf-module>" + EOL +\r
467                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +\r
468                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +\r
469                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +\r
470                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
471                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
472                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
473                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
474                         "      <resource-version>0000074</resource-version>" + EOL +\r
475                         "    </vf-module>" + EOL +\r
476                         "    <vf-module>" + EOL +\r
477                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +\r
478                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +\r
479                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL +\r
480                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
481                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +\r
482                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
483                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
484                         "      <resource-version>0000075</resource-version>" + EOL +\r
485                         "    </vf-module>" + EOL +\r
486                         "  </vf-modules>" + EOL +\r
487                         "  <relationship-list/>" + EOL +\r
488                         "  <l-interfaces/>" + EOL +\r
489                         "  <lag-interfaces/>" + EOL +\r
490                         "</generic-vnf>" + EOL;\r
491         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))\r
492                 .willReturn(aResponse()\r
493                         .withStatus(200)\r
494                         .withHeader("Content-Type", "text/xml")\r
495                         .withBody(body)));\r
496 \r
497         body =\r
498                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
499                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +\r
500                         "  <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +\r
501                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
502                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
503                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
504                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
505                         "  <in-maint>false</in-maint>" + EOL +\r
506                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
507                         "  <resource-version>0000019</resource-version>" + EOL +\r
508                         "  <vf-modules>" + EOL +\r
509                         "    <vf-module>" + EOL +\r
510                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL +\r
511                         "      <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL +\r
512                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL +\r
513                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
514                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
515                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
516                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
517                         "      <resource-version>0000076</resource-version>" + EOL +\r
518                         "    </vf-module>" + EOL +\r
519                         "    <vf-module>" + EOL +\r
520                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +\r
521                         "      <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +\r
522                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL +\r
523                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
524                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +\r
525                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
526                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
527                         "      <resource-version>0000077</resource-version>" + EOL +\r
528                         "    </vf-module>" + EOL +\r
529                         "  </vf-modules>" + EOL +\r
530                         "  <relationship-list/>" + EOL +\r
531                         "  <l-interfaces/>" + EOL +\r
532                         "  <lag-interfaces/>" + EOL +\r
533                         "</generic-vnf>" + EOL;\r
534         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))\r
535                 .willReturn(aResponse()\r
536                         .withStatus(200)\r
537                         .withHeader("Content-Type", "text/xml")\r
538                         .withBody(body)));\r
539 \r
540         body =\r
541                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
542                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +\r
543                         "  <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +\r
544                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
545                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
546                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
547                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
548                         "  <in-maint>false</in-maint>" + EOL +\r
549                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
550                         "  <resource-version>0000018</resource-version>" + EOL +\r
551                         "  <vf-modules>" + EOL +\r
552                         "    <vf-module>" + EOL +\r
553                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +\r
554                         "      <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +\r
555                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL +\r
556                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
557                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
558                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
559                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
560                         "      <resource-version>0000078</resource-version>" + EOL +\r
561                         "    </vf-module>" + EOL +\r
562                         "  </vf-modules>" + EOL +\r
563                         "  <relationship-list/>" + EOL +\r
564                         "  <l-interfaces/>" + EOL +\r
565                         "  <lag-interfaces/>" + EOL +\r
566                         "</generic-vnf>" + EOL;\r
567         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))\r
568                 .willReturn(aResponse()\r
569                         .withStatus(200)\r
570                         .withHeader("Content-Type", "text/xml")\r
571                         .withBody(body)));\r
572 \r
573         body =\r
574                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +\r
575                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +\r
576                         "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +\r
577                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +\r
578                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +\r
579                         "  <equipment-role>vMMSC</equipment-role>" + EOL +\r
580                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +\r
581                         "  <in-maint>false</in-maint>" + EOL +\r
582                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +\r
583                         "  <resource-version>0000021</resource-version>" + EOL +\r
584                         "  <vf-modules>" + EOL +\r
585                         "    <vf-module>" + EOL +\r
586                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +\r
587                         "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +\r
588                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +\r
589                         "      <persona-model-version>1.0</persona-model-version>" + EOL +\r
590                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +\r
591                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +\r
592                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +\r
593                         "      <resource-version>0000073</resource-version>" + EOL +\r
594                         "    </vf-module>" + EOL +\r
595                         "  </vf-modules>" + EOL +\r
596                         "  <relationship-list/>" + EOL +\r
597                         "  <l-interfaces/>" + EOL +\r
598                         "  <lag-interfaces/>" + EOL +\r
599                         "</generic-vnf>" + EOL;\r
600         stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))\r
601                 .willReturn(aResponse()\r
602                         .withStatus(200)\r
603                         .withHeader("Content-Type", "text/xml")\r
604                         .withBody(body)));\r
605     }\r
606 \r
607     public static void MockAAIDeleteGenericVnf() {\r
608         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))\r
609                 .willReturn(aResponse()\r
610                         .withStatus(200)));\r
611         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))\r
612                 .willReturn(aResponse()\r
613                         .withStatus(500)\r
614                         .withHeader("Content-Type", "text/xml")\r
615                         .withBodyFile("aaiFault.xml")));\r
616     }\r
617 \r
618     public static void MockAAIDeleteVfModule() {\r
619         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))\r
620                 .willReturn(aResponse()\r
621                         .withStatus(200)));\r
622         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))\r
623                 .willReturn(aResponse()\r
624                         .withStatus(200)));\r
625         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))\r
626                 .willReturn(aResponse()\r
627                         .withStatus(200)));\r
628         stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))\r
629                 .willReturn(aResponse()\r
630                         .withStatus(500)\r
631                         .withHeader("Content-Type", "text/xml")\r
632                         .withBodyFile("aaiFault.xml")));\r
633         stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))\r
634                 .willReturn(aResponse()\r
635                         .withStatus(200)\r
636                         .withHeader("Content-Type", "text/xml")\r
637                         .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));\r
638 \r
639         stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))\r
640                 .willReturn(aResponse()\r
641                         .withStatus(200)));\r
642     }\r
643 }\r
644 \r