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