f34f84a5fd2a85be10739a2f481be193b0f35ccb
[so.git] /
1 package org.openecomp.mso.bpmn.vcpe.scripts
2 \r
3 \r
4 import org.camunda.bpm.engine.ProcessEngineServices\r
5 import org.camunda.bpm.engine.RepositoryService\r
6 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity\r
7 import org.camunda.bpm.engine.repository.ProcessDefinition\r
8 import org.camunda.bpm.engine.runtime.Execution\r
9 import org.junit.Before
10 import org.junit.BeforeClass\r
11 import org.junit.Rule\r
12 import org.junit.Test
13 import org.junit.Ignore\r
14 import org.mockito.MockitoAnnotations
15 import org.mockito.ArgumentCaptor
16 import org.camunda.bpm.engine.delegate.BpmnError\r
17 import org.openecomp.mso.bpmn.common.scripts.MsoUtils\r
18 import org.openecomp.mso.bpmn.core.WorkflowException
19 import org.openecomp.mso.bpmn.mock.FileUtil
20
21 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
22 import static com.github.tomakehurst.wiremock.client.WireMock.get
23 import static com.github.tomakehurst.wiremock.client.WireMock.patch
24 import static com.github.tomakehurst.wiremock.client.WireMock.put
25 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
26 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
27 import static org.junit.Assert.*;\r
28 import static org.mockito.Mockito.*
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource
30 import org.openecomp.mso.bpmn.core.RollbackData
31
32 import com.github.tomakehurst.wiremock.junit.WireMockRule\r
33 \r
34 class DoCreateAllottedResourceBRGTest  {\r
35         \r
36         @Rule\r
37         public WireMockRule wireMockRule = new WireMockRule(28090)\r
38         
39                 static def urnProps = new Properties()
40                 static def aaiUriPfx
41         \r
42                 String Prefix="DCARBRG_"\r
43                 def utils = new MsoUtils()\r
44
45                 @BeforeClass
46                 public static void setUpBeforeClass() {
47                         def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties")
48                         urnProps.load(fr)
49                         fr.close()
50                         
51                         aaiUriPfx = urnProps.get("aai.endpoint")
52                 }
53                   \r
54             @Before\r
55                 public void init()\r
56                 {\r
57                         MockitoAnnotations.initMocks(this)\r
58                 }
59                 
60                 
61                 // ***** preProcessRequest *****\r
62                                 \r
63                 @Test\r
64 //              @Ignore  \r
65                 public void preProcessRequest() {\r
66                         ExecutionEntity mex = setupMock()
67                         initPreProcess(mex)
68                         \r
69                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()\r
70                         DoCreateAllottedResourceBRG.preProcessRequest(mex)\r
71 \r
72                         verify(mex).getVariable("isDebugLogEnabled")\r
73                         verify(mex).setVariable("prefix", Prefix)\r
74                                         
75                         assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback"))
76                         assertTrue(checkMissingPreProcessRequest("serviceInstanceId"))
77                         assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId"))
78                         assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo"))
79                         assertTrue(checkMissingPreProcessRequest("vni"))
80                         assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP"))
81                         assertTrue(checkMissingPreProcessRequest("brgWanMacAddress"))
82                         assertTrue(checkMissingPreProcessRequest("allottedResourceRole"))
83                         assertTrue(checkMissingPreProcessRequest("allottedResourceType"))\r
84                 }
85                 
86                 
87                 // ***** getAaiAR *****
88                 
89                 @Test
90 //              @Ignore
91                 public void getAaiAR() {
92                         def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")
93                         def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
94                         
95                         wireMockRule
96                                 .stubFor(get(urlMatching("/aai/v[0-9]+/mylink"))
97                                                 .willReturn(aResponse()
98                                                         .withStatus(200)
99                                                         .withHeader("Content-Type", "text/xml")
100                                                         .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")))
101                         
102                         ExecutionEntity mex = setupMock()
103                         
104                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
105                         when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
106                         when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
107                         when(mex.getVariable("CSI_service")).thenReturn(arData)
108                         when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
109                         when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
110                         
111                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
112                         DoCreateAllottedResourceBRG.getAaiAR(mex)
113                         
114                         verify(mex).setVariable("foundActiveAR", true)
115                 }
116                 
117                 @Test
118 //              @Ignore
119                 public void getAaiAR_Duplicate() {
120                         def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")
121                         def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
122                         
123                         wireMockRule
124                                 .stubFor(get(urlMatching("/aai/v[0-9]+/mylink"))
125                                                 .willReturn(aResponse()
126                                                         .withStatus(200)
127                                                         .withHeader("Content-Type", "text/xml")
128                                                         .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")))
129                         
130                         ExecutionEntity mex = setupMock()
131                         
132                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
133                         when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
134                         when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
135                         when(mex.getVariable("CSI_service")).thenReturn(arData)
136                         when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
137                         when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active")
138                         
139                         // fail if duplicate
140                         when(mex.getVariable("failExists")).thenReturn("true")
141                         
142                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
143                         
144                         assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
145                 }
146                 
147                 @Test
148 //              @Ignore
149                 public void getAaiAR_NotActive() {
150                         def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")
151                         def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
152                         
153                         wireMockRule
154                                 .stubFor(get(urlMatching("/aai/v[0-9]+/mylink"))
155                                                 .willReturn(aResponse()
156                                                         .withStatus(200)
157                                                         .withHeader("Content-Type", "text/xml")
158                                                         .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")))
159                         
160                         ExecutionEntity mex = setupMock()
161                         
162                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
163                         when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
164                         when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
165                         when(mex.getVariable("CSI_service")).thenReturn(arData)
166                         when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
167                         
168                         // not active
169                         when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active")
170                         
171                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
172                         
173                         assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) }))
174                 }
175                 
176                 @Test
177 //              @Ignore
178                 public void getAaiAR_NoStatus() {
179                         def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")
180                         def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")
181                         
182                         wireMockRule
183                                 .stubFor(get(urlMatching("/aai/v[0-9]+/mylink"))
184                                                 .willReturn(aResponse()
185                                                         .withStatus(200)
186                                                         .withHeader("Content-Type", "text/xml")
187                                                         .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml")))
188                         
189                         ExecutionEntity mex = setupMock()
190                         
191                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
192                         when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
193                         when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
194                         when(mex.getVariable("CSI_service")).thenReturn(arData)
195                         when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
196                         
197                         when(mex.getVariable("aaiAROrchStatus")).thenReturn(null)
198                         
199                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
200                         DoCreateAllottedResourceBRG.getAaiAR(mex)
201                         
202                         verify(mex, never()).setVariable("foundActiveAR", true)
203                 }
204                 
205                 
206                 // ***** createAaiAR *****
207                 
208                 @Test
209 //              @Ignore
210                 public void createAaiAR() {
211                         ExecutionEntity mex = setupMock()
212                         initCreateAaiAr(mex)
213                         
214                         wireMockRule
215                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid"))
216                                                 .willReturn(aResponse()
217                                                         .withStatus(200)))
218                         
219                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
220                         DoCreateAllottedResourceBRG.createAaiAR(mex)
221                         
222                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
223                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
224                         
225                         verify(mex, times(3)).setVariable(keycap.capture(), valcap.capture())
226                         
227                         assertFalse(keycap.getAllValues().isEmpty())
228                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
229                         
230                         def data = valcap.getAllValues().get(valcap.getAllValues().size()-1)
231                         assertNotNull(data)
232                         assertTrue(data instanceof RollbackData)
233                         
234                         assertEquals("45", data.get(Prefix, "disableRollback"))
235                         assertEquals("true", data.get(Prefix, "rollbackAAI"))
236                         assertEquals("myid", data.get(Prefix, "allottedResourceId"))
237                         assertEquals("sii", data.get(Prefix, "serviceInstanceId"))
238                         assertEquals("psii", data.get(Prefix, "parentServiceInstanceId"))
239                         assertEquals(aaiUriPfx+"/aai/v9/mypsi/allotted-resources/allotted-resource/myid", data.get(Prefix, "aaiARPath"))
240                 }
241                 
242                 @Test
243 //              @Ignore
244                 public void createAaiAR_NoArid_NoModelUuids() {
245                         ExecutionEntity mex = setupMock()
246                         initCreateAaiAr(mex)
247                                 
248                         // no allottedResourceId - will be generated
249                         
250                         when(mex.getVariable("allottedResourceId")).thenReturn(null)
251                         
252                         wireMockRule
253                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/.*"))
254                                                 .willReturn(aResponse()
255                                                         .withStatus(200)))
256                         
257                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
258                         DoCreateAllottedResourceBRG.createAaiAR(mex)
259                         
260                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
261                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
262                         
263                         verify(mex, times(4)).setVariable(keycap.capture(), valcap.capture())
264                         
265                         assertFalse(keycap.getAllValues().isEmpty())
266                         assertEquals("allottedResourceId", keycap.getAllValues().get(0))
267                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
268                         
269                         def arid = valcap.getAllValues().get(0)
270                         assertNotNull(arid)
271                         assertFalse(arid.isEmpty())
272                         
273                         def data = valcap.getAllValues().get(valcap.getAllValues().size()-1)
274                         assertNotNull(data)
275                         assertTrue(data instanceof RollbackData)
276                         
277                         assertEquals(arid, data.get(Prefix, "allottedResourceId"))
278                 }
279                 
280                 @Test
281 //              @Ignore
282                 public void createAaiAR_MissingPsiLink() {
283                         ExecutionEntity mex = setupMock()
284                         initCreateAaiAr(mex)
285                         
286                         when(mex.getVariable("PSI_resourceLink")).thenReturn(null)
287                         
288                         wireMockRule
289                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid"))
290                                                 .willReturn(aResponse()
291                                                         .withStatus(200)))
292                         
293                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
294                         
295                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
296                 }
297                 
298                 @Test
299 //              @Ignore
300                 public void createAaiAR_HttpFailed() {
301                         ExecutionEntity mex = setupMock()
302                         initCreateAaiAr(mex)
303                         
304                         // return 500 status
305                         wireMockRule
306                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid"))
307                                                 .willReturn(aResponse()
308                                                         .withStatus(500)))
309                         
310                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
311                         
312                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
313                 }
314                 
315                 @Test
316 //              @Ignore
317                 public void createAaiAR_BpmnError() {
318                         ExecutionEntity mex = setupMock()
319                         initCreateAaiAr(mex)
320                         
321                         when(mex.getVariable("URN_aai_endpoint")).thenThrow(new BpmnError("expected exception"))
322                         
323                         wireMockRule
324                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid"))
325                                                 .willReturn(aResponse()
326                                                         .withStatus(200)))
327                         
328                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
329                         
330                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
331                 }
332                 
333                 @Test
334 //              @Ignore
335                 public void createAaiAR_Ex() {
336                         ExecutionEntity mex = setupMock()
337                         initCreateAaiAr(mex)
338                         
339                         when(mex.getVariable("URN_aai_endpoint")).thenThrow(new RuntimeException("expected exception"))
340                         
341                         wireMockRule
342                                 .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid"))
343                                                 .willReturn(aResponse()
344                                                         .withStatus(200)))
345                         
346                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
347                         
348                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) }))
349                 }
350                 
351                 
352                 // ***** buildSDNCRequest *****
353                 
354                 @Test
355 //              @Ignore
356                 public void buildSDNCRequest() {
357                         ExecutionEntity mex = setupMock()
358                         initBuildSDNCRequest(mex)
359                         
360                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
361                         
362                         String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
363                         
364                         assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
365                         assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
366                         assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
367                         assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
368                         assertTrue(result.indexOf("<service-instance-id>psii</") >= 0)
369                         assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
370                         assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
371                         assertTrue(result.indexOf("<request-id>mri</") >= 0)
372                         assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
373                         assertTrue(result.indexOf("<vni>myvni</") >= 0)
374                         assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
375                         assertTrue(result.indexOf("<model-invariant-uuid>miu</") >= 0)
376                         assertTrue(result.indexOf("<model-uuid>mu</") >= 0)
377                         assertTrue(result.indexOf("<model-customization-uuid>mcu</") >= 0)
378                         assertTrue(result.indexOf("<model-version>mv</") >= 0)
379                         assertTrue(result.indexOf("<model-name>mn</") >= 0)
380                 }
381                 
382                 @Test
383 //              @Ignore
384                 public void buildSDNCRequest_EmptyModelInfo() {
385                         ExecutionEntity mex = setupMock()
386                         initBuildSDNCRequest(mex)
387                         
388                         when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}")
389                         
390                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
391                         
392                         String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq")
393                         
394                         assertTrue(result.indexOf("<sdncadapter:RequestId>myreq</") >= 0)
395                         assertTrue(result.indexOf("<sdncadapter:SvcAction>myact</") >= 0)
396                         assertTrue(result.indexOf("<allotted-resource-id>ari</") >= 0)
397                         assertTrue(result.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
398                         assertTrue(result.indexOf("<service-instance-id>psii</") >= 0)
399                         assertTrue(result.indexOf("<parent-service-instance-id>psii</") >= 0)
400                         assertTrue(result.indexOf("<sdncadapter:CallbackUrl>scu</") >= 0)
401                         assertTrue(result.indexOf("<request-id>mri</") >= 0)
402                         assertTrue(result.indexOf("<brg-wan-mac-address>bwma</") >= 0)
403                         assertTrue(result.indexOf("<vni>myvni</") >= 0)
404                         assertTrue(result.indexOf("<vgmux-bearer-ip>vbi</") >= 0)
405                         assertTrue(result.indexOf("<model-invariant-uuid/>") >= 0)
406                         assertTrue(result.indexOf("<model-uuid/>") >= 0)
407                         assertTrue(result.indexOf("<model-customization-uuid/>") >= 0)
408                         assertTrue(result.indexOf("<model-version/>") >= 0)
409                         assertTrue(result.indexOf("<model-name/>") >= 0)
410                 }
411                 
412                 @Test
413 //              @Ignore
414                 public void buildSDNCRequest_Ex() {
415                         ExecutionEntity mex = setupMock()
416                         initBuildSDNCRequest(mex)
417                         
418                         when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception"))
419                         
420                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
421                         
422                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") }))
423                 }
424                 
425                 
426                 // ***** preProcessSDNCAssign *****
427                 
428                 @Test
429 //              @Ignore
430                 public void preProcessSDNCAssign() {
431                         ExecutionEntity mex = setupMock()
432                         def data = initPreProcessSDNC(mex)
433                                                 
434                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
435                         DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex)
436                         
437                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
438                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
439                         
440                         verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture())
441                         
442                         assertFalse(keycap.getAllValues().isEmpty())
443                         assertEquals("sdncAssignRequest", keycap.getAllValues().get(0))
444                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
445                         
446                         def req = valcap.getAllValues().get(0)
447                         assertNotNull(req)
448                         
449                         assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1))
450                         
451                         def rbreq = data.get(Prefix, "sdncAssignRollbackReq")
452                         
453                         assertTrue(req.indexOf("<sdncadapter:SvcAction>assign</") >= 0)
454                         assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
455                         assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
456                         
457                         assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>unassign</") >= 0)
458                         assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
459                         assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
460                 }
461                 
462                 @Test
463 //              @Ignore
464                 public void preProcessSDNCAssign_BpmnError() {
465                         ExecutionEntity mex = setupMock()
466                         initPreProcessSDNC(mex)
467                         
468                         when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
469                                                 
470                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
471                         
472                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
473                 }
474                 
475                 @Test
476 //              @Ignore
477                 public void preProcessSDNCAssign_Ex() {
478                         ExecutionEntity mex = setupMock()
479                         initPreProcessSDNC(mex)
480                         
481                         when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
482                                                 
483                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
484                         
485                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) }))
486                 }
487                 
488                 
489                 // ***** preProcessSDNCCreate *****
490                 
491                 @Test
492 //              @Ignore
493                 public void preProcessSDNCCreate() {
494                         ExecutionEntity mex = setupMock()
495                         def data = initPreProcessSDNC(mex)
496                                                 
497                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
498                         DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex)
499                         
500                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
501                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
502                         
503                         verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture())
504                         
505                         assertFalse(keycap.getAllValues().isEmpty())
506                         assertEquals("sdncCreateRequest", keycap.getAllValues().get(0))
507                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
508                         
509                         def req = valcap.getAllValues().get(0)
510                         assertNotNull(req)
511                         
512                         assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1))
513                         
514                         def rbreq = data.get(Prefix, "sdncCreateRollbackReq")
515                         
516                         assertTrue(req.indexOf("<sdncadapter:SvcAction>create</") >= 0)
517                         assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
518                         assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
519                         
520                         assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>delete</") >= 0)
521                         assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
522                         assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
523                         
524                 }
525                 
526                 @Test
527 //              @Ignore
528                 public void preProcessSDNCCreate_BpmnError() {
529                         ExecutionEntity mex = setupMock()
530                         initPreProcessSDNC(mex)
531                         
532                         when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
533                                                 
534                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
535                         
536                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
537                 }
538                 
539                 @Test
540 //              @Ignore
541                 public void preProcessSDNCCreate_Ex() {
542                         ExecutionEntity mex = setupMock()
543                         initPreProcessSDNC(mex)
544                         
545                         when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
546                                                 
547                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
548                         
549                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) }))
550                 }
551                 
552                 
553                 // ***** preProcessSDNCActivate *****
554                 
555                 @Test
556 //              @Ignore
557                 public void preProcessSDNCActivate() {
558                         ExecutionEntity mex = setupMock()
559                         def data = initPreProcessSDNC(mex)
560                                                 
561                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
562                         DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex)
563                         
564                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
565                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
566                         
567                         verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture())
568                         
569                         assertFalse(keycap.getAllValues().isEmpty())
570                         assertEquals("sdncActivateRequest", keycap.getAllValues().get(0))
571                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
572                         
573                         def req = valcap.getAllValues().get(0)
574                         assertNotNull(req)
575                         
576                         assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1))
577                         
578                         def rbreq = data.get(Prefix, "sdncActivateRollbackReq")
579                         
580                         assertTrue(req.indexOf("<sdncadapter:SvcAction>activate</") >= 0)
581                         assertTrue(req.indexOf("<request-action>CreateBRGInstance</") >= 0)
582                         assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
583                         
584                         assertTrue(rbreq.indexOf("<sdncadapter:SvcAction>deactivate</") >= 0)
585                         assertTrue(rbreq.indexOf("<request-action>DeleteBRGInstance</") >= 0)
586                         assertTrue(rbreq.indexOf("<sdncadapter:RequestId>") >= 0)
587                         
588                 }
589                 
590                 @Test
591 //              @Ignore
592                 public void preProcessSDNCActivate_BpmnError() {
593                         ExecutionEntity mex = setupMock()
594                         initPreProcessSDNC(mex)
595                         
596                         when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception"))
597                                                 
598                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
599                         
600                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
601                 }
602                 
603                 @Test
604 //              @Ignore
605                 public void preProcessSDNCActivate_Ex() {
606                         ExecutionEntity mex = setupMock()
607                         initPreProcessSDNC(mex)
608                         
609                         when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception"))
610                                                 
611                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
612                         
613                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) }))
614                 }
615                 
616                 
617                 // ***** validateSDNCResp *****
618                 
619                 @Test
620 //              @Ignore
621                 public void validateSDNCResp() {
622                         ExecutionEntity mex = setupMock()
623                         def data = initValidateSDNCResp(mex)
624                         def resp = initValidateSDNCResp_Resp()
625                         
626                         when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
627                         
628                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
629                         
630                         DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create")
631                         
632                         verify(mex).getVariable("WorkflowException")
633                         verify(mex).getVariable("SDNCA_SuccessIndicator")
634                         verify(mex).getVariable("rollbackData")
635                         
636                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
637                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
638                         
639                         verify(mex, times(4)).setVariable(keycap.capture(), valcap.capture())
640                         
641                         assertFalse(keycap.getAllValues().isEmpty())
642                         assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1))
643                         
644                         assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1))
645                         
646                         assertEquals("true", data.get(Prefix, "rollback" +  "SDNCcreate"))
647                         
648                 }
649                 
650                 @Test
651 //              @Ignore
652                 public void validateSDNCResp_Get() {
653                         ExecutionEntity mex = setupMock()
654                         def data = initValidateSDNCResp(mex)
655                         def resp = initValidateSDNCResp_Resp()
656                         
657                         when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true)
658                         
659                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
660                         
661                         DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get")
662                         
663                         verify(mex).getVariable("WorkflowException")
664                         verify(mex).getVariable("SDNCA_SuccessIndicator")
665                         
666                         verify(mex, never()).getVariable("rollbackData")
667                 }
668                 
669                 @Test
670 //              @Ignore
671                 public void validateSDNCResp_Unsuccessful() {
672                         ExecutionEntity mex = setupMock()
673                         initValidateSDNCResp(mex)
674                         def resp = initValidateSDNCResp_Resp()
675                         
676                         // unsuccessful
677                         when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false)
678                         
679                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
680                         
681                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
682                 }
683                 
684                 @Test
685 //              @Ignore
686                 public void validateSDNCResp_BpmnError() {
687                         ExecutionEntity mex = setupMock()
688                         initValidateSDNCResp(mex)
689                         def resp = initValidateSDNCResp_Resp()
690                         
691                         when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
692                         
693                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
694                         
695                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
696                 }
697                 
698                 @Test
699 //              @Ignore
700                 public void validateSDNCResp_Ex() {
701                         ExecutionEntity mex = setupMock()
702                         initValidateSDNCResp(mex)
703                         def resp = initValidateSDNCResp_Resp()
704                         
705                         when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
706                         
707                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
708                         
709                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") }))
710                 }
711                 
712                 
713                 // ***** preProcessSDNCGet *****
714                 
715                 @Test
716 //              @Ignore
717                 public void preProcessSDNCGet_FoundAR() {
718                         ExecutionEntity mex = setupMock()
719                         initPreProcessSDNCGet(mex)
720                                                 
721                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
722                         DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
723                         
724                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
725                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
726                         
727                         verify(mex, times(1)).setVariable(keycap.capture(), valcap.capture())
728                         
729                         assertFalse(keycap.getAllValues().isEmpty())
730                         assertEquals("sdncGetRequest", keycap.getAllValues().get(keycap.getAllValues().size()-1))
731                         
732                         String req = valcap.getAllValues().get(valcap.getAllValues().size()-1)
733                         
734                         assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
735                         assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
736                         assertTrue(req.indexOf("<sdncadapter:SvcOperation>arlink</") >= 0)
737                         assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
738                         
739                 }
740                 
741                 @Test
742 //              @Ignore
743                 public void preProcessSDNCGet_NotFoundAR() {
744                         ExecutionEntity mex = setupMock()
745                         initPreProcessSDNCGet(mex)
746                         
747                         when(mex.getVariable("foundActiveAR")).thenReturn(false)
748                                                 
749                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
750                         DoCreateAllottedResourceBRG.preProcessSDNCGet(mex)
751                         
752                         ArgumentCaptor<String> keycap = ArgumentCaptor.forClass(String.class)
753                         ArgumentCaptor<Object> valcap = ArgumentCaptor.forClass(Object.class)
754                         
755                         verify(mex, times(1)).setVariable(keycap.capture(), valcap.capture())
756                         
757                         assertFalse(keycap.getAllValues().isEmpty())
758                         assertEquals("sdncGetRequest", keycap.getAllValues().get(keycap.getAllValues().size()-1))
759                         
760                         String req = valcap.getAllValues().get(valcap.getAllValues().size()-1)
761                         
762                         assertTrue(req.indexOf("<sdncadapter:RequestId>") >= 0)
763                         assertTrue(req.indexOf("<sdncadapter:SvcInstanceId>sii</") >= 0)
764                         assertTrue(req.indexOf("<sdncadapter:SvcOperation>assignlink</") >= 0)
765                         assertTrue(req.indexOf("<sdncadapter:CallbackUrl>myurl</") >= 0)
766                         
767                 }
768                 
769                 @Test
770 //              @Ignore
771                 public void preProcessSDNCGet_Ex() {
772                         ExecutionEntity mex = setupMock()
773                         initPreProcessSDNCGet(mex)
774                         
775                         when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception"))
776                         
777                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
778                         
779                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) }))
780                 }
781                 
782                 
783                 // ***** updateAaiAROrchStatus *****
784                 
785                 @Test
786 //              @Ignore
787                 public void updateAaiAROrchStatus() {
788                         ExecutionEntity mex = setupMock()
789                         initUpdateAaiAROrchStatus(mex)
790                                                 
791                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
792                         DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success")
793                 }
794                 
795                 
796                 // ***** generateOutputs *****
797                 
798                 @Test
799 //              @Ignore
800                 public void generateOutputs() {
801                         ExecutionEntity mex = setupMock()
802                         def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml")
803                         
804                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
805                         when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop)
806                         
807                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
808                         DoCreateAllottedResourceBRG.generateOutputs(mex)
809                         
810                         verify(mex).setVariable("allotedResourceName", "namefromrequest")
811                         
812                 }
813                 
814                 @Test
815 //              @Ignore
816                 public void generateOutputs_BadXml() {
817                         ExecutionEntity mex = setupMock()
818                         
819                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
820                         when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml")
821                         
822                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
823                         DoCreateAllottedResourceBRG.generateOutputs(mex)
824                         
825                         verify(mex, never()).setVariable(anyString(), anyString())
826                         
827                 }
828                 
829                 @Test
830 //              @Ignore
831                 public void generateOutputs_BpmnError() {
832                         ExecutionEntity mex = setupMock()
833                         
834                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
835                         when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception"))
836                         
837                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
838                         
839                         DoCreateAllottedResourceBRG.generateOutputs(mex)
840                         verify(mex, never()).setVariable(anyString(), anyString())
841                         
842                 }
843                 
844                 @Test
845 //              @Ignore
846                 public void generateOutputs_Ex() {
847                         ExecutionEntity mex = setupMock()
848                         
849                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
850                         when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception"))
851                         
852                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
853                         
854                         DoCreateAllottedResourceBRG.generateOutputs(mex)
855                         verify(mex, never()).setVariable(anyString(), anyString())
856                         
857                 }
858                 
859                 
860                 // ***** preProcessRollback *****
861                 
862                 @Test
863 //              @Ignore
864                 public void preProcessRollback() {
865                         ExecutionEntity mex = setupMock()
866                         WorkflowException wfe = mock(WorkflowException.class)
867                         
868                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
869                         when(mex.getVariable("WorkflowException")).thenReturn(wfe)
870                         
871                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
872                         DoCreateAllottedResourceBRG.preProcessRollback(mex)
873                         
874                         verify(mex).setVariable("prevWorkflowException", wfe)
875                         
876                 }
877                 
878                 @Test
879 //              @Ignore
880                 public void preProcessRollback_NotWFE() {
881                         ExecutionEntity mex = setupMock()
882                         
883                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
884                         when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE")
885                         
886                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
887                         DoCreateAllottedResourceBRG.preProcessRollback(mex)
888                         
889 //                      verify(mex, never()).setVariable("prevWorkflowException", any())
890                         
891                 }
892                 
893                 @Test
894 //              @Ignore
895                 public void preProcessRollback_BpmnError() {
896                         ExecutionEntity mex = setupMock()
897                         
898                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
899                         when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception"))
900                         
901                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
902                         
903                         DoCreateAllottedResourceBRG.preProcessRollback(mex)
904                         
905                 }
906                 
907                 @Test
908 //              @Ignore
909                 public void preProcessRollback_Ex() {
910                         ExecutionEntity mex = setupMock()
911                         
912                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
913                         when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception"))
914                         
915                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
916                         
917                         DoCreateAllottedResourceBRG.preProcessRollback(mex)
918                         
919                 }
920                 
921                 
922                 // ***** postProcessRollback *****
923                 
924                 @Test
925 //              @Ignore
926                 public void postProcessRollback() {
927                         ExecutionEntity mex = setupMock()
928                         WorkflowException wfe = mock(WorkflowException.class)
929                         
930                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
931                         when(mex.getVariable("prevWorkflowException")).thenReturn(wfe)
932                         
933                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
934                         DoCreateAllottedResourceBRG.postProcessRollback(mex)
935                         
936                         verify(mex).setVariable("WorkflowException", wfe)
937                         verify(mex).setVariable("rollbackData", null)
938                         
939                 }
940                 
941                 @Test
942 //              @Ignore
943                 public void postProcessRollback_NotWFE() {
944                         ExecutionEntity mex = setupMock()
945                         
946                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
947                         when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE")
948                         
949                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
950                         DoCreateAllottedResourceBRG.postProcessRollback(mex)
951                         
952 //                      verify(mex, never()).setVariable("WorkflowException", any())
953                         verify(mex).setVariable("rollbackData", null)
954                         
955                 }
956                 
957                 @Test
958 //              @Ignore
959                 public void postProcessRollback_BpmnError() {
960                         ExecutionEntity mex = setupMock()
961                         
962                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
963                         when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception"))
964                         
965                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
966                         
967                         assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) }))
968                         verify(mex, never()).setVariable("rollbackData", null)
969                         
970                 }
971                 
972                 @Test
973 //              @Ignore
974                 public void postProcessRollback_Ex() {
975                         ExecutionEntity mex = setupMock()
976                         
977                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
978                         when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception"))
979                         
980                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
981                         
982                         DoCreateAllottedResourceBRG.postProcessRollback(mex)
983                         verify(mex, never()).setVariable("rollbackData", null)
984                         
985                 }
986                 
987                 private boolean checkMissingPreProcessRequest(String fieldnm) {
988                         ExecutionEntity mex = setupMock()
989                         initPreProcess(mex)
990                                                                         
991                         DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG()
992                         
993                         when(mex.getVariable(fieldnm)).thenReturn("")
994                         
995                         return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) })
996                 }
997                 
998                 private boolean doBpmnError(def func) {
999                         
1000                         try {
1001                                 func()
1002                                 return false;
1003                                 
1004                         } catch(BpmnError e) {
1005                                 return true;
1006                         }
1007                 }
1008                 
1009                 private void initPreProcess(ExecutionEntity mex) {
1010                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1011                         when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn")
1012                         when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1013                         when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
1014                         when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi")
1015                         when(mex.getVariable("vni")).thenReturn("myvni")
1016                         when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
1017                         when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
1018                         when(mex.getVariable("allottedResourceRole")).thenReturn("arr")
1019                         when(mex.getVariable("allottedResourceType")).thenReturn("art")
1020                 }
1021                 
1022                 private initCreateAaiAr(ExecutionEntity mex) {                          
1023                         when(mex.getVariable("disableRollback")).thenReturn(45)
1024                         when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1025                         when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
1026                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1027                         when(mex.getVariable("allottedResourceId")).thenReturn("myid")
1028                         when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx)
1029                         when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace"))
1030                         when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mypsi")
1031                         when(mex.getVariable("allottedResourceType")).thenReturn("BRGt")
1032                         when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr")
1033                         when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi")
1034                         when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
1035                                         {
1036                                                 "modelInvariantUuid":"modelinvuuid",
1037                                                 "modelUuid":"modeluuid",
1038                                                 "modelCustomizationUuid":"modelcustuuid"
1039                                         }
1040                                 """)
1041                 }
1042                 
1043                 private initBuildSDNCRequest(ExecutionEntity mex) {
1044                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1045                         when(mex.getVariable("allottedResourceId")).thenReturn("ari")
1046                         when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1047                         when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii")
1048                         when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu")
1049                         when(mex.getVariable("msoRequestId")).thenReturn("mri")
1050                         when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma")
1051                         when(mex.getVariable("vni")).thenReturn("myvni")
1052                         when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi")
1053                         when(mex.getVariable("allottedResourceModelInfo")).thenReturn("""
1054                                         {
1055                                                 "modelInvariantUuid":"miu",
1056                                                 "modelUuid":"mu",
1057                                                 "modelCustomizationUuid":"mcu",
1058                                                 "modelVersion":"mv",
1059                                                 "modelName":"mn"
1060                                         }
1061                                 """)
1062                 }
1063                 
1064                 private RollbackData initPreProcessSDNC(ExecutionEntity mex) {
1065                         def data = new RollbackData()
1066                         
1067                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1068                         when(mex.getVariable("rollbackData")).thenReturn(data)
1069                         
1070                         return data
1071                 }
1072                 
1073                 private initPreProcessSDNCGet(ExecutionEntity mex) {
1074                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1075                         when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
1076                         when(mex.getVariable("foundActiveAR")).thenReturn(true)
1077                         when(mex.getVariable("aaiARGetResponse")).thenReturn("<selflink>arlink</selflink>")
1078                         when(mex.getVariable("sdncAssignResponse")).thenReturn("<response-data>&lt;object-path&gt;assignlink&lt;/object-path&gt;</response-data>")
1079                         when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
1080                         when(mex.getVariable("junitSleepMs")).thenReturn("5")
1081                         when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl")
1082                 }
1083                 
1084                 private RollbackData initValidateSDNCResp(ExecutionEntity mex) {
1085                         def data = new RollbackData()
1086                         
1087                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1088                         when(mex.getVariable("prefix")).thenReturn(Prefix)
1089                         when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true)
1090                         when(mex.getVariable("rollbackData")).thenReturn(data)
1091                         
1092                         return data
1093                 }
1094                 
1095                 private String initValidateSDNCResp_Resp() {
1096                         return "<response-data>&lt;response-code&gt;200&lt;/response-code&gt;</response-data>"
1097                 }
1098                 
1099                 private initUpdateAaiAROrchStatus(ExecutionEntity mex) {
1100                         when(mex.getVariable("isDebugLogEnabled")).thenReturn("true")
1101                         when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx+"/aai/v9/myurl")
1102                         
1103                         wireMockRule
1104                                 .stubFor(patch(urlMatching("/aai/v[0-9]+/myurl"))
1105                                                         .willReturn(aResponse()
1106                                                                 .withStatus(200)))
1107                 }\r
1108                 \r
1109                 private ExecutionEntity setupMock() {\r
1110                         \r
1111                         ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)\r
1112                         when(mockProcessDefinition.getKey()).thenReturn("DoCreateAllottedResourceBRG")\r
1113                         RepositoryService mockRepositoryService = mock(RepositoryService.class)\r
1114                         when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)\r
1115                         when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateAllottedResourceBRG")\r
1116                         when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")\r
1117                         ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)\r
1118                         when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)\r
1119                         \r
1120                         ExecutionEntity mex = mock(ExecutionEntity.class)\r
1121                         \r
1122                         when(mex.getId()).thenReturn("100")\r
1123                         when(mex.getProcessDefinitionId()).thenReturn("DoCreateAllottedResourceBRG")\r
1124                         when(mex.getProcessInstanceId()).thenReturn("DoCreateAllottedResourceBRG")\r
1125                         when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices)\r
1126                         when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition)\r
1127                         \r
1128                         return mex\r
1129                 }\r
1130                 \r
1131 }