Containerization feature of SO
[so.git] / bpmn / so-bpmn-infrastructure-flows / src / test / groovy / org / onap / so / bpmn / vcpe / scripts / CreateVcpeResCustServiceTest.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.onap.so.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.onap.so.bpmn.core.WorkflowException
35 import org.onap.so.bpmn.core.domain.HomingSolution
36 import org.onap.so.bpmn.mock.FileUtil
37
38 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
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.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource
47 import org.onap.so.bpmn.core.domain.ServiceDecomposition
48 import org.onap.so.bpmn.core.domain.VnfResource
49 import org.onap.so.bpmn.core.domain.AllottedResource
50 import org.onap.so.bpmn.core.domain.ModelInfo
51 import org.onap.so.bpmn.core.domain.HomingSolution
52 import org.onap.so.bpmn.core.RollbackData
53 import org.onap.so.bpmn.vcpe.scripts.MapGetter
54 import org.onap.so.bpmn.vcpe.scripts.MapSetter
55
56 import com.github.tomakehurst.wiremock.junit.WireMockRule
57
58 class CreateVcpeResCustServiceTest extends GroovyTestBase {
59         
60         private static String request
61         
62         @Rule
63         public WireMockRule wireMockRule = new WireMockRule(PORT)
64
65         String Prefix = "CVRCS_"
66         String RbType = "DCRENI_"
67
68         @BeforeClass
69         public static void setUpBeforeClass() {
70                 request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json")
71         }
72           
73     @Before
74         public void init()
75         {
76                 MockitoAnnotations.initMocks(this)
77         }
78         
79         public CreateVcpeResCustServiceTest() {
80                 super("CreateVcpeResCustService")
81         }
82         
83         
84         // ***** preProcessRequest *****
85                         
86         @Test
87         @Ignore // 1802 merge
88         public void preProcessRequest() {
89                 ExecutionEntity mex = setupMock()
90                 def map = setupMap(mex)
91                 initPreProcess(mex)
92                 
93                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
94                 CreateVcpeResCustService.preProcessRequest(mex)
95
96                 verify(mex).getVariable(DBGFLAG)
97                 verify(mex).setVariable("prefix", Prefix)
98                 verify(mex).setVariable("aaiDistDelay", "aaidelay")
99                 verify(mex).setVariable("createVcpeServiceRequest", request)
100                 verify(mex).setVariable("msoRequestId", "mri")
101                 assertEquals("sii", map.get("serviceInstanceId"))
102                 verify(mex).setVariable("requestAction", "ra")
103                 verify(mex).setVariable("source", "VID")
104                 verify(mex).setVariable("globalSubscriberId", CUST)
105                 verify(mex).setVariable("globalCustomerId", CUST)
106                 verify(mex).setVariable("subscriptionServiceType", SVC)
107                 verify(mex).setVariable("disableRollback", "false")
108                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")              
109                 assertTrue(map.containsKey("subscriberInfo"))
110                 
111                 verify(mex).setVariable("brgWanMacAddress", "brgmac")
112                 verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"])
113                 verify(mex).setVariable("homingService", "sniro")
114                 assertTrue(map.containsKey("serviceInputParams"))
115                 assertTrue(map.containsKey(Prefix+"requestInfo"))
116                 
117                 def reqinfo = map.get(Prefix+"requestInfo")
118                 assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
119                 assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
120         }
121                         
122         @Test
123         // @Ignore  
124         public void preProcessRequest_MissingAaiDistDelay() {
125                 ExecutionEntity mex = setupMock()
126                 def map = setupMap(mex)
127                 initPreProcess(mex)
128                 
129                 when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn(null)
130                 
131                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
132                 
133                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
134         }
135                         
136         @Test
137         @Ignore // 1802 merge
138         public void preProcessRequest_EmptyParts() {
139                 ExecutionEntity mex = setupMock()
140                 def map = setupMap(mex)
141                 initPreProcess(mex)
142                 
143                 def req = request
144                                         .replace('"source"', '"sourceXXX"')
145                                         .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"')
146                                         .replace('"Customer_Location"', '"Customer_LocationXXX"')
147                 
148                 when(mex.getVariable("bpmnRequest")).thenReturn(req)
149                 when(mex.getVariable("serviceInstanceId")).thenReturn(null)
150                 
151                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
152                 CreateVcpeResCustService.preProcessRequest(mex)
153
154                 verify(mex).getVariable(DBGFLAG)
155                 verify(mex).setVariable("prefix", Prefix)
156                 verify(mex).setVariable("createVcpeServiceRequest", req)
157                 verify(mex).setVariable("msoRequestId", "mri")
158                 assertNotNull(map.get("serviceInstanceId"))
159                 assertFalse(map.get("serviceInstanceId").isEmpty())
160                 verify(mex).setVariable("requestAction", "ra")
161                 verify(mex).setVariable("source", "VID")
162                 verify(mex).setVariable("globalSubscriberId", CUST)
163                 verify(mex).setVariable("globalCustomerId", CUST)
164                 verify(mex).setVariable("subscriptionServiceType", SVC)
165                 verify(mex).setVariable("disableRollback", "false")
166                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
167                 assertTrue(map.containsKey("subscriberInfo"))
168                 
169                 assertEquals("", map.get("brgWanMacAddress"))
170                 assertEquals("", map.get("customerLocation"))
171                 assertEquals("oof", map.get("homingService"))
172                 assertTrue(map.containsKey("serviceInputParams"))
173                 assertTrue(map.containsKey(Prefix+"requestInfo"))
174                 
175                 def reqinfo = map.get(Prefix+"requestInfo")
176                 println reqinfo
177                 assertTrue(reqinfo.indexOf("<request-id>mri</") >= 0)
178                 assertTrue(reqinfo.indexOf("<source>VID</") >= 0)
179         }
180                         
181         @Test
182         // @Ignore  
183         public void preProcessRequest_MissingSubscriberId() {
184                 ExecutionEntity mex = setupMock()
185                 def map = setupMap(mex)
186                 initPreProcess(mex)
187                 
188                 def req = request
189                                         .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"')
190                 
191                 when(mex.getVariable("bpmnRequest")).thenReturn(req)
192                 when(mex.getVariable("serviceInstanceId")).thenReturn(null)
193                 
194                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
195                 
196                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
197         }
198                         
199         @Test
200         // @Ignore  
201         public void preProcessRequest_BpmnError() {
202                 ExecutionEntity mex = setupMock()
203                 initPreProcess(mex)
204                 
205                 when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception"))
206                 
207                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
208                 
209                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
210         }
211                         
212         @Test
213         // @Ignore  
214         public void preProcessRequest_Ex() {
215                 ExecutionEntity mex = setupMock()
216                 initPreProcess(mex)
217                 
218                 when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception"))
219                 
220                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
221                 
222                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
223         }
224         
225         // ***** sendSyncResponse *****
226                         
227         @Test
228         // @Ignore  
229         public void sendSyncResponse() {
230                 ExecutionEntity mex = setupMock()
231                 def map = setupMap(mex)
232                 initSendSyncResponse(mex)
233                 
234                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
235                 CreateVcpeResCustService.sendSyncResponse(mex)
236
237                 verify(mex, times(2)).getVariable(DBGFLAG)
238                 
239                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
240                 
241                 assertEquals("202", map.get(processName+"ResponseCode"))
242                 assertEquals("Success", map.get(processName+"Status"))
243                 
244                 def resp = map.get(processName+"Response")
245                 
246                 assertTrue(resp.indexOf('"instanceId":"sii"') >= 0)
247                 assertTrue(resp.indexOf('"requestId":"mri"') >= 0)
248         }
249                         
250         @Test
251         // @Ignore  
252         public void sendSyncResponse_Ex() {
253                 ExecutionEntity mex = setupMock()
254                 initSendSyncResponse(mex)
255                 
256                 when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception"))
257                 
258                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
259                 
260                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.sendSyncResponse(mex) }))
261         }
262         
263         
264         // ***** prepareDecomposeService *****
265                         
266         @Test
267         // @Ignore  
268         public void prepareDecomposeService() {
269                 ExecutionEntity mex = setupMock()
270                 initPrepareDecomposeService(mex)
271                 
272                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
273                 CreateVcpeResCustService.prepareDecomposeService(mex)
274
275                 verify(mex).getVariable(DBGFLAG)
276                 verify(mex).setVariable("serviceModelInfo", "mi")
277         }
278                         
279         @Test
280         // @Ignore  
281         public void prepareDecomposeService_Ex() {
282                 ExecutionEntity mex = setupMock()
283                 initPrepareDecomposeService(mex)
284                 
285                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
286                 
287                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
288                 
289                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareDecomposeService(mex) }))
290         }
291         
292         
293         // ***** prepareCreateServiceInstance *****
294                         
295         @Test
296         // @Ignore  
297         public void prepareCreateServiceInstance() {
298                 ExecutionEntity mex = setupMock()
299                 initPrepareCreateServiceInstance(mex)
300                 
301                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
302                 CreateVcpeResCustService.prepareCreateServiceInstance(mex)
303
304                 verify(mex).getVariable(DBGFLAG)
305                 verify(mex).setVariable("serviceInstanceName", "VCPE1")
306                 verify(mex).setVariable("serviceDecompositionString", "mydecomp")
307         }
308                         
309         @Test
310         // @Ignore  
311         public void prepareCreateServiceInstance_Ex() {
312                 ExecutionEntity mex = setupMock()
313                 initPrepareCreateServiceInstance(mex)
314                 
315                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
316                 
317                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
318                 
319                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) }))
320         }
321         
322         
323         // ***** postProcessServiceInstanceCreate *****
324                         
325         @Test
326         // @Ignore  
327         public void postProcessServiceInstanceCreate() {
328                 ExecutionEntity mex = setupMock()
329                 def map = setupMap(mex)
330                 initPostProcessServiceInstanceCreate(mex)
331                 
332                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
333                 CreateVcpeResCustService.postProcessServiceInstanceCreate(mex)
334
335                 verify(mex).getVariable(DBGFLAG)
336                 
337                 def reqinfo = map.get(Prefix+"setUpdateDbInstancePayload")
338                 
339                 assertTrue(reqinfo.indexOf("<requestId>mri</") >= 0)
340                 assertTrue(reqinfo.indexOf("<serviceInstanceId>sii</") >= 0)
341                 assertTrue(reqinfo.indexOf("<serviceInstanceName>sin</") >= 0)
342         }
343                         
344         @Test
345         // @Ignore  
346         public void postProcessServiceInstanceCreate_BpmnError() {
347                 ExecutionEntity mex = setupMock()
348                 initPostProcessServiceInstanceCreate(mex)
349                 
350                 doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
351                 
352                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
353                 
354                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
355         }
356                         
357         @Test
358         // @Ignore  
359         public void postProcessServiceInstanceCreate_Ex() {
360                 ExecutionEntity mex = setupMock()
361                 initPostProcessServiceInstanceCreate(mex)
362                 
363                 doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any())
364                 
365                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
366                 
367                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) }))
368         }
369         
370         
371         // ***** processDecomposition *****
372                         
373         @Test
374         // @Ignore  
375         public void processDecomposition() {
376                 ExecutionEntity mex = setupMock()
377                 def svcdecomp = initProcessDecomposition(mex)
378                 
379                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
380                 CreateVcpeResCustService.processDecomposition(mex)
381
382                 verify(mex).getVariable(DBGFLAG)
383                 
384                 verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
385                 verify(mex).setVariable("vnfListString", '[myvnf]')
386                 verify(mex).setVariable(Prefix+"VNFsCount", 1)
387                 
388                 verify(mex).setVariable("vnfModelInfo", "mymodel")
389                 verify(mex).setVariable("vnfModelInfoString", "mymodel")
390         }
391                         
392         @Test
393         // @Ignore  
394         public void processDecomposition_EmptyNet_EmptyVnf() {
395                 ExecutionEntity mex = setupMock()
396                 def svcdecomp = initProcessDecomposition(mex)
397                 
398                 when(svcdecomp.getVnfResources()).thenReturn(new LinkedList<VnfResource>())
399                 
400                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
401                 CreateVcpeResCustService.processDecomposition(mex)
402
403                 verify(mex).getVariable(DBGFLAG)
404                 
405                 verify(mex).setVariable("vnfList", svcdecomp.getVnfResources())
406                 verify(mex).setVariable("vnfListString", '[]')
407                 verify(mex).setVariable(Prefix+"VNFsCount", 0)
408                 
409                 verify(mex).setVariable("vnfModelInfo", "")
410                 verify(mex).setVariable("vnfModelInfoString", "")
411         }
412                         
413         @Test
414         // @Ignore  
415         public void processDecomposition_Ex() {
416                 ExecutionEntity mex = setupMock()
417                 def svcdecomp = initProcessDecomposition(mex)
418                 
419                 when(svcdecomp.getVnfResources()).thenThrow(new RuntimeException("expected exception"))
420                 
421                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
422                 
423                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processDecomposition(mex) }))
424         }
425         
426         
427         // ***** filterVnfs *****
428                         
429         @Test
430         // @Ignore  
431         public void filterVnfs() {
432                 ExecutionEntity mex = setupMock()
433                 def svcdecomp = initFilterVnfs(mex)
434                 
435                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
436                 CreateVcpeResCustService.processDecomposition(mex)
437                 
438                 verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]')
439         }
440                         
441         @Test
442         // @Ignore  
443         public void filterVnfs_Null() {
444                 ExecutionEntity mex = setupMock()
445                 def svcdecomp = initFilterVnfs(mex)
446                 
447                 when(svcdecomp.getVnfResources()).thenReturn(null)
448                 
449                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
450                 CreateVcpeResCustService.processDecomposition(mex)
451                 
452                 // nothing more to check, as long as it didn't throw an exception
453         }
454         
455         
456         // ***** prepareCreateAllottedResourceTXC *****
457                         
458         @Test
459         // @Ignore  
460         public void prepareCreateAllottedResourceTXC() {
461                 ExecutionEntity mex = setupMock()
462                 initPrepareCreateAllottedResourceTXC(mex)
463                 
464                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
465                 CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
466
467                 verify(mex).getVariable(DBGFLAG)
468                 
469                 verify(mex).setVariable("createTXCAR", true)
470                 verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB")
471                 verify(mex).setVariable("allottedResourceRoleTXC", "TXCr")
472                 verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
473                 verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB")
474         }
475                         
476         @Test
477         // @Ignore  
478         public void prepareCreateAllottedResourceTXC_NullArList() {
479                 ExecutionEntity mex = setupMock()
480                 def svcdecomp = initPrepareCreateAllottedResourceTXC(mex)
481                 
482                 when(svcdecomp.getAllottedResources()).thenReturn(null)
483                 
484                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
485                 CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
486
487                 verify(mex).getVariable(DBGFLAG)
488                 
489                 verify(mex, never()).setVariable("createTXCAR", true)
490                 verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB")
491                 verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr")
492                 verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn")
493                 verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB")
494         }
495                         
496         @Test
497         // @Ignore  
498         public void prepareCreateAllottedResourceTXC_Ex() {
499                 ExecutionEntity mex = setupMock()
500                 initPrepareCreateAllottedResourceTXC(mex)
501                 
502                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
503                 
504                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
505                 
506                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) }))
507         }
508         
509         
510         // ***** prepareCreateAllottedResourceBRG *****
511                         
512         @Test
513         // @Ignore  
514         public void prepareCreateAllottedResourceBRG() {
515                 ExecutionEntity mex = setupMock()
516                 initPrepareCreateAllottedResourceBRG(mex)
517                 
518                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
519                 CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
520
521                 verify(mex).getVariable(DBGFLAG)
522                 
523                 verify(mex).setVariable("createBRGAR", true)
524                 verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB")
525                 verify(mex).setVariable("allottedResourceRoleBRG", "BRGr")
526                 verify(mex).setVariable("allottedResourceTypeBRG", "BRG")
527                 verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB")
528         }
529                         
530         @Test
531         // @Ignore  
532         public void prepareCreateAllottedResourceBRG_NullArList() {
533                 ExecutionEntity mex = setupMock()
534                 def svcdecomp = initPrepareCreateAllottedResourceBRG(mex)
535                 
536                 when(svcdecomp.getAllottedResources()).thenReturn(null)
537                 
538                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
539                 CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
540
541                 verify(mex).getVariable(DBGFLAG)
542                 
543                 verify(mex, never()).setVariable("createBRGAR", true)
544                 verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB")
545                 verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr")
546                 verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG")
547                 verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB")
548         }
549                         
550         @Test
551         // @Ignore  
552         public void prepareCreateAllottedResourceBRG_Ex() {
553                 ExecutionEntity mex = setupMock()
554                 initPrepareCreateAllottedResourceBRG(mex)
555                 
556                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
557                 
558                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
559                 
560                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) }))
561         }
562         
563         
564         // ***** prepareVnfAndModulesCreate *****
565                         
566         @Test
567         // @Ignore  
568         public void prepareVnfAndModulesCreate() {
569                 ExecutionEntity mex = setupMock()
570                 initPrepareVnfAndModulesCreate(mex)
571                 
572                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
573                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
574
575                 verify(mex).getVariable(DBGFLAG)
576                 
577                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
578                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
579                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
580         }
581                         
582         @Test
583         // @Ignore  
584         public void prepareVnfAndModulesCreate_EmptyList() {
585                 ExecutionEntity mex = setupMock()
586                 initPrepareVnfAndModulesCreate(mex)
587                 
588                 when(mex.getVariable("vnfList")).thenReturn(new LinkedList<VnfResource>())
589                 
590                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
591                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
592
593                 verify(mex).getVariable(DBGFLAG)
594                 
595                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
596                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
597                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
598         }
599                         
600         @Test
601         // @Ignore  
602         public void prepareVnfAndModulesCreate_NullList() {
603                 ExecutionEntity mex = setupMock()
604                 initPrepareVnfAndModulesCreate(mex)
605                 
606                 when(mex.getVariable("vnfList")).thenReturn(null)
607                 
608                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
609                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
610
611                 verify(mex).getVariable(DBGFLAG)
612                 
613                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
614                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
615                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
616         }
617                         
618         @Test
619         // @Ignore  
620         public void prepareVnfAndModulesCreate_Ex() {
621                 ExecutionEntity mex = setupMock()
622                 initPrepareVnfAndModulesCreate(mex)
623                 
624                 when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception"))
625                 
626                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
627                 
628                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) }))
629         }
630         
631         
632         // ***** validateVnfCreate *****
633                         
634         @Test
635         // @Ignore  
636         public void validateVnfCreate() {
637                 ExecutionEntity mex = setupMock()
638                 initValidateVnfCreate(mex)
639                 
640                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
641                 CreateVcpeResCustService.validateVnfCreate(mex)
642
643                 verify(mex).getVariable(DBGFLAG)
644                 
645                 verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3)
646         }
647                         
648         @Test
649         // @Ignore  
650         public void validateVnfCreate_Ex() {
651                 ExecutionEntity mex = setupMock()
652                 initValidateVnfCreate(mex)
653                 
654                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception"))
655                 
656                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
657                 
658                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) }))
659         }
660         
661         
662         // ***** postProcessResponse *****
663                         
664         @Test
665         // @Ignore  
666         public void postProcessResponse() {
667                 ExecutionEntity mex = setupMock()
668                 def map = setupMap(mex)
669                 initPostProcessResponse(mex)
670                 
671                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
672                 CreateVcpeResCustService.postProcessResponse(mex)
673
674                 verify(mex).getVariable(DBGFLAG)
675                 
676                 verify(mex).setVariable(Prefix+"Success", true)
677                 
678                 def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest")
679                 
680                 assertTrue(reqinfo.indexOf("request-id>mri</") >= 0)
681                 assertTrue(reqinfo.indexOf("source>mysrc</") >= 0)
682                 assertTrue(reqinfo.indexOf("serviceInstanceId>sii</") >= 0)
683         }
684                         
685         @Test
686         // @Ignore  
687         public void postProcessResponse_BpmnError() {
688                 ExecutionEntity mex = setupMock()
689                 def map = setupMap(mex)
690                 initPostProcessResponse(mex)
691                 
692                 when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
693                 
694                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
695                 
696                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
697         }
698                         
699         @Test
700         // @Ignore  
701         public void postProcessResponse_Ex() {
702                 ExecutionEntity mex = setupMock()
703                 def map = setupMap(mex)
704                 initPostProcessResponse(mex)
705                 
706                 when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception"))
707                 
708                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
709                 
710                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
711         }
712         
713         
714         // ***** preProcessRollback *****
715                         
716         @Test
717         // @Ignore  
718         public void preProcessRollback() {
719                 ExecutionEntity mex = setupMock()
720                 def wfe = initPreProcessRollback(mex)
721                 
722                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
723                 CreateVcpeResCustService.preProcessRollback(mex)
724
725                 verify(mex).getVariable(DBGFLAG)
726                 
727                 verify(mex).setVariable("prevWorkflowException", wfe)
728         }
729                         
730         @Test
731         // @Ignore  
732         public void preProcessRollback_NullWfe() {
733                 ExecutionEntity mex = setupMock()
734                 def map = setupMap(mex)
735                 def wfe = initPreProcessRollback(mex)
736                 
737                 when(mex.getVariable("WorkflowException")).thenReturn(null)
738                 
739                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
740                 CreateVcpeResCustService.preProcessRollback(mex)
741
742                 verify(mex).getVariable(DBGFLAG)
743                 
744                 assertFalse(map.containsKey("prevWorkflowException"))
745         }
746                         
747         @Test
748         // @Ignore  
749         public void preProcessRollback_BpmnError() {
750                 ExecutionEntity mex = setupMock()
751                 def map = setupMap(mex)
752                 def wfe = initPreProcessRollback(mex)
753                 
754                 when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
755                 
756                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
757                 CreateVcpeResCustService.preProcessRollback(mex)
758
759                 verify(mex).getVariable(DBGFLAG)
760                 
761                 assertFalse(map.containsKey("prevWorkflowException"))
762         }
763                         
764         @Test
765         // @Ignore  
766         public void preProcessRollback_Ex() {
767                 ExecutionEntity mex = setupMock()
768                 def map = setupMap(mex)
769                 def wfe = initPreProcessRollback(mex)
770                 
771                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
772                 
773                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
774                 CreateVcpeResCustService.preProcessRollback(mex)
775
776                 verify(mex).getVariable(DBGFLAG)
777                 
778                 assertFalse(map.containsKey("prevWorkflowException"))
779         }
780         
781         
782         // ***** postProcessRollback *****
783                         
784         @Test
785         // @Ignore  
786         public void postProcessRollback() {
787                 ExecutionEntity mex = setupMock()
788                 def wfe = initPostProcessRollback(mex)
789                 
790                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
791                 CreateVcpeResCustService.postProcessRollback(mex)
792
793                 verify(mex).getVariable(DBGFLAG)
794                 
795                 verify(mex).setVariable("WorkflowException", wfe)
796         }
797                         
798         @Test
799         // @Ignore  
800         public void postProcessRollback_NullWfe() {
801                 ExecutionEntity mex = setupMock()
802                 def map = setupMap(mex)
803                 def wfe = initPostProcessRollback(mex)
804                 
805                 when(mex.getVariable("prevWorkflowException")).thenReturn(null)
806                 
807                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
808                 CreateVcpeResCustService.postProcessRollback(mex)
809
810                 verify(mex).getVariable(DBGFLAG)
811                 
812                 assertFalse(map.containsKey("WorkflowException"))
813         }
814                         
815         @Test
816         // @Ignore  
817         public void postProcessRollback_BpmnError() {
818                 ExecutionEntity mex = setupMock()
819                 def map = setupMap(mex)
820                 def wfe = initPostProcessRollback(mex)
821                 
822                 when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
823                 
824                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
825                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) }))
826         }
827                         
828         @Test
829         // @Ignore  
830         public void postProcessRollback_Ex() {
831                 ExecutionEntity mex = setupMock()
832                 def map = setupMap(mex)
833                 def wfe = initPostProcessRollback(mex)
834                 
835                 when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
836                 
837                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
838                 CreateVcpeResCustService.postProcessRollback(mex)
839
840                 verify(mex).getVariable(DBGFLAG)
841                 
842                 assertFalse(map.containsKey("WorkflowException"))
843         }
844         
845         
846         // ***** prepareFalloutRequest *****
847                         
848         @Test
849         // @Ignore  
850         public void prepareFalloutRequest() {
851                 ExecutionEntity mex = setupMock()
852                 def map = setupMap(mex)
853                 initPrepareFalloutRequest(mex)
854                 
855                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
856                 CreateVcpeResCustService.prepareFalloutRequest(mex)
857
858                 verify(mex, times(2)).getVariable(DBGFLAG)
859                 
860                 def fo = map.get(Prefix+"falloutRequest")
861                 
862                 assertTrue(fo.indexOf("<hello>world</") >= 0)
863                 assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
864                 assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
865         }
866                         
867         @Test
868         // @Ignore  
869         public void prepareFalloutRequest_Ex() {
870                 ExecutionEntity mex = setupMock()
871                 def map = setupMap(mex)
872                 initPrepareFalloutRequest(mex)
873                 
874                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
875                 
876                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
877                 
878                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) }))
879         }
880         
881         // ***** sendSyncError *****
882                         
883         @Test
884         // @Ignore  
885         public void sendSyncError() {
886                 ExecutionEntity mex = setupMock()
887                 def map = setupMap(mex)
888                 initSendSyncError(mex)
889                 
890                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
891                 CreateVcpeResCustService.sendSyncError(mex)
892
893                 verify(mex, times(2)).getVariable(DBGFLAG)
894                 
895                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
896                 
897                 assertEquals("500", map.get(processName+"ResponseCode"))
898                 assertEquals("Fail", map.get(processName+"Status"))
899                 
900                 def resp = map.get(processName+"Response")
901                 
902                 assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
903                 
904                 verify(mex).setVariable("WorkflowResponse", resp)
905         }
906                         
907         @Test
908         // @Ignore  
909         public void sendSyncError_NotWfe() {
910                 ExecutionEntity mex = setupMock()
911                 def map = setupMap(mex)
912                 initSendSyncError(mex)
913                 
914                 when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
915                 
916                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
917                 CreateVcpeResCustService.sendSyncError(mex)
918
919                 verify(mex, times(2)).getVariable(DBGFLAG)
920                 
921                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
922                 
923                 assertEquals("500", map.get(processName+"ResponseCode"))
924                 assertEquals("Fail", map.get(processName+"Status"))
925                 
926                 def resp = map.get(processName+"Response")
927                 
928                 assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
929                 
930                 verify(mex).setVariable("WorkflowResponse", resp)
931         }
932                         
933         @Test
934         // @Ignore  
935         public void sendSyncError_NullWfe() {
936                 ExecutionEntity mex = setupMock()
937                 def map = setupMap(mex)
938                 initSendSyncError(mex)
939                 
940                 when(mex.getVariable("WorkflowException")).thenReturn(null)
941                 
942                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
943                 CreateVcpeResCustService.sendSyncError(mex)
944
945                 verify(mex, times(2)).getVariable(DBGFLAG)
946                 
947                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
948                 
949                 assertEquals("500", map.get(processName+"ResponseCode"))
950                 assertEquals("Fail", map.get(processName+"Status"))
951                 
952                 def resp = map.get(processName+"Response")
953                 
954                 assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
955                 
956                 verify(mex).setVariable("WorkflowResponse", resp)
957         }
958                         
959         @Test
960         // @Ignore  
961         public void sendSyncError_Ex() {
962                 ExecutionEntity mex = setupMock()
963                 def map = setupMap(mex)
964                 initSendSyncError(mex)
965                 
966                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
967                 
968                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
969                 
970                 CreateVcpeResCustService.sendSyncError(mex)
971                 
972                 assertFalse(map.containsKey(processName+"ResponseCode"))
973         }
974         
975         
976         // ***** processJavaException *****
977                         
978         @Test
979         // @Ignore  
980         public void processJavaException() {
981                 ExecutionEntity mex = setupMock()
982                 def map = setupMap(mex)
983                 initProcessJavaException(mex)
984                 
985                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
986                 
987                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
988
989                 verify(mex, times(2)).getVariable(DBGFLAG)
990                 
991                 verify(mex).setVariable("prefix", Prefix)
992                 
993                 def wfe = map.get("WorkflowException")
994                 
995                 assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
996         }
997                         
998         @Test
999         // @Ignore  
1000         public void processJavaException_BpmnError() {
1001                 ExecutionEntity mex = setupMock()
1002                 def map = setupMap(mex)
1003                 initProcessJavaException(mex)
1004                 
1005                 when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
1006                 
1007                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
1008                 
1009                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
1010                 
1011                 assertFalse(map.containsKey("WorkflowException"))
1012         }
1013                         
1014         @Test
1015         // @Ignore  
1016         public void processJavaException_Ex() {
1017                 ExecutionEntity mex = setupMock()
1018                 def map = setupMap(mex)
1019                 initProcessJavaException(mex)
1020                 
1021                 when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
1022                 
1023                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
1024                 
1025                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
1026                 
1027                 def wfe = map.get("WorkflowException")
1028                 
1029                 assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
1030         }
1031         
1032         
1033         private void initPreProcess(ExecutionEntity mex) {
1034                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1035                 when(mex.getVariable("bpmnRequest")).thenReturn(request)
1036                 when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn("aaidelay")
1037                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1038                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1039                 when(mex.getVariable("requestAction")).thenReturn("ra")
1040         }
1041         
1042         private initSendSyncResponse(ExecutionEntity mex) {
1043                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1044                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1045                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1046         }
1047         
1048         private void initPrepareDecomposeService(ExecutionEntity mex) {
1049                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1050                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}')
1051         }
1052         
1053         private void initPrepareCreateServiceInstance(ExecutionEntity mex) {
1054                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1055                 
1056                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1057                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1058                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1059                 
1060                 when(svcdecomp.toJsonStringNoRootName()).thenReturn("mydecomp")
1061         }
1062         
1063         private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) {
1064                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1065                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1066                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1067                 when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
1068         }
1069         
1070         private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) {
1071                 List<VnfResource> vnflst = new LinkedList<>()
1072                 vnflst.add(makeVnf("", ""))
1073                 vnflst.add(makeVnf("2", "BRG"))
1074                 vnflst.add(makeVnf("3", "BRG"))
1075                         
1076                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1077                 when(svcdecomp.getVnfResources()).thenReturn(vnflst)
1078                 
1079                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1080                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1081                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1082                 when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
1083                 
1084                 return svcdecomp
1085         }
1086         
1087         private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) {
1088                 List<VnfResource> vnflst = new LinkedList<>()
1089                 vnflst.add(makeVnf("", "BRG"))
1090                 vnflst.add(makeVnf("2", "Tunnel XConn"))
1091                 vnflst.add(makeVnf("3", ""))
1092                 vnflst.add(makeVnf("4", "BRG"))
1093                 vnflst.add(makeVnf("5", "other"))
1094                         
1095                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1096                 when(svcdecomp.getVnfResources()).thenReturn(vnflst)
1097                 
1098                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1099                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1100                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1101                 when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
1102                 
1103                 return svcdecomp
1104         }
1105         
1106         private initAwaitAaiDistribution(ExecutionEntity mex) {
1107                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1108         }
1109         
1110         private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) {
1111                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1112                 List<AllottedResource> arlst = new LinkedList<>()
1113                 
1114                 arlst.add(makeArBRG("A"))
1115                 arlst.add(makeArTXC("B"))
1116                 arlst.add(makeArBRG("C"))
1117                 
1118                 when(svcdecomp.getAllottedResources()).thenReturn(arlst)
1119                 
1120                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1121                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1122                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1123                 when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
1124                 
1125                 return svcdecomp
1126         }
1127         
1128         private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) {
1129                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1130                 List<AllottedResource> arlst = new LinkedList<>()
1131                 
1132                 arlst.add(makeArTXC("A"))
1133                 arlst.add(makeArBRG("B"))
1134                 arlst.add(makeArTXC("C"))
1135                 
1136                 when(svcdecomp.getAllottedResources()).thenReturn(arlst)
1137                 
1138                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1139                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1140                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1141                 when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
1142                 
1143                 return svcdecomp
1144         }
1145         
1146         private AllottedResource makeArTXC(String id) {
1147                 AllottedResource ar = mock(AllottedResource.class)
1148                 ModelInfo mod = mock(ModelInfo.class)
1149                 HomingSolution home = mock(HomingSolution.class)
1150                 
1151                 when(ar.toJsonStringNoRootName()).thenReturn("json"+id)
1152                 when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn")
1153                 when(ar.getModelInfo()).thenReturn(mod)
1154                 when(ar.getAllottedResourceRole()).thenReturn("TXCr")
1155                 when(ar.getHomingSolution()).thenReturn(home)
1156                 
1157                 when(mod.toJsonStringNoRootName()).thenReturn("model"+id)
1158                 
1159                 when(home.getServiceInstanceId()).thenReturn("home"+id)
1160                 
1161                 return ar
1162         }
1163         
1164         private AllottedResource makeArBRG(String id) {
1165                 AllottedResource ar = mock(AllottedResource.class)
1166                 ModelInfo mod = mock(ModelInfo.class)
1167                 HomingSolution home = mock(HomingSolution.class)
1168                 
1169                 when(ar.toJsonStringNoRootName()).thenReturn("json"+id)
1170                 when(ar.getAllottedResourceType()).thenReturn("BRG")
1171                 when(ar.getModelInfo()).thenReturn(mod)
1172                 when(ar.getAllottedResourceRole()).thenReturn("BRGr")
1173                 when(ar.getHomingSolution()).thenReturn(home)
1174                 
1175                 when(mod.toJsonStringNoRootName()).thenReturn("model"+id)
1176                 
1177                 when(home.getServiceInstanceId()).thenReturn("home"+id)
1178                 
1179                 return ar
1180         }
1181         
1182         private initPrepareVnfAndModulesCreate(ExecutionEntity mex) {
1183                 
1184                 List<VnfResource> vnflst = new LinkedList<>()
1185                 
1186                 vnflst.add(makeVnf("A", "BRG"))
1187                 vnflst.add(makeVnf("B", ""))
1188                 vnflst.add(makeVnf("C", ""))
1189                 vnflst.add(makeVnf("D", "Tunnel XConn"))
1190                 
1191                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1192                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1193                 when(mex.getVariable("vnfList")).thenReturn(vnflst)
1194                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
1195                 when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel")
1196                 when(mex.getVariable("sdncVersion")).thenReturn("myvers")
1197         }
1198         
1199         private VnfResource makeVnf(String id, String role) {           
1200                 ModelInfo mod = mock(ModelInfo.class)           
1201                 VnfResource vnf = mock(VnfResource.class)
1202                 
1203                 when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}')
1204                 
1205                 when(vnf.toString()).thenReturn("myvnf"+id)
1206                 when(vnf.getModelInfo()).thenReturn(mod)
1207                 when(vnf.getNfRole()).thenReturn(role)
1208
1209                 return vnf
1210         }
1211         
1212         private initValidateVnfCreate(ExecutionEntity mex) {
1213                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1214                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
1215         }
1216         
1217         private initPostProcessResponse(ExecutionEntity mex) {
1218                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1219                 when(mex.getVariable("source")).thenReturn("mysrc")
1220                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1221                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1222         }
1223         
1224         private WorkflowException initPreProcessRollback(ExecutionEntity mex) {
1225                 WorkflowException wfe = mock(WorkflowException.class)
1226                 
1227                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1228                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1229                 
1230                 return wfe
1231         }
1232         
1233         private WorkflowException initPostProcessRollback(ExecutionEntity mex) {
1234                 WorkflowException wfe = mock(WorkflowException.class)
1235                 
1236                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1237                 when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
1238                 
1239                 return wfe
1240         }
1241         
1242         private initPrepareFalloutRequest(ExecutionEntity mex) {
1243                 WorkflowException wfe = mock(WorkflowException.class)
1244                 
1245                 when(wfe.getErrorMessage()).thenReturn("mymsg")
1246                 when(wfe.getErrorCode()).thenReturn(999)
1247                 
1248                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1249                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1250                 when(mex.getVariable(Prefix+"requestInfo")).thenReturn("<hello>world</hello>")
1251                 
1252                 return wfe
1253         }
1254         
1255         private initSendSyncError(ExecutionEntity mex) {
1256                 WorkflowException wfe = mock(WorkflowException.class)
1257                 
1258                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1259                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1260                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1261                 
1262                 when(wfe.getErrorMessage()).thenReturn("mymsg")
1263         }
1264         
1265         private initProcessJavaException(ExecutionEntity mex) {
1266                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1267         }
1268                 
1269 }