c5eff7308401f5f00ae82d0400e719a7934095a1
[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         // ***** prepareCreateAllottedResourceTXC *****
409                         
410         @Test
411 //      @Ignore  
412         public void prepareCreateAllottedResourceTXC() {
413                 ExecutionEntity mex = setupMock()
414                 initPrepareCreateAllottedResourceTXC(mex)
415                 
416                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
417                 CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
418
419                 verify(mex).getVariable(DBGFLAG)
420                 
421                 verify(mex).setVariable("createTXCAR", true)
422                 verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB")
423                 verify(mex).setVariable("allottedResourceRoleTXC", "TXCr")
424                 verify(mex).setVariable("allottedResourceTypeTXC", "TunnelXConn")
425                 verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB")
426         }
427                         
428         @Test
429 //      @Ignore  
430         public void prepareCreateAllottedResourceTXC_NullArList() {
431                 ExecutionEntity mex = setupMock()
432                 def svcdecomp = initPrepareCreateAllottedResourceTXC(mex)
433                 
434                 when(svcdecomp.getServiceAllottedResources()).thenReturn(null)
435                 
436                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
437                 CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex)
438
439                 verify(mex).getVariable(DBGFLAG)
440                 
441                 verify(mex, never()).setVariable("createTXCAR", true)
442                 verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB")
443                 verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr")
444                 verify(mex, never()).setVariable("allottedResourceTypeTXC", "TunnelXConn")
445                 verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB")
446         }
447                         
448         @Test
449 //      @Ignore  
450         public void prepareCreateAllottedResourceTXC_Ex() {
451                 ExecutionEntity mex = setupMock()
452                 initPrepareCreateAllottedResourceTXC(mex)
453                 
454                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
455                 
456                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
457                 
458                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) }))
459         }
460         
461         
462         // ***** prepareCreateAllottedResourceBRG *****
463                         
464         @Test
465 //      @Ignore  
466         public void prepareCreateAllottedResourceBRG() {
467                 ExecutionEntity mex = setupMock()
468                 initPrepareCreateAllottedResourceBRG(mex)
469                 
470                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
471                 CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
472
473                 verify(mex).getVariable(DBGFLAG)
474                 
475                 verify(mex).setVariable("createBRGAR", true)
476                 verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB")
477                 verify(mex).setVariable("allottedResourceRoleBRG", "BRGr")
478                 verify(mex).setVariable("allottedResourceTypeBRG", "BRG")
479                 verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB")
480         }
481                         
482         @Test
483 //      @Ignore  
484         public void prepareCreateAllottedResourceBRG_NullArList() {
485                 ExecutionEntity mex = setupMock()
486                 def svcdecomp = initPrepareCreateAllottedResourceBRG(mex)
487                 
488                 when(svcdecomp.getServiceAllottedResources()).thenReturn(null)
489                 
490                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
491                 CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex)
492
493                 verify(mex).getVariable(DBGFLAG)
494                 
495                 verify(mex, never()).setVariable("createBRGAR", true)
496                 verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB")
497                 verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr")
498                 verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG")
499                 verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB")
500         }
501                         
502         @Test
503 //      @Ignore  
504         public void prepareCreateAllottedResourceBRG_Ex() {
505                 ExecutionEntity mex = setupMock()
506                 initPrepareCreateAllottedResourceBRG(mex)
507                 
508                 when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception"))
509                 
510                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
511                 
512                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) }))
513         }
514         
515         
516         // ***** prepareVnfAndModulesCreate *****
517                         
518         @Test
519 //      @Ignore  
520         public void prepareVnfAndModulesCreate() {
521                 ExecutionEntity mex = setupMock()
522                 initPrepareVnfAndModulesCreate(mex)
523                 
524                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
525                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
526
527                 verify(mex).getVariable(DBGFLAG)
528                 
529                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
530                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
531                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
532         }
533                         
534         @Test
535 //      @Ignore  
536         public void prepareVnfAndModulesCreate_EmptyList() {
537                 ExecutionEntity mex = setupMock()
538                 initPrepareVnfAndModulesCreate(mex)
539                 
540                 when(mex.getVariable("vnfList")).thenReturn(new LinkedList<VnfResource>())
541                 
542                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
543                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
544
545                 verify(mex).getVariable(DBGFLAG)
546                 
547                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
548                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
549                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
550         }
551                         
552         @Test
553 //      @Ignore  
554         public void prepareVnfAndModulesCreate_NullList() {
555                 ExecutionEntity mex = setupMock()
556                 initPrepareVnfAndModulesCreate(mex)
557                 
558                 when(mex.getVariable("vnfList")).thenReturn(null)
559                 
560                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
561                 CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
562
563                 verify(mex).getVariable(DBGFLAG)
564                 
565                 verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
566                 verify(mex).setVariable("lcpCloudRegionId", "mdt1")
567                 verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
568         }
569                         
570         @Test
571 //      @Ignore  
572         public void prepareVnfAndModulesCreate_Ex() {
573                 ExecutionEntity mex = setupMock()
574                 initPrepareVnfAndModulesCreate(mex)
575                 
576                 when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception"))
577                 
578                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
579                 
580                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) }))
581         }
582         
583         
584         // ***** validateVnfCreate *****
585                         
586         @Test
587 //      @Ignore  
588         public void validateVnfCreate() {
589                 ExecutionEntity mex = setupMock()
590                 initValidateVnfCreate(mex)
591                 
592                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
593                 CreateVcpeResCustService.validateVnfCreate(mex)
594
595                 verify(mex).getVariable(DBGFLAG)
596                 
597                 verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3)
598         }
599                         
600         @Test
601 //      @Ignore  
602         public void validateVnfCreate_Ex() {
603                 ExecutionEntity mex = setupMock()
604                 initValidateVnfCreate(mex)
605                 
606                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception"))
607                 
608                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
609                 
610                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) }))
611         }
612         
613         
614         // ***** postProcessResponse *****
615                         
616         @Test
617 //      @Ignore  
618         public void postProcessResponse() {
619                 ExecutionEntity mex = setupMock()
620                 def map = setupMap(mex)
621                 initPostProcessResponse(mex)
622                 
623                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
624                 CreateVcpeResCustService.postProcessResponse(mex)
625
626                 verify(mex).getVariable(DBGFLAG)
627                 
628                 verify(mex).setVariable(Prefix+"Success", true)
629                 
630                 def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest")
631                 
632                 assertTrue(reqinfo.indexOf("request-id>mri</") >= 0)
633                 assertTrue(reqinfo.indexOf("source>mysrc</") >= 0)
634                 assertTrue(reqinfo.indexOf("serviceInstanceId>sii</") >= 0)
635         }
636                         
637         @Test
638 //      @Ignore  
639         public void postProcessResponse_BpmnError() {
640                 ExecutionEntity mex = setupMock()
641                 def map = setupMap(mex)
642                 initPostProcessResponse(mex)
643                 
644                 when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception"))
645                 
646                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
647                 
648                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
649         }
650                         
651         @Test
652 //      @Ignore  
653         public void postProcessResponse_Ex() {
654                 ExecutionEntity mex = setupMock()
655                 def map = setupMap(mex)
656                 initPostProcessResponse(mex)
657                 
658                 when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception"))
659                 
660                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
661                 
662                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) }))
663         }
664         
665         
666         // ***** preProcessRollback *****
667                         
668         @Test
669 //      @Ignore  
670         public void preProcessRollback() {
671                 ExecutionEntity mex = setupMock()
672                 def wfe = initPreProcessRollback(mex)
673                 
674                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
675                 CreateVcpeResCustService.preProcessRollback(mex)
676
677                 verify(mex).getVariable(DBGFLAG)
678                 
679                 verify(mex).setVariable("prevWorkflowException", wfe)
680         }
681                         
682         @Test
683 //      @Ignore  
684         public void preProcessRollback_NullWfe() {
685                 ExecutionEntity mex = setupMock()
686                 def map = setupMap(mex)
687                 def wfe = initPreProcessRollback(mex)
688                 
689                 when(mex.getVariable("WorkflowException")).thenReturn(null)
690                 
691                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
692                 CreateVcpeResCustService.preProcessRollback(mex)
693
694                 verify(mex).getVariable(DBGFLAG)
695                 
696                 assertFalse(map.containsKey("prevWorkflowException"))
697         }
698                         
699         @Test
700 //      @Ignore  
701         public void preProcessRollback_BpmnError() {
702                 ExecutionEntity mex = setupMock()
703                 def map = setupMap(mex)
704                 def wfe = initPreProcessRollback(mex)
705                 
706                 when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
707                 
708                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
709                 CreateVcpeResCustService.preProcessRollback(mex)
710
711                 verify(mex).getVariable(DBGFLAG)
712                 
713                 assertFalse(map.containsKey("prevWorkflowException"))
714         }
715                         
716         @Test
717 //      @Ignore  
718         public void preProcessRollback_Ex() {
719                 ExecutionEntity mex = setupMock()
720                 def map = setupMap(mex)
721                 def wfe = initPreProcessRollback(mex)
722                 
723                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
724                 
725                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
726                 CreateVcpeResCustService.preProcessRollback(mex)
727
728                 verify(mex).getVariable(DBGFLAG)
729                 
730                 assertFalse(map.containsKey("prevWorkflowException"))
731         }
732         
733         
734         // ***** postProcessRollback *****
735                         
736         @Test
737 //      @Ignore  
738         public void postProcessRollback() {
739                 ExecutionEntity mex = setupMock()
740                 def wfe = initPostProcessRollback(mex)
741                 
742                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
743                 CreateVcpeResCustService.postProcessRollback(mex)
744
745                 verify(mex).getVariable(DBGFLAG)
746                 
747                 verify(mex).setVariable("WorkflowException", wfe)
748         }
749                         
750         @Test
751 //      @Ignore  
752         public void postProcessRollback_NullWfe() {
753                 ExecutionEntity mex = setupMock()
754                 def map = setupMap(mex)
755                 def wfe = initPostProcessRollback(mex)
756                 
757                 when(mex.getVariable("prevWorkflowException")).thenReturn(null)
758                 
759                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
760                 CreateVcpeResCustService.postProcessRollback(mex)
761
762                 verify(mex).getVariable(DBGFLAG)
763                 
764                 assertFalse(map.containsKey("WorkflowException"))
765         }
766                         
767         @Test
768 //      @Ignore  
769         public void postProcessRollback_BpmnError() {
770                 ExecutionEntity mex = setupMock()
771                 def map = setupMap(mex)
772                 def wfe = initPostProcessRollback(mex)
773                 
774                 when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
775                 
776                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
777                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) }))
778         }
779                         
780         @Test
781 //      @Ignore  
782         public void postProcessRollback_Ex() {
783                 ExecutionEntity mex = setupMock()
784                 def map = setupMap(mex)
785                 def wfe = initPostProcessRollback(mex)
786                 
787                 when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
788                 
789                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
790                 CreateVcpeResCustService.postProcessRollback(mex)
791
792                 verify(mex).getVariable(DBGFLAG)
793                 
794                 assertFalse(map.containsKey("WorkflowException"))
795         }
796         
797         
798         // ***** prepareFalloutRequest *****
799                         
800         @Test
801 //      @Ignore  
802         public void prepareFalloutRequest() {
803                 ExecutionEntity mex = setupMock()
804                 def map = setupMap(mex)
805                 initPrepareFalloutRequest(mex)
806                 
807                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
808                 CreateVcpeResCustService.prepareFalloutRequest(mex)
809
810                 verify(mex, times(2)).getVariable(DBGFLAG)
811                 
812                 def fo = map.get(Prefix+"falloutRequest")
813                 
814                 assertTrue(fo.indexOf("<hello>world</") >= 0)
815                 assertTrue(fo.indexOf("ErrorMessage>mymsg</") >= 0)
816                 assertTrue(fo.indexOf("ErrorCode>999</") >= 0)
817         }
818                         
819         @Test
820 //      @Ignore  
821         public void prepareFalloutRequest_Ex() {
822                 ExecutionEntity mex = setupMock()
823                 def map = setupMap(mex)
824                 initPrepareFalloutRequest(mex)
825                 
826                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
827                 
828                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
829                 
830                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) }))
831         }
832         
833         // ***** sendSyncError *****
834                         
835         @Test
836 //      @Ignore  
837         public void sendSyncError() {
838                 ExecutionEntity mex = setupMock()
839                 def map = setupMap(mex)
840                 initSendSyncError(mex)
841                 
842                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
843                 CreateVcpeResCustService.sendSyncError(mex)
844
845                 verify(mex, times(2)).getVariable(DBGFLAG)
846                 
847                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
848                 
849                 assertEquals("500", map.get(processName+"ResponseCode"))
850                 assertEquals("Fail", map.get(processName+"Status"))
851                 
852                 def resp = map.get(processName+"Response")
853                 
854                 assertTrue(resp.indexOf("ErrorMessage>mymsg</") >= 0)
855                 
856                 verify(mex).setVariable("WorkflowResponse", resp)
857         }
858                         
859         @Test
860 //      @Ignore  
861         public void sendSyncError_NotWfe() {
862                 ExecutionEntity mex = setupMock()
863                 def map = setupMap(mex)
864                 initSendSyncError(mex)
865                 
866                 when(mex.getVariable("WorkflowException")).thenReturn("not a WFE")
867                 
868                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
869                 CreateVcpeResCustService.sendSyncError(mex)
870
871                 verify(mex, times(2)).getVariable(DBGFLAG)
872                 
873                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
874                 
875                 assertEquals("500", map.get(processName+"ResponseCode"))
876                 assertEquals("Fail", map.get(processName+"Status"))
877                 
878                 def resp = map.get(processName+"Response")
879                 
880                 assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
881                 
882                 verify(mex).setVariable("WorkflowResponse", resp)
883         }
884                         
885         @Test
886 //      @Ignore  
887         public void sendSyncError_NullWfe() {
888                 ExecutionEntity mex = setupMock()
889                 def map = setupMap(mex)
890                 initSendSyncError(mex)
891                 
892                 when(mex.getVariable("WorkflowException")).thenReturn(null)
893                 
894                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
895                 CreateVcpeResCustService.sendSyncError(mex)
896
897                 verify(mex, times(2)).getVariable(DBGFLAG)
898                 
899                 verify(mex).setVariable(processName+"WorkflowResponseSent", "true")
900                 
901                 assertEquals("500", map.get(processName+"ResponseCode"))
902                 assertEquals("Fail", map.get(processName+"Status"))
903                 
904                 def resp = map.get(processName+"Response")
905                 
906                 assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.</") >= 0)
907                 
908                 verify(mex).setVariable("WorkflowResponse", resp)
909         }
910                         
911         @Test
912 //      @Ignore  
913         public void sendSyncError_Ex() {
914                 ExecutionEntity mex = setupMock()
915                 def map = setupMap(mex)
916                 initSendSyncError(mex)
917                 
918                 when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
919                 
920                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
921                 
922                 CreateVcpeResCustService.sendSyncError(mex)
923                 
924                 assertFalse(map.containsKey(processName+"ResponseCode"))
925         }
926         
927         
928         // ***** processJavaException *****
929                         
930         @Test
931 //      @Ignore  
932         public void processJavaException() {
933                 ExecutionEntity mex = setupMock()
934                 def map = setupMap(mex)
935                 initProcessJavaException(mex)
936                 
937                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
938                 
939                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
940
941                 verify(mex, times(2)).getVariable(DBGFLAG)
942                 
943                 verify(mex).setVariable("prefix", Prefix)
944                 
945                 def wfe = map.get("WorkflowException")
946                 
947                 assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage())
948         }
949                         
950         @Test
951 //      @Ignore  
952         public void processJavaException_BpmnError() {
953                 ExecutionEntity mex = setupMock()
954                 def map = setupMap(mex)
955                 initProcessJavaException(mex)
956                 
957                 when(mex.getVariables()).thenThrow(new BpmnError("expected exception"))
958                 
959                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
960                 
961                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
962                 
963                 assertFalse(map.containsKey("WorkflowException"))
964         }
965                         
966         @Test
967 //      @Ignore  
968         public void processJavaException_Ex() {
969                 ExecutionEntity mex = setupMock()
970                 def map = setupMap(mex)
971                 initProcessJavaException(mex)
972                 
973                 when(mex.getVariables()).thenThrow(new RuntimeException("expected exception"))
974                 
975                 CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
976                 
977                 assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) }))
978                 
979                 def wfe = map.get("WorkflowException")
980                 
981                 assertEquals("Exception in processJavaException method", wfe.getErrorMessage())
982         }
983         
984         
985         private void initPreProcess(ExecutionEntity mex) {
986                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
987                 when(mex.getVariable("bpmnRequest")).thenReturn(request)
988                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
989                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
990                 when(mex.getVariable("requestAction")).thenReturn("ra")
991         }
992         
993         private initSendSyncResponse(ExecutionEntity mex) {
994                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
995                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
996                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
997         }
998         
999         private void initPrepareDecomposeService(ExecutionEntity mex) {
1000                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1001                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}')
1002         }
1003         
1004         private void initPrepareCreateServiceInstance(ExecutionEntity mex) {
1005                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1006                 
1007                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1008                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1009                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1010                 
1011                 when(svcdecomp.toJsonString()).thenReturn("mydecomp")
1012         }
1013         
1014         private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) {
1015                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1016                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1017                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1018                 when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
1019         }
1020         
1021         private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex, boolean haveNet, boolean haveVnf) {
1022                 List<VnfResource> vnflst = new LinkedList<>()
1023                 if(haveVnf) {
1024                         vnflst.add(makeVnf(""))
1025                         vnflst.add(makeVnf("2"))
1026                         vnflst.add(makeVnf("3"))
1027                 }
1028                         
1029                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1030                 when(svcdecomp.getServiceVnfs()).thenReturn(vnflst)
1031                 
1032                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1033                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1034                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1035                 when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
1036                 
1037                 return svcdecomp
1038         }
1039         
1040         private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) {
1041                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1042                 List<AllottedResource> arlst = new LinkedList<>()
1043                 
1044                 arlst.add(makeArBRG("A"))
1045                 arlst.add(makeArTXC("B"))
1046                 arlst.add(makeArBRG("C"))
1047                 
1048                 when(svcdecomp.getServiceAllottedResources()).thenReturn(arlst)
1049                 
1050                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1051                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1052                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1053                 when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
1054                 
1055                 return svcdecomp
1056         }
1057         
1058         private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) {
1059                 ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
1060                 List<AllottedResource> arlst = new LinkedList<>()
1061                 
1062                 arlst.add(makeArTXC("A"))
1063                 arlst.add(makeArBRG("B"))
1064                 arlst.add(makeArTXC("C"))
1065                 
1066                 when(svcdecomp.getServiceAllottedResources()).thenReturn(arlst)
1067                 
1068                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1069                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1070                 when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
1071                 when(mex.getVariable("allottedResourceId")).thenReturn(ARID)
1072                 
1073                 return svcdecomp
1074         }
1075         
1076         private AllottedResource makeArTXC(String id) {
1077                 AllottedResource ar = mock(AllottedResource.class)
1078                 ModelInfo mod = mock(ModelInfo.class)
1079                 HomingSolution home = mock(HomingSolution.class)
1080                 
1081                 when(ar.toJsonString()).thenReturn("json"+id)
1082                 when(ar.getAllottedResourceType()).thenReturn("TunnelXConn")
1083                 when(ar.getModelInfo()).thenReturn(mod)
1084                 when(ar.getAllottedResourceRole()).thenReturn("TXCr")
1085                 when(ar.getHomingSolution()).thenReturn(home)
1086                 
1087                 when(mod.toJsonString()).thenReturn("model"+id)
1088                 
1089                 when(home.getServiceInstanceId()).thenReturn("home"+id)
1090                 
1091                 return ar
1092         }
1093         
1094         private AllottedResource makeArBRG(String id) {
1095                 AllottedResource ar = mock(AllottedResource.class)
1096                 ModelInfo mod = mock(ModelInfo.class)
1097                 HomingSolution home = mock(HomingSolution.class)
1098                 
1099                 when(ar.toJsonString()).thenReturn("json"+id)
1100                 when(ar.getAllottedResourceType()).thenReturn("BRG")
1101                 when(ar.getModelInfo()).thenReturn(mod)
1102                 when(ar.getAllottedResourceRole()).thenReturn("BRGr")
1103                 when(ar.getHomingSolution()).thenReturn(home)
1104                 
1105                 when(mod.toJsonString()).thenReturn("model"+id)
1106                 
1107                 when(home.getServiceInstanceId()).thenReturn("home"+id)
1108                 
1109                 return ar
1110         }
1111         
1112         private initPrepareVnfAndModulesCreate(ExecutionEntity mex) {
1113                 
1114                 List<VnfResource> vnflst = new LinkedList<>()
1115                 
1116                 vnflst.add(makeVnf("A"))
1117                 vnflst.add(makeVnf("B"))
1118                 vnflst.add(makeVnf("C"))
1119                 vnflst.add(makeVnf("D"))
1120                 
1121                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1122                 when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
1123                 when(mex.getVariable("vnfList")).thenReturn(vnflst)
1124                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
1125                 when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel")
1126                 when(mex.getVariable("sdncVersion")).thenReturn("myvers")
1127         }
1128         
1129         private VnfResource makeVnf(String id) {                
1130                 ModelInfo mod = mock(ModelInfo.class)           
1131                 VnfResource vnf = mock(VnfResource.class)
1132                 
1133                 when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}')
1134                 
1135                 when(vnf.toString()).thenReturn("myvnf"+id)
1136                 when(vnf.getModelInfo()).thenReturn(mod)
1137
1138                 return vnf              
1139         }
1140         
1141         private initValidateVnfCreate(ExecutionEntity mex) {
1142                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1143                 when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2)
1144         }
1145         
1146         private initPostProcessResponse(ExecutionEntity mex) {
1147                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1148                 when(mex.getVariable("source")).thenReturn("mysrc")
1149                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1150                 when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1151         }
1152         
1153         private WorkflowException initPreProcessRollback(ExecutionEntity mex) {
1154                 WorkflowException wfe = mock(WorkflowException.class)
1155                 
1156                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1157                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1158                 
1159                 return wfe
1160         }
1161         
1162         private WorkflowException initPostProcessRollback(ExecutionEntity mex) {
1163                 WorkflowException wfe = mock(WorkflowException.class)
1164                 
1165                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1166                 when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
1167                 
1168                 return wfe
1169         }
1170         
1171         private initPrepareFalloutRequest(ExecutionEntity mex) {
1172                 WorkflowException wfe = mock(WorkflowException.class)
1173                 
1174                 when(wfe.getErrorMessage()).thenReturn("mymsg")
1175                 when(wfe.getErrorCode()).thenReturn(999)
1176                 
1177                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1178                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1179                 when(mex.getVariable(Prefix+"requestInfo")).thenReturn("<hello>world</hello>")
1180                 
1181                 return wfe
1182         }
1183         
1184         private initSendSyncError(ExecutionEntity mex) {
1185                 WorkflowException wfe = mock(WorkflowException.class)
1186                 
1187                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1188                 when(mex.getVariable("mso-request-id")).thenReturn("mri")
1189                 when(mex.getVariable("WorkflowException")).thenReturn(wfe)
1190                 
1191                 when(wfe.getErrorMessage()).thenReturn("mymsg")
1192         }
1193         
1194         private initProcessJavaException(ExecutionEntity mex) {
1195                 when(mex.getVariable(DBGFLAG)).thenReturn("true")
1196         }\r
1197                 \r
1198 }