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