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