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