Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / vcpe / CreateVcpeResCustServiceIT.java
1 /*
2  * ============LICENSE_START======================================================= ONAP - SO
3  * ================================================================================ Copyright (C) 2017 AT&T Intellectual
4  * Property. All rights reserved. ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * 
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  * ============LICENSE_END=========================================================
14  */
15
16 package org.onap.so.bpmn.vcpe;
17
18 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
19 import static com.github.tomakehurst.wiremock.client.WireMock.get;
20 import static com.github.tomakehurst.wiremock.client.WireMock.post;
21 import static com.github.tomakehurst.wiremock.client.WireMock.put;
22 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetCustomer;
29 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
30 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
31 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicyfqdn;
32 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
33 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500;
34 import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
35 import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404;
36 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
37 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchGenericVnf;
38 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource;
39 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
40 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutNetwork;
41 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
42 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
43 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
44 import static org.onap.so.bpmn.mock.StubResponseDatabase.MockPostRequestDB;
45 import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
46 import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
47 import static org.onap.so.bpmn.mock.StubResponseVNFAdapter.mockVNFPost;
48 import java.io.IOException;
49 import java.util.HashMap;
50 import java.util.Map;
51 import java.util.UUID;
52 import org.junit.Before;
53 import org.junit.Test;
54 import org.onap.so.bpmn.common.BPMNUtil;
55 import org.onap.so.bpmn.mock.FileUtil;
56 import org.onap.so.bpmn.mock.StubResponseOof;
57
58
59 public class CreateVcpeResCustServiceIT extends AbstractTestBase {
60
61     private static final String PROCNAME = "CreateVcpeResCustService";
62     private static final String Prefix = "CVRCS_";
63
64     private final CallbackSet callbacks = new CallbackSet();
65     private final String request;
66
67     @Before
68     public void init() {
69         BPMNUtil.cleanHistory(processEngine);
70     }
71
72     public CreateVcpeResCustServiceIT() throws IOException {
73
74         callbacks.put("oof", JSON, "oofResponse",
75                 FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/oofCallbackInfraVnf.json"));
76         callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
77         callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
78         callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
79         callbacks.put("queryTXC",
80                 FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml"));
81         callbacks.put("queryBRG",
82                 FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml"));
83         callbacks.put("deactivate",
84                 FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml"));
85         callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml"));
86         callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml"));
87
88         callbacks.put("query", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallback.xml"));
89         callbacks.put("queryVnf", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVnf.xml"));
90         callbacks.put("queryModuleNoVnf",
91                 FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModuleNoVnf.xml"));
92         callbacks.put("queryModule",
93                 FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml"));
94         callbacks.put("vnfCreate", FileUtil.readResourceFile("__files/VfModularity/VNFAdapterRestCreateCallback.xml"));
95
96         request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestNoSIName.json");
97     }
98
99     @Test
100     public void testCreateVcpeResCustService_Success() throws Exception {
101         System.out.println("starting:  testCreateVcpeResCustService_Success\n");
102         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
103                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
104         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
105                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
106         MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
107         StubResponseOof.mockOof(wireMockServer);
108         // TODO: the SI should NOT have to be URL-encoded yet again!
109         MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
110                 "GenericFlows/getServiceInstance.xml");
111         MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
112                 "GenericFlows/getServiceInstance.xml");
113
114         MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
115         MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
116         MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
117         MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
118         MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
119         MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
120         MockGetGenericVnfByIdWithDepth(wireMockServer, ".*", 1, "VCPE/CreateVcpeResCustService/GenericVnf.xml");
121
122         MockPutGenericVnf(wireMockServer, ".*");
123         MockPatchGenericVnf(wireMockServer, ".*");
124
125         MockGetGenericVnfByIdWithPriority(wireMockServer, ".*", ".*", 200, "VfModularity/VfModule-new.xml", 5);
126         // MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
127         MockPutVfModuleIdNoResponse(wireMockServer, ".*", "PCRF", ".*");
128         MockPutNetwork(wireMockServer, ".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200);
129
130         MockGetNetworkPolicyfqdn(wireMockServer, ".*",
131                 "CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200);
132         MockNodeQueryServiceInstanceByName_404(wireMockServer, ".*");
133
134         mockVNFPost(wireMockServer, "", 202, ".*");
135
136         wireMockServer.stubFor(post(urlMatching("/services/rest/v1/vnfs" + ".*" + "/vf-modules"))
137                 .willReturn(aResponse().withStatus(202)));
138         wireMockServer
139                 .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
140         wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
141                 .willReturn(aResponse().withStatus(200)));
142         wireMockServer.stubFor(put(urlMatching(
143                 ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
144                         .willReturn(aResponse().withStatus(200)));
145         wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
146         MockPostRequestDB(wireMockServer);
147         mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
148         mockSDNCAdapter(wireMockServer, 200);
149
150         Map<String, Object> variables = setupVariables();
151
152         String businessKey = UUID.randomUUID().toString();
153         invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
154
155         injectWorkflowMessages(callbacks, "oof");
156         // for SI
157         injectSDNCCallbacks(callbacks, "assign");
158         // for TXC
159         injectSDNCCallbacks(callbacks, "assign");
160         injectSDNCCallbacks(callbacks, "create");
161         injectSDNCCallbacks(callbacks, "activate");
162         injectSDNCCallbacks(callbacks, "queryTXC");
163
164         // For VNF
165         injectSDNCCallbacks(callbacks, "assign");
166         injectSDNCCallbacks(callbacks, "assign");
167         injectSDNCCallbacks(callbacks, "queryModule");
168         injectSDNCCallbacks(callbacks, "activate");
169         // VF Module
170         injectSDNCCallbacks(callbacks, "queryModule");
171         injectSDNCCallbacks(callbacks, "assign");
172         injectSDNCCallbacks(callbacks, "queryModule");
173         injectSDNCCallbacks(callbacks, "queryModule");
174         injectSDNCCallbacks(callbacks, "assign");
175         injectSDNCCallbacks(callbacks, "queryModuleNoVnf");
176         injectVNFRestCallbacks(callbacks, "vnfCreate");
177         injectSDNCCallbacks(callbacks, "activate");
178
179         // for BRG
180         injectSDNCCallbacks(callbacks, "assign");
181         injectSDNCCallbacks(callbacks, "create");
182         injectSDNCCallbacks(callbacks, "activate");
183         injectSDNCCallbacks(callbacks, "queryBRG");
184
185         waitForProcessEnd(businessKey, 10000);
186
187         String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
188         System.out.println("workflowException:\n" + workflowException);
189
190         String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
191         System.out.println("completionReq:\n" + completionReq);
192
193         assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
194         assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
195         assertEquals(null, workflowException);
196         assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
197         assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
198         assertTrue(completionReq.indexOf("source>VID<") >= 0);
199
200         assertEquals("1", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "VnfsCreatedCount"));
201     }
202
203     @Test
204     public void testCreateVcpeResCustService_NoParts() throws Exception {
205         System.out.println("starting: testCreateVcpeResCustService_NoParts\n");
206         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
207                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
208         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
209                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json");
210         MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
211
212         // TODO: the SI should NOT have to be URL-encoded yet again!
213         MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
214                 "GenericFlows/getServiceInstance.xml");
215         MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
216                 "GenericFlows/getServiceInstance.xml");
217
218         MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
219         MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
220         MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
221         MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
222
223         // TODO: should these really be PARENT_INST, or should they be INST?
224         MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
225         MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
226
227         mockSDNCAdapter(wireMockServer, 200);
228         mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
229
230         StubResponseOof.mockOof(wireMockServer);
231         wireMockServer
232                 .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
233         wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
234                 .willReturn(aResponse().withStatus(200)));
235         wireMockServer.stubFor(put(urlMatching(
236                 ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
237                         .willReturn(aResponse().withStatus(200)));
238         wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
239         MockPostRequestDB(wireMockServer);
240         mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
241
242         Map<String, Object> variables = setupVariables();
243
244         String businessKey = UUID.randomUUID().toString();
245         invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
246
247         injectWorkflowMessages(callbacks, "oof");
248         // for SI
249         injectSDNCCallbacks(callbacks, "assign");
250
251         waitForProcessEnd(businessKey, 10000);
252
253         String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
254         System.out.println("workflowException:\n" + workflowException);
255
256         String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
257         System.out.println("completionReq:\n" + completionReq);
258
259         assertEquals("true", BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
260         assertEquals("200", BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
261         assertEquals(null, workflowException);
262         assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0);
263         assertTrue(completionReq.indexOf("action>CREATE<") >= 0);
264         assertTrue(completionReq.indexOf("source>VID<") >= 0);
265
266         assertEquals("0", BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + "VnfsCreatedCount"));
267     }
268
269     @Test
270     public void testCreateVcpeResCustService_Fault_NoRollback() throws Exception {
271         System.out.println("starting:  testCreateVcpeResCustService_Fault_NoRollback\n");
272         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
273                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
274         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
275                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
276         MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
277
278         // TODO: the SI should NOT have to be URL-encoded yet again!
279         MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
280                 "GenericFlows/getServiceInstance.xml");
281         MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
282                 "GenericFlows/getServiceInstance.xml");
283
284         MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
285         MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
286         MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
287         MockGetServiceInstance_500(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
288         MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
289         MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
290
291         mockSDNCAdapter(wireMockServer, 404);
292         mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
293
294         StubResponseOof.mockOof(wireMockServer);
295         wireMockServer
296                 .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
297         wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
298                 .willReturn(aResponse().withStatus(200)));
299         wireMockServer.stubFor(put(urlMatching(
300                 ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
301                         .willReturn(aResponse().withStatus(200)));
302         wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
303         MockPostRequestDB(wireMockServer);
304
305         Map<String, Object> variables = setupVariables();
306
307         String businessKey = UUID.randomUUID().toString();
308         invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables);
309
310         injectWorkflowMessages(callbacks, "oof");
311
312         waitForProcessEnd(businessKey, 100000);
313
314         String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
315         System.out.println("workflowException:\n" + workflowException);
316
317         String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
318         System.out.println("completionReq:\n" + completionReq);
319
320         assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
321         assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
322         assertNotNull(workflowException);
323
324         BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceBRGRollback");
325         BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateVnfAndModulesRollback");
326         BPMNUtil.assertNoProcessInstance(processEngine, "DoCreateAllottedResourceTXCRollback");
327     }
328
329     @Test
330     public void testCreateVcpeResCustService_Fault_Rollback() throws Exception {
331         System.out.println("starting:  testCreateVcpeResCustService_Fault_Rollback\n");
332         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef", "2",
333                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
334         MockGetServiceResourcesCatalogData(wireMockServer, "uuid-miu-svc-011-abcdef",
335                 "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json");
336         MockGetCustomer(wireMockServer, CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml");
337
338         // TODO: the SI should NOT have to be URL-encoded yet again!
339         MockPutServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
340                 "GenericFlows/getServiceInstance.xml");
341         MockGetServiceInstance(wireMockServer, CUST, SVC, INST.replace("%", "%25"),
342                 "GenericFlows/getServiceInstance.xml");
343
344         MockNodeQueryServiceInstanceById(wireMockServer, INST, "GenericFlows/getSIUrlById.xml");
345         MockNodeQueryServiceInstanceById(wireMockServer, PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
346         MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
347         MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
348         MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml");
349         MockGetAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID,
350                 "VCPE/CreateVcpeResCustService/arGetById.xml");
351         MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
352         MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
353         MockDeleteAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID, ARVERS);
354
355         mockSDNCAdapter(wireMockServer, 200);
356         mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
357
358         StubResponseOof.mockOof(wireMockServer);
359         wireMockServer
360                 .stubFor(get(urlMatching(".*/business/owning-entities?.*")).willReturn(aResponse().withStatus(404)));
361         wireMockServer.stubFor(put(urlMatching(".*/business/owning-entities/owning-entity/.*"))
362                 .willReturn(aResponse().withStatus(200)));
363         wireMockServer.stubFor(put(urlMatching(
364                 ".*/business/owning-entities/owning-entity/038d99af-0427-42c2-9d15-971b99b9b489/relationship-list/relationship"))
365                         .willReturn(aResponse().withStatus(200)));
366         wireMockServer.stubFor(put(urlMatching(".*/query?.*")).willReturn(aResponse().withStatus(200)));
367         MockPostRequestDB(wireMockServer);
368         String req = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestRollback.json");
369
370         Map<String, Object> variables = setupVariables();
371
372         String businessKey = UUID.randomUUID().toString();
373         invokeAsyncProcess(PROCNAME, "v1", businessKey, req, variables);
374
375         injectWorkflowMessages(callbacks, "oof");
376         // for SI
377         injectSDNCCallbacks(callbacks, "assign");
378
379         // for TXC
380         injectSDNCCallbacks(callbacks, "assign");
381         injectSDNCCallbacks(callbacks, "create");
382
383         waitForProcessEnd(businessKey, 10000);
384
385         String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX);
386         System.out.println("workflowException:\n" + workflowException);
387
388         String completionReq = BPMNUtil.getVariable(processEngine, PROCNAME, Prefix + VAR_COMP_REQ);
389         System.out.println("completionReq:\n" + completionReq);
390
391         assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, PROCNAME + VAR_SUCCESS_IND));
392         assertEquals(null, BPMNUtil.getVariable(processEngine, PROCNAME, VAR_RESP_CODE));
393         assertEquals(null, completionReq);
394         assertNotNull(workflowException);
395
396         BPMNUtil.assertAnyProcessInstanceFinished(processEngine, "DoCreateServiceInstanceRollback");
397     }
398
399     // *****************
400     // Utility Section
401     // *****************
402
403     // Success Scenario
404     private Map<String, Object> setupVariables() {
405         Map<String, Object> variables = new HashMap<>();
406         variables.put("requestId", "testRequestId");
407         variables.put("request-id", "testRequestId");
408         variables.put("serviceInstanceId", DEC_INST);
409         variables.put("allottedResourceId", ARID);
410         variables.put("URN_mso_workflow_aai_distribution_delay", "PT5S");
411         return variables;
412
413     }
414 }