[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / infrastructure / DeleteVfModuleInfraTest.java
1 /*- 
2  * ============LICENSE_START======================================================= 
3  * OPENECOMP - MSO 
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 
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0 
12  * 
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========================================================= 
19  */ 
20
21 package org.openecomp.mso.bpmn.infrastructure;
22
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
25 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
26 import static com.github.tomakehurst.wiremock.client.WireMock.get;
27 import static com.github.tomakehurst.wiremock.client.WireMock.post;
28 import static com.github.tomakehurst.wiremock.client.WireMock.put;
29 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
30 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
31 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
32 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
33 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFDelete;
34
35 import java.io.IOException;
36 import java.util.HashMap;
37 import java.util.Map;
38 import java.util.UUID;
39
40 import org.camunda.bpm.engine.test.Deployment;
41 import org.junit.Ignore;
42 import org.junit.Test;
43 import org.openecomp.mso.bpmn.common.WorkflowTest;
44 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
45 import org.openecomp.mso.bpmn.core.WorkflowException;
46 import org.openecomp.mso.bpmn.mock.FileUtil;
47
48 import com.github.tomakehurst.wiremock.client.WireMock;
49 /**
50  * Unit test for DoDeleteVfModule.bpmn.
51  */
52 public class DeleteVfModuleInfraTest extends WorkflowTest {
53         private final CallbackSet callbacks = new CallbackSet();
54         
55         private static final String EOL = "\n";
56
57         private final String vnfAdapterDeleteCallback = 
58                         "<deleteVfModuleResponse>" + EOL +
59                         "    <vnfId>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnfId>" + EOL +
60                         "    <vfModuleId>973ed047-d251-4fb9-bf1a-65b8949e0a73</vfModuleId>" + EOL +
61                         "    <vfModuleDeleted>true</vfModuleDeleted>" + EOL +
62                         "    <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
63                         "       <vfModuleOutputs>" + EOL +  
64                         "        <entry>" + EOL +
65                         "        <key>policyKey1_contrail_network_policy_fqdn</key>" + EOL +
66                         " <value>MSOTest:DefaultPolicyFQDN1</value>" + EOL +
67                         "</entry>" + EOL +
68                         "<entry>" + EOL +
69                         "<key>policyKey2_contrail_network_policy_fqdn</key>" + EOL +
70                         "<value>MSOTest:DefaultPolicyFQDN2</value>" + EOL +
71                         "</entry>" + EOL +
72                         "        <entry>" + EOL +
73                         "        <key>oam_management_v4_address</key>" + EOL +
74                         " <value>1234</value>" + EOL +
75                         "</entry>" + EOL +
76                         "        <entry>" + EOL +
77                         "        <key>oam_management_v6_address</key>" + EOL +
78                         " <value>1234</value>" + EOL +
79                         "</entry>" + EOL +
80                         "</vfModuleOutputs>" + EOL +
81                         "</deleteVfModuleResponse>" + EOL;
82                                 
83         private final String vnfAdapterDeleteCallbackFail = 
84                         "<vfModuleException>" + EOL +
85                         "    <message>Error processing request to VNF-Async. Not Found.</message>" + EOL +
86                         "    <category>INTERNAL</category>" + EOL +
87                         "    <rolledBack>false</rolledBack>" + EOL +
88                         "    <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
89                         "</vfModuleException>" + EOL;
90                                         
91         private final String sdncAdapterDeleteCallback =
92                 "<output xmlns=\"org:openecomp:sdnctl:l3api\">" + EOL +
93                 "  <svc-request-id>{{REQUEST-ID}}</svc-request-id>" + EOL +
94                 "  <ack-final-indicator>Y</ack-final-indicator>" + EOL +
95                 "</output>" + EOL;
96         
97         public DeleteVfModuleInfraTest() throws IOException {
98                 callbacks.put("sdncChangeDelete", sdncAdapterDeleteCallback);
99                 callbacks.put("sdncDelete", sdncAdapterDeleteCallback);
100                 callbacks.put("vnfDelete", vnfAdapterDeleteCallback);
101                 callbacks.put("vnfDeleteFail", vnfAdapterDeleteCallbackFail);
102         }
103
104         @Test
105         @Deployment(resources = {
106                         "process/Infrastructure/DeleteVfModuleInfra.bpmn",
107                         "subprocess/DoDeleteVfModule.bpmn",
108                         "subprocess/PrepareUpdateAAIVfModule.bpmn",
109                         "subprocess/UpdateAAIVfModule.bpmn",
110                         "subprocess/UpdateAAIGenericVnf.bpmn",
111                         "subprocess/DeleteAAIVfModule.bpmn",
112                         "subprocess/SDNCAdapterV1.bpmn",
113                         "subprocess/VnfAdapterRestV1.bpmn",
114                         "subprocess/CompleteMsoProcess.bpmn",
115                         "subprocess/FalloutHandler.bpmn"
116                 })
117         @Ignore
118         public void  TestDeleteVfModuleSuccess() throws Exception {
119                 // delete the Base Module
120                 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
121                 String request =
122                         "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
123                         "  <request-info>" + EOL +
124                         "    <request-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</request-id>" + EOL +
125                         "    <action>DELETE_VF_MODULE</action>" + EOL +
126                         "    <source>PORTAL</source>" + EOL +
127                         "  </request-info>" + EOL +
128                         "  <vnf-inputs>" + EOL +
129                         "    <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
130                         "    <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
131                         "    <vnf-type>asc_heat-int</vnf-type>" + EOL +
132                         "    <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
133                         "    <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
134                         "    <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
135                         "    <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL +
136                         "    <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
137                         "    <orchestration-status>pending-delete</orchestration-status>" + EOL +
138                         "    <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
139                         "  </vnf-inputs>" + EOL +
140                         "  <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
141                         "</vnf-request>" + EOL;
142                 logStart();
143                 WireMock.reset();
144                 
145                 stubFor(post(urlEqualTo("/SDNCAdapter"))
146                                   .withRequestBody(containing("SvcAction>changedelete"))
147                                   .willReturn(aResponse()
148                                   .withStatus(200)
149                                   .withHeader("Content-Type", "text/xml")
150                                   .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml")));
151                 stubFor(post(urlEqualTo("/SDNCAdapter"))
152                                   .withRequestBody(containing("SvcAction>delete"))
153                                   .willReturn(aResponse()
154                                   .withStatus(200)
155                                   .withHeader("Content-Type", "text/xml")
156                                   .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml")));
157                 
158                 mockVNFDelete(".*", "/.*", 202);
159 //              MockAAIGenericVnfSearch();
160 //              MockAAIVfModulePUT(false);
161 //              MockAAIDeleteGenericVnf();
162 //              MockAAIDeleteVfModule();
163                 mockUpdateRequestDB(200, "VfModularity/DBUpdateResponse.xml");
164                 
165                 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"))
166                                 .willReturn(aResponse()
167                                                 .withStatus(200)));
168                 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"))
169                                 .willReturn(aResponse()
170                                                 .withStatus(200)));
171                 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"))
172                                 .willReturn(aResponse()
173                                                 .withStatus(200)));
174                 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"))
175                                 .willReturn(aResponse()
176                                                 .withStatus(500)
177                                                 .withHeader("Content-Type", "text/xml")
178                                                 .withBodyFile("aaiFault.xml")));
179                 stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
180                                   .willReturn(aResponse()
181                                   .withStatus(200)
182                                   .withHeader("Content-Type", "text/xml")
183                                   .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
184
185                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
186                                 .willReturn(aResponse()
187                                                 .withStatus(200)));
188                 
189                 
190                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
191                                 .willReturn(aResponse()
192                                                 .withStatus(200)));
193                 stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
194                                 .willReturn(aResponse()
195                                                 .withStatus(500)
196                                                 .withHeader("Content-Type", "text/xml")
197                                                 .withBodyFile("aaiFault.xml")));
198                 
199                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
200                                 .withRequestBody(containing("MMSC"))
201                                 .willReturn(aResponse()
202                                                 .withStatus(200)));
203                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
204                                 .withRequestBody(containing("PCRF"))
205                                 .willReturn(aResponse()
206                                                 .withStatus(500)
207                                                 .withHeader("Content-Type", "text/xml")
208                                                 .withBodyFile("aaiFault.xml")));
209                 stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))                          
210                                 .willReturn(aResponse()
211                                         .withStatus(200)));
212                 
213                 String body;
214                 
215                 // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
216         
217                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
218                                 .willReturn(aResponse()
219                                                 .withStatus(500)
220                                                 .withHeader("Content-Type", "text/xml")
221                                                 .withBodyFile("aaiFault.xml")));
222         
223                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
224                                 .willReturn(aResponse()
225                                                 .withStatus(404)
226                                                 .withHeader("Content-Type", "text/xml")
227                                                 .withBody("Generic VNF Not Found")));
228                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
229                                 .willReturn(aResponse()
230                                                 .withStatus(404)
231                                                 .withHeader("Content-Type", "text/xml")
232                                                 .withBody("Generic VNF Not Found")));
233         
234                 body =
235                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
236                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
237                         "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
238                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
239                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
240                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
241                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
242                         "  <in-maint>false</in-maint>" + EOL +
243                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
244                         "  <resource-version>1508691</resource-version>" + EOL +
245                         "  <vf-modules>" + EOL +
246                         "    <vf-module>" + EOL +
247                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
248                         "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
249                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
250                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
251                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
252                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
253                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
254                         "      <resource-version>1508692</resource-version>" + EOL +
255                         "    </vf-module>" + EOL +
256                         "  </vf-modules>" + EOL +
257                         "  <relationship-list/>" + EOL +
258                         "  <l-interfaces/>" + EOL +
259                         "  <lag-interfaces/>" + EOL +
260                         "</generic-vnf>" + EOL;
261                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
262                                 .willReturn(aResponse()
263                                                 .withStatus(200)
264                                                 .withHeader("Content-Type", "text/xml")
265                                                 .withBody(body)));
266                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
267                                 .willReturn(aResponse()
268                                                 .withStatus(200)
269                                                 .withHeader("Content-Type", "text/xml")
270                                                 .withBody(body)));
271         
272                 body =
273                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
274                         "  <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL +
275                         "  <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
276                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
277                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
278                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
279                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
280                         "  <in-maint>false</in-maint>" + EOL +
281                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
282                         "  <resource-version>1508691</resource-version>" + EOL +
283                         "  <vf-modules>" + EOL +
284                         "    <vf-module>" + EOL +
285                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
286                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
287                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
288                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
289                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
290                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
291                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
292                         "      <resource-version>1508692</resource-version>" + EOL +
293                         "    </vf-module>" + EOL +
294                         "    <vf-module>" + EOL +
295                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
296                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
297                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
298                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
299                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +
300                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
301                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
302                         "      <resource-version>1508692</resource-version>" + EOL +
303                         "    </vf-module>" + EOL +
304                         "  </vf-modules>" + EOL +
305                         "  <relationship-list/>" + EOL +
306                         "  <l-interfaces/>" + EOL +
307                         "  <lag-interfaces/>" + EOL +
308                         "</generic-vnf>" + EOL;
309                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
310                                 .willReturn(aResponse()
311                                                 .withStatus(200)
312                                                 .withHeader("Content-Type", "text/xml")
313                                                 .withBody(body)));
314                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
315                                 .willReturn(aResponse()
316                                                 .withStatus(200)
317                                                 .withHeader("Content-Type", "text/xml")
318                                                 .withBody(body)));
319         
320                 // The following stubs are for DeleteAAIVfModule
321         
322                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
323                                 .willReturn(aResponse()
324                                                 .withStatus(500)
325                                                 .withHeader("Content-Type", "text/xml")
326                                                 .withBodyFile("aaiFault.xml")));
327         
328                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
329                                 .willReturn(aResponse()
330                                                 .withStatus(404)
331                                                 .withHeader("Content-Type", "text/xml")
332                                                 .withBody("Generic VNF Not Found")));
333         
334                 body =
335                                 "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
336                                 "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
337                                 "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
338                                 "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
339                                 "  <service-id>SDN-MOBILITY</service-id>" + EOL +
340                                 "  <equipment-role>vMMSC</equipment-role>" + EOL +
341                                 "  <orchestration-status>pending-create</orchestration-status>" + EOL +
342                                 "  <in-maint>false</in-maint>" + EOL +
343                                 "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
344                                 "  <resource-version>0000021</resource-version>" + EOL +
345                                 "  <vf-modules>" + EOL +
346                                 "    <vf-module>" + EOL +
347                                 "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
348                                 "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
349                                 "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
350                                 "      <persona-model-version>1.0</persona-model-version>" + EOL +
351                                 "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
352                                 "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
353                                 "      <orchestration-status>pending-create</orchestration-status>" + EOL +
354                                 "      <resource-version>0000073</resource-version>" + EOL +
355                                 "    </vf-module>" + EOL +
356                                 "  </vf-modules>" + EOL +
357                                 "  <relationship-list/>" + EOL +
358                                 "  <l-interfaces/>" + EOL +
359                                 "  <lag-interfaces/>" + EOL +
360                                 "</generic-vnf>" + EOL;
361                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
362                                 .willReturn(aResponse()
363                                                 .withStatus(200)
364                                                 .withHeader("Content-Type", "text/xml")
365                                                 .withBody(body)));
366         
367                 body =
368                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
369                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
370                         "  <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
371                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
372                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
373                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
374                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
375                         "  <in-maint>false</in-maint>" + EOL +
376                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
377                         "  <resource-version>0000020</resource-version>" + EOL +
378                         "  <vf-modules>" + EOL +
379                         "    <vf-module>" + EOL +
380                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
381                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
382                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
383                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
384                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
385                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
386                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
387                         "      <resource-version>0000074</resource-version>" + EOL +
388                         "    </vf-module>" + EOL +
389                         "    <vf-module>" + EOL +
390                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
391                         "      <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
392                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL +
393                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
394                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +
395                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
396                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
397                         "      <resource-version>0000075</resource-version>" + EOL +
398                         "    </vf-module>" + EOL +
399                         "  </vf-modules>" + EOL +
400                         "  <relationship-list/>" + EOL +
401                         "  <l-interfaces/>" + EOL +
402                         "  <lag-interfaces/>" + EOL +
403                         "</generic-vnf>" + EOL;
404                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
405                                 .willReturn(aResponse()
406                                                 .withStatus(200)
407                                                 .withHeader("Content-Type", "text/xml")
408                                                 .withBody(body)));
409         
410                 body =
411                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
412                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
413                         "  <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
414                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
415                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
416                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
417                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
418                         "  <in-maint>false</in-maint>" + EOL +
419                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
420                         "  <resource-version>0000019</resource-version>" + EOL +
421                         "  <vf-modules>" + EOL +
422                         "    <vf-module>" + EOL +
423                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL +
424                         "      <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL +
425                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL +
426                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
427                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
428                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
429                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
430                         "      <resource-version>0000076</resource-version>" + EOL +
431                         "    </vf-module>" + EOL +
432                         "    <vf-module>" + EOL +
433                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
434                         "      <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
435                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL +
436                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
437                         "      <is-base-vf-module>false</is-base-vf-module>" + EOL +
438                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
439                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
440                         "      <resource-version>0000077</resource-version>" + EOL +
441                         "    </vf-module>" + EOL +
442                         "  </vf-modules>" + EOL +
443                         "  <relationship-list/>" + EOL +
444                         "  <l-interfaces/>" + EOL +
445                         "  <lag-interfaces/>" + EOL +
446                         "</generic-vnf>" + EOL;
447                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
448                                 .willReturn(aResponse()
449                                                 .withStatus(200)
450                                                 .withHeader("Content-Type", "text/xml")
451                                                 .withBody(body)));
452         
453                 body =
454                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
455                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
456                         "  <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
457                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
458                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
459                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
460                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
461                         "  <in-maint>false</in-maint>" + EOL +
462                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
463                         "  <resource-version>0000018</resource-version>" + EOL +
464                         "  <vf-modules>" + EOL +
465                         "    <vf-module>" + EOL +
466                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
467                         "      <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
468                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL +
469                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
470                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
471                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
472                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
473                         "      <resource-version>0000078</resource-version>" + EOL +
474                         "    </vf-module>" + EOL +
475                         "  </vf-modules>" + EOL +
476                         "  <relationship-list/>" + EOL +
477                         "  <l-interfaces/>" + EOL +
478                         "  <lag-interfaces/>" + EOL +
479                         "</generic-vnf>" + EOL;
480                 stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
481                                 .willReturn(aResponse()
482                                                 .withStatus(200)
483                                                 .withHeader("Content-Type", "text/xml")
484                                                 .withBody(body)));
485         
486                 body =
487                         "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
488                         "  <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
489                         "  <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
490                         "  <vnf-type>mmsc-capacity</vnf-type>" + EOL +
491                         "  <service-id>SDN-MOBILITY</service-id>" + EOL +
492                         "  <equipment-role>vMMSC</equipment-role>" + EOL +
493                         "  <orchestration-status>pending-create</orchestration-status>" + EOL +
494                         "  <in-maint>false</in-maint>" + EOL +
495                         "  <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
496                         "  <resource-version>0000021</resource-version>" + EOL +
497                         "  <vf-modules>" + EOL +
498                         "    <vf-module>" + EOL +
499                         "      <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
500                         "      <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
501                         "      <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
502                         "      <persona-model-version>1.0</persona-model-version>" + EOL +
503                         "      <is-base-vf-module>true</is-base-vf-module>" + EOL +
504                         "      <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
505                         "      <orchestration-status>pending-create</orchestration-status>" + EOL +
506                         "      <resource-version>0000073</resource-version>" + EOL +
507                         "    </vf-module>" + EOL +
508                         "  </vf-modules>" + EOL +
509                         "  <relationship-list/>" + EOL +
510                         "  <l-interfaces/>" + EOL +
511                         "  <lag-interfaces/>" + EOL +
512                         "</generic-vnf>" + EOL;
513                 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"))
514                                 .willReturn(aResponse()
515                                                 .withStatus(200)
516                                                 .withHeader("Content-Type", "text/xml")
517                                                 .withBody(body)));
518
519                 String businessKey = UUID.randomUUID().toString();
520                 String deleteVfModuleRequest =
521                                 FileUtil.readResourceFile("__files/DeleteVfModule_VID_request.json");
522                 //Map<String, Object> variables = new HashMap<String, Object>();        
523                 
524                 //variables.put("isDebugLogEnabled","true");
525 //              variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
526 //              variables.put("mso-service-instance-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
527                 
528                 Map<String, Object> variables = setupVariablesSunnyDayVID();
529
530                 TestAsyncResponse asyncResponse = invokeAsyncProcess("DeleteVfModuleInfra",
531                                 "v1", businessKey, deleteVfModuleRequest, variables);
532                 WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000);
533                 String responseBody = response.getResponse();
534                 System.out.println("Workflow (Synch) Response:\n" + responseBody);
535
536                 // "changedelete" operation not required for deleting a Vf Module
537 //              injectSDNCCallbacks(callbacks, "sdncChangeDelete");
538                 injectVNFRestCallbacks(callbacks, "vnfDelete");
539                 waitForRunningProcessCount("vnfAdapterDeleteV1", 0, 120000);
540                 injectSDNCCallbacks(callbacks, "sdncDelete");
541
542                 waitForProcessEnd(businessKey, 10000);
543                 WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
544                 checkVariable(businessKey, "DeleteVfModuleInfraSuccessIndicator", true);
545                 checkVariable(businessKey, "WorkflowException", null);
546                 if (wfe != null) {
547                         System.out.println("TestDeleteVfModuleInfraSuccess: ErrorCode=" + wfe.getErrorCode() +
548                                         ", ErrorMessage=" + wfe.getErrorMessage());
549                 }
550                 logEnd();
551         }
552         
553         // Active Scenario
554                         private Map<String, Object> setupVariablesSunnyDayVID() {
555                                 Map<String, Object> variables = new HashMap<String, Object>();
556                                 //try {
557                                 //      variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"));
558                                 //}
559                                 //catch (Exception e) {
560                                         
561                                 //}
562                                 //variables.put("mso-request-id", "testRequestId");
563                                 variables.put("requestId", "testRequestId");            
564                                 variables.put("isBaseVfModule", "true");
565                                 variables.put("isDebugLogEnabled", "true");
566                                 variables.put("recipeTimeout", "0");            
567                                 variables.put("requestAction", "DELETE_VF_MODULE");
568                                 variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4");
569                                 variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
570                                 variables.put("vfModuleId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
571                                 variables.put("volumeGroupId", "");                     
572                                 variables.put("serviceType", "MOG");    
573                                 variables.put("vfModuleType", "");                      
574                                 return variables;
575                                 
576                         }
577
578         
579 }