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