4e62a566a767c3ba31da127ce15139426669db2b
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / groovy / org / openecomp / mso / bpmn / vcpe / scripts / DoDeleteAllottedResourceBRGTest.groovy
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 package org.openecomp.mso.bpmn.vcpe.scripts
21
22
23 import org.camunda.bpm.engine.ProcessEngineServices
24 import org.camunda.bpm.engine.RepositoryService
25 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
26 import org.camunda.bpm.engine.repository.ProcessDefinition
27 import org.camunda.bpm.engine.runtime.Execution
28 import org.junit.Before
29 import org.junit.BeforeClass
30 import org.junit.Rule
31 import org.junit.Test
32 import org.junit.Ignore
33 import org.mockito.MockitoAnnotations
34 import org.camunda.bpm.engine.delegate.BpmnError
35 import org.openecomp.mso.bpmn.core.WorkflowException
36 import org.openecomp.mso.bpmn.mock.FileUtil
37
38 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
39 import static com.github.tomakehurst.wiremock.client.WireMock.delete
40 import static com.github.tomakehurst.wiremock.client.WireMock.get
41 import static com.github.tomakehurst.wiremock.client.WireMock.patch
42 import static com.github.tomakehurst.wiremock.client.WireMock.put
43 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
44 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
45 import static org.junit.Assert.*;
46 import static org.mockito.Mockito.*
47 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource
48 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource
49 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource
50 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById
51
52 import java.util.Map
53
54 import org.openecomp.mso.bpmn.core.RollbackData
55 import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter
56
57 import com.github.tomakehurst.wiremock.junit.WireMockRule
58
59 class DoDeleteAllottedResourceBRGTest extends GroovyTestBase {
60         
61         @Rule
62         public WireMockRule wireMockRule = new WireMockRule(PORT)
63
64         String Prefix = "DDARBRG_"
65
66         @BeforeClass
67         public static void setUpBeforeClass() {
68                 // nothing for now
69         }
70           
71     @Before
72         public void init()
73         {
74                 MockitoAnnotations.initMocks(this)
75         }
76         
77         public DoDeleteAllottedResourceBRGTest() {
78                 super("DoDeleteAllottedResourceBRG")
79         }
80         
81         
82         // ***** preProcessRequest *****
83                         
84         @Test
85 //      @Ignore  
86         public void preProcessRequest() {
87                 ExecutionEntity mex = setupMock()
88                 initPreProcess(mex)
89                 
90                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
91                 DoDeleteAllottedResourceBRG.preProcessRequest(mex)
92
93                 verify(mex).getVariable(DBGFLAG)
94                 verify(mex).setVariable("prefix", Prefix)
95                 verify(mex).setVariable("sdncCallbackUrl", "sdncurn")
96                                 
97                 assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback"))
98                 assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
99                 assertTrue(checkMissingPreProcessRequest("allottedResourceId"))
100         }
101                         
102         @Test
103 //      @Ignore  
104         public void preProcessRequest_BpmnError() {
105                 ExecutionEntity mex = setupMock()
106                 initPreProcess(mex)
107                 
108                 when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception"))
109                 
110                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
111                 
112                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
113         }
114                         
115         @Test
116 //      @Ignore  
117         public void preProcessRequest_Ex() {
118                 ExecutionEntity mex = setupMock()
119                 initPreProcess(mex)
120                 
121                 when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
122                 
123                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
124                 
125                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }))
126         }
127         
128         
129         // ***** getAaiAR *****
130         
131         @Test
132 //      @Ignore
133         public void getAaiAR() {
134                 MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml")
135                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
136                 
137                 ExecutionEntity mex = setupMock()
138                 initGetAaiAR(mex)
139                 
140                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
141                 DoDeleteAllottedResourceBRG.getAaiAR(mex)
142                 
143                 verify(mex).setVariable("parentServiceInstanceId", INST)
144         }
145         
146         @Test
147 //      @Ignore
148         public void getAaiAR_EmptyResponse() {
149                 
150                 // note: empty result-link
151                 wireMockRule
152                         .stubFor(get(urlMatching("/aai/.*/search/.*"))
153                                         .willReturn(aResponse()
154                                                 .withStatus(200)
155                                                 .withHeader("Content-Type", "text/xml")
156                                                 .withBody("<result-data></result-data>")))
157                         
158                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
159                 
160                 ExecutionEntity mex = setupMock()
161                 initGetAaiAR(mex)
162                 
163                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
164                 
165                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.getAaiAR(mex) }))
166         }
167         
168         
169         // ***** updateAaiAROrchStatus *****
170         
171         @Test
172 //      @Ignore
173         public void updateAaiAROrchStatus() {
174                 ExecutionEntity mex = setupMock()
175                 initUpdateAaiAROrchStatus(mex)
176                 
177                 MockPatchAllottedResource(CUST, SVC, INST, ARID)
178                                         
179                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
180                 DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
181         }
182         
183         
184         // ***** buildSDNCRequest *****
185         
186         @Test
187 //      @Ignore
188         public void buildSDNCRequest() {
189                 ExecutionEntity mex = setupMock()
190                 initBuildSDNCRequest(mex)
191                 
192                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
193                 
194                 String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
195                 
196                 assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
197                 assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
198                 assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
199                 assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
200                 assertTrue(result.indexOf("<service-instance-id>sii</") >= 0)
201                 assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
202                 assertTrue(result.indexOf("<subscription-service-type>sst</") >= 0)
203                 assertTrue(result.indexOf("<global-customer-id>gci</") >= 0)
204                 assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
205                 assertTrue(result.indexOf("<request-id>mri</") >= 0)
206                 assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
207                 assertTrue(result.indexOf("<model-uuid/>") >= 0)
208                 assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
209                 assertTrue(result.indexOf("<model-version/>") >= 0)
210                 assertTrue(result.indexOf("<model-name/>") >= 0)
211         }
212         
213         @Test
214 //      @Ignore
215         public void buildSDNCRequest_Ex() {
216                 ExecutionEntity mex = setupMock()
217                 initBuildSDNCRequest(mex)
218                 
219                 when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
220                 
221                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
222                 
223                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
224         }
225         
226         
227         // ***** preProcessSDNCUnassign *****
228         
229         @Test
230 //      @Ignore
231         public void preProcessSDNCUnassign() {
232                 ExecutionEntity mex = setupMock()
233                 def map = setupMap(mex)
234                 initPreProcessSDNC(mex)
235                                         
236                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
237                 DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex)
238                 
239                 def req = map.get("sdncUnassignRequest")
240                 
241                 assertTrue(req.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
242                 assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
243                 assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
244         }
245         
246         @Test
247 //      @Ignore
248         public void preProcessSDNCUnassign_BpmnError() {
249                 ExecutionEntity mex = setupMock()
250                 initPreProcessSDNC(mex)
251                 
252                 when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
253                                         
254                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
255                 
256                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
257         }
258         
259         @Test
260 //      @Ignore
261         public void preProcessSDNCUnassign_Ex() {
262                 ExecutionEntity mex = setupMock()
263                 initPreProcessSDNC(mex)
264                 
265                 when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
266                                         
267                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
268                 
269                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) }))
270         }
271         
272         
273         // ***** preProcessSDNCDelete *****
274         
275         @Test
276 //      @Ignore
277         public void preProcessSDNCDelete() {
278                 ExecutionEntity mex = setupMock()
279                 def map = setupMap(mex)
280                 initPreProcessSDNC(mex)
281                                         
282                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
283                 DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex)
284                 
285                 def req = map.get("sdncDeleteRequest")
286                 
287                 assertTrue(req.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
288                 assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
289                 assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
290         }
291         
292         @Test
293 //      @Ignore
294         public void preProcessSDNCDelete_BpmnError() {
295                 ExecutionEntity mex = setupMock()
296                 initPreProcessSDNC(mex)
297                 
298                 when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
299                                         
300                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
301                 
302                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
303         }
304         
305         @Test
306 //      @Ignore
307         public void preProcessSDNCDelete_Ex() {
308                 ExecutionEntity mex = setupMock()
309                 initPreProcessSDNC(mex)
310                 
311                 when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
312                                         
313                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
314                 
315                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) }))
316         }
317         
318         
319         // ***** preProcessSDNCDeactivate *****
320         
321         @Test
322 //      @Ignore
323         public void preProcessSDNCDeactivate() {
324                 ExecutionEntity mex = setupMock()
325                 def map = setupMap(mex)
326                 initPreProcessSDNC(mex)
327                                         
328                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
329                 DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex)
330                 
331                 def req = map.get("sdncDeactivateRequest")
332                 
333                 assertTrue(req.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
334                 assertTrue(req.indexOf("<request-action>DeleteBRGInstance</") >= 0)
335                 assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
336         }
337         
338         @Test
339 //      @Ignore
340         public void preProcessSDNCDeactivate_BpmnError() {
341                 ExecutionEntity mex = setupMock()
342                 initPreProcessSDNC(mex)
343                 
344                 when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception"))
345                                         
346                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
347                 
348                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
349         }
350         
351         @Test
352 //      @Ignore
353         public void preProcessSDNCDeactivate_Ex() {
354                 ExecutionEntity mex = setupMock()
355                 initPreProcessSDNC(mex)
356                 
357                 when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
358                                         
359                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
360                 
361                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) }))
362         }
363         
364         
365         // ***** validateSDNCResp *****
366         
367         @Test
368 //      @Ignore
369         public void validateSDNCResp() {
370                 ExecutionEntity mex = setupMock()
371                 def data = initValidateSDNCResp(mex)
372                 def resp = initValidateSDNCResp_Resp(200)
373                 
374                 when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
375                 
376                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
377                 
378                 DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
379                 
380                 verify(mex).getVariable("WorkflowException")
381                 verify(mex).getVariable("SDNCA_SuccessIndicator")               
382                 verify(mex).getVariable(Prefix+"sdncResponseSuccess")
383                 
384                 verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode")
385                 verify(mex, never()).setVariable("wasDeleted", false)
386         }
387         
388         @Test
389 //      @Ignore
390         public void validateSDNCResp_Fail404_Deactivate_FailNotFound() {
391                 ExecutionEntity mex = setupMock()
392                 def data = initValidateSDNCResp(mex)
393                 
394                 def resp = initValidateSDNCResp_Resp(404)
395                 when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
396                 when(mex.getVariable("failNotFound")).thenReturn("true")
397                 
398                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
399                 
400                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")}))
401         }
402         
403         @Test
404 //      @Ignore
405         public void validateSDNCResp_Fail404_Deactivate() {
406                 ExecutionEntity mex = setupMock()
407                 def data = initValidateSDNCResp(mex)
408                 
409                 def resp = initValidateSDNCResp_Resp(404)
410                 when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
411                 
412                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
413                 
414                 DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")
415                 
416                 verify(mex).setVariable("ARNotFoundInSDNC", true)
417                 verify(mex).setVariable("wasDeleted", false)
418         }
419         
420         @Test
421 //      @Ignore
422         public void validateSDNCResp_Fail404() {
423                 ExecutionEntity mex = setupMock()
424                 def data = initValidateSDNCResp(mex)
425                 
426                 def resp = initValidateSDNCResp_Resp(404)
427                 when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404")
428                 
429                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
430                 
431                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")}))
432         }
433         
434         @Test
435 //      @Ignore
436         public void validateSDNCResp_Deactivate() {
437                 ExecutionEntity mex = setupMock()
438                 def data = initValidateSDNCResp(mex)
439                 def resp = initValidateSDNCResp_Resp(200)
440                 
441                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
442                 
443                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")}))
444         }
445         
446         @Test
447 //      @Ignore
448         public void validateSDNCResp_BpmnError() {
449                 ExecutionEntity mex = setupMock()
450                 initValidateSDNCResp(mex)
451                 def resp = initValidateSDNCResp_Resp(200)
452                 
453                 when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
454                 
455                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
456                 
457                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
458         }
459         
460         @Test
461 //      @Ignore
462         public void validateSDNCResp_Ex() {
463                 ExecutionEntity mex = setupMock()
464                 initValidateSDNCResp(mex)
465                 def resp = initValidateSDNCResp_Resp(200)
466                 
467                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
468                 
469                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
470                 
471                 assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
472         }
473                         
474         @Test
475 //      @Ignore  
476         public void deleteAaiAR() {
477                 ExecutionEntity mex = setupMock()
478                 initDeleteAaiAR(mex)
479                 
480                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
481                 MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
482                 
483                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
484                 DoDeleteAllottedResourceBRG.deleteAaiAR(mex)
485         }
486                         
487         @Test
488 //      @Ignore  
489         public void deleteAaiAR_NoArPath() {
490                 ExecutionEntity mex = setupMock()
491                 initDeleteAaiAR(mex)
492                 
493                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
494                 MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
495                         
496                 when(mex.getVariable("aaiARPath")).thenReturn("")
497                 
498                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
499                 
500                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
501         }
502                         
503         @Test
504 //      @Ignore  
505         public void deleteAaiAR_BpmnError() {
506                 ExecutionEntity mex = setupMock()
507                 initDeleteAaiAR(mex)
508                 
509                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
510                 MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
511                         
512                 when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception"))
513                 
514                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
515                 
516                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
517         }
518                         
519         @Test
520 //      @Ignore  
521         public void deleteAaiAR_Ex() {
522                 ExecutionEntity mex = setupMock()
523                 initDeleteAaiAR(mex)
524                 
525                 MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml")
526                 MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS)
527                         
528                 when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception"))
529                 
530                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
531                 
532                 assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) }))
533         }
534         
535         private boolean checkMissingPreProcessRequest(String fieldnm) {
536                 ExecutionEntity mex = setupMock()
537                 initPreProcess(mex)
538                                                                 
539                 DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG()
540                 
541                 when(mex.getVariable(fieldnm)).thenReturn("")
542                 
543                 return doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })
544         }
545         
546         private void initPreProcess(ExecutionEntity mex) {
547                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
548                 when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn")
549                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
550                 when(mex.getVariable("allottedResourceId")).thenReturn("ari")
551         }
552         
553         private void initGetAaiAR(ExecutionEntity mex) {
554                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
555                 when(mex.getVariable("allottedResourceType")).thenReturn("BRG")
556                 when(mex.getVariable("allottedResourceRole")).thenReturn("BRG")
557                 when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
558                 when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceBRG/getAR.xml"))
559                 when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace"))
560                 when(mex.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn(urnProps.get("mso.workflow.global.default.aai.version"))
561                 when(mex.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn(urnProps.get("mso.workflow.default.aai.v8.nodes-query.uri"))
562                 when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
563                 when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
564                 when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
565         }
566         
567         private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
568                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
569                 when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
570         }
571         
572         private initBuildSDNCRequest(ExecutionEntity mex) {
573                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
574                 when(mex.getVariable("allottedResourceId")).thenReturn("ari")
575                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
576                 when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
577                 when(mex.getVariable("subscriptionServiceType")).thenReturn("sst")
578                 when(mex.getVariable("globalCustomerId")).thenReturn("gci")
579                 when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
580                 when(mex.getVariable("msoRequestId")).thenReturn("mri")
581         }
582         
583         private initPreProcessSDNC(ExecutionEntity mex) {
584                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
585         }
586         
587         private initValidateSDNCResp(ExecutionEntity mex) {
588                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
589                 when(mex.getVariable("prefix")).thenReturn(Prefix)
590                 when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
591         }
592         
593         private String initValidateSDNCResp_Resp(int code) {
594                 return "<response-data>&lt;response-code&gt;${code}&lt;/response-code&gt;</response-data>"
595         }
596         
597         private initDeleteAaiAR(ExecutionEntity mex) {
598                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
599                 when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID)
600                 when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers")
601                 when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
602         }
603                 
604 }