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