560f2a91bfb1ce0ab3250a72389c98fc3ac780a7
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / aai / tasks / AAIUpdateTasksTest.java
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
21 package org.onap.so.bpmn.infrastructure.aai.tasks;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Matchers.any;
25 import static org.mockito.Matchers.eq;
26 import static org.mockito.Mockito.doNothing;
27 import static org.mockito.Mockito.doReturn;
28 import static org.mockito.Mockito.doThrow;
29 import static org.mockito.Mockito.mock;
30 import static org.mockito.Mockito.spy;
31 import static org.mockito.Mockito.times;
32 import static org.mockito.Mockito.verify;
33 import static org.mockito.Mockito.when;
34
35 import java.util.HashMap;
36
37 import org.camunda.bpm.engine.delegate.BpmnError;
38 import org.hamcrest.Matchers;
39 import org.junit.Before;
40 import org.junit.Test;
41 import org.mockito.Mockito;
42 import org.onap.so.adapters.nwrest.CreateNetworkResponse;
43 import org.onap.so.bpmn.BaseTaskTest;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
52 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
53 import org.onap.so.db.catalog.beans.OrchestrationStatus;
54 import org.springframework.beans.factory.annotation.Autowired;
55
56 public class AAIUpdateTasksTest extends BaseTaskTest{
57         @Autowired
58         private AAIUpdateTasks aaiUpdateTasks;
59         
60         private L3Network network;
61         private ServiceInstance serviceInstance;
62         private VfModule vfModule;
63         private GenericVnf genericVnf;
64         private VolumeGroup volumeGroup;
65         private CloudRegion cloudRegion;
66         private Configuration configuration;
67         private Subnet subnet;
68         
69         @Before
70         public void before() {
71                 serviceInstance = setServiceInstance();
72                 genericVnf = setGenericVnf();
73                 vfModule = setVfModule();
74                 volumeGroup = setVolumeGroup();
75                 cloudRegion = setCloudRegion();
76                 network = setL3Network();
77                 configuration = setConfiguration();
78                 subnet = buildSubnet();
79         }
80         
81         @Test
82         public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
83                 doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
84
85                 aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
86
87                 verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
88         }
89         
90         @Test
91         public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
92                 expectedException.expect(BpmnError.class);
93                 
94                 doThrow(Exception.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
95
96                 aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
97         }
98         
99         @Test
100         public void updateOrchestrationStatusActiveServiceTest() throws Exception {
101                 doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
102
103                 aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
104
105                 verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
106         }
107         
108         @Test
109         public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
110                 expectedException.expect(BpmnError.class);
111                 
112                 doThrow(Exception.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
113
114                 aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
115         }
116
117         @Test
118         public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
119                 doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
120
121                 aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
122
123                 verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
124         }
125         
126         @Test
127         public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
128                 expectedException.expect(BpmnError.class);
129                 
130                 doThrow(Exception.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
131
132                 aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
133         }
134         
135         @Test
136         public void updateOrchestrationStatusActiveVnfTest() throws Exception {
137                 doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
138
139                 aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
140
141                 verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
142         }
143         
144         @Test
145         public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
146                 expectedException.expect(BpmnError.class);
147                 
148                 doThrow(Exception.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
149
150                 aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
151         }
152         
153         @Test
154         public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {            
155                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
156                 aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
157                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
158                 assertEquals("", vfModule.getHeatStackId());
159         }
160         
161         @Test
162         public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
163                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
164                 
165                 expectedException.expect(BpmnError.class);
166                 
167                 aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
168         }
169         
170         @Test
171         public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception {
172                 ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
173                 modelInfoGenericVnf.setMultiStageDesign("false");
174                 genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
175                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
176                 aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
177                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
178                 assertEquals("", vfModule.getHeatStackId());
179         }
180         
181         @Test
182         public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception {
183                 ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
184                 modelInfoGenericVnf.setMultiStageDesign("true");
185                 genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
186                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
187                 aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
188                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
189                 assertEquals("", vfModule.getHeatStackId());
190         }
191         
192         @Test
193         public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
194                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
195                 
196                 expectedException.expect(BpmnError.class);
197                 
198                 aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
199         }
200         
201         @Test
202         public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {           
203                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
204                 aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
205                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
206         }
207         
208         @Test
209         public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
210                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
211                 
212                 expectedException.expect(BpmnError.class);
213                 
214                 aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
215         }
216         
217         @Test
218         public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
219                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
220
221                 aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
222
223                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
224         }
225         
226         @Test
227         public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
228                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
229                 
230                 expectedException.expect(BpmnError.class);
231         
232                 aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
233         }
234         
235         @Test
236         public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
237                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
238
239                 aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
240
241                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
242         }
243         
244         @Test
245         public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
246                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
247                 
248                 expectedException.expect(BpmnError.class);
249         
250                 aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
251         }
252         
253         @Test
254         public void updateHeatStackIdVfModuleTest() throws Exception {
255                 execution.setVariable("heatStackId", "newHeatStackId");
256                 doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
257
258                 aaiUpdateTasks.updateHeatStackIdVfModule(execution);
259
260                 verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
261                 assertEquals("newHeatStackId", vfModule.getHeatStackId());
262         }
263         
264         @Test
265         public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
266                 doThrow(Exception.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
267                 
268                 expectedException.expect(BpmnError.class);
269         
270                 aaiUpdateTasks.updateHeatStackIdVfModule(execution);
271         }
272         
273         @Test
274         public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
275                 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
276
277                 aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
278
279                 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
280         }
281         
282         @Test
283         public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
284                 expectedException.expect(BpmnError.class);
285                 doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
286                 aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
287         }
288         
289         @Test
290         public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
291                 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
292
293                 aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
294
295                 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
296         }
297         
298         @Test
299         public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
300                 expectedException.expect(BpmnError.class);
301                 doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
302                 aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
303         }       
304         
305         @Test
306         public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
307                 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
308
309                 aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
310
311                 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
312                 assertEquals("", volumeGroup.getHeatStackId());
313         }
314         
315         @Test
316         public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
317                 expectedException.expect(BpmnError.class);
318                 doThrow(Exception.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
319                 aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
320         }
321         @Test
322         public void updateHeatStackIdVolumeGroupTest() throws Exception {
323                 execution.setVariable("heatStackId", "newHeatStackId");
324                 doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
325
326                 aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
327
328                 verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
329                 assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
330         }
331         
332         @Test
333         public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
334                 expectedException.expect(BpmnError.class);
335                 doThrow(Exception.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
336                 aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
337         }
338
339         @Test
340         public void updateNetworkExceptionTest() throws Exception {
341                 expectedException.expect(BpmnError.class);
342
343                 doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
344                 
345                 aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
346         }
347         
348         @Test
349         public void updateOstatusActivedNetworkCollectionTest() throws Exception {
350                 doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
351                 aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
352                 verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
353         }
354
355         @Test
356         public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
357                 expectedException.expect(BpmnError.class);
358                 doThrow(Exception.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
359                 aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
360         }
361
362         @Test
363         public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
364                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
365
366                 aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
367
368                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
369         }
370         
371         @Test
372         public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
373                 doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
374                 
375                 expectedException.expect(BpmnError.class);
376                 
377                 aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
378         }
379         
380         @Test
381         public void updateNetworkCreatedTest() throws Exception {
382                 CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
383                 createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
384                 createNetworkResponse.setNetworkStackId("testNetworkStackId");
385                 HashMap<String, String> subnetMap = new HashMap<String, String>();
386                 subnetMap.put("testSubnetId", "testNeutronSubnetId");
387                 createNetworkResponse.setSubnetMap(subnetMap);
388                 
389                 network.getSubnets().add(subnet);
390                 
391                 execution.setVariable("createNetworkResponse", createNetworkResponse);
392                 
393                 doNothing().when(aaiNetworkResources).updateNetwork(network);
394                 doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
395
396                 aaiUpdateTasks.updateNetworkCreated(execution);
397                 verify(aaiNetworkResources, times(1)).updateNetwork(network);
398                 verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
399                 
400                 assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
401                 assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
402                 assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
403                 assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
404                 String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
405                 assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
406         }
407
408         @Test
409         public void updateOrchestrationStatusNetworkTest() {
410                 AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks());
411                 doNothing().when(spy).updateNetwork(eq(execution), any());
412                 spy.updateOrchestrationStatusActiveNetwork(execution);
413                 verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE);
414                 spy.updateOrchestrationStatusAssignedNetwork(execution);
415                 verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED);
416                 spy.updateOrchestrationStatusCreatedNetwork(execution);
417                 verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED);
418         }
419         
420         @Test
421         public void updateNetworkAAITest() {
422                 
423                 L3Network spy = spy(new L3Network());
424                 L3Network shallowCopy = mock(L3Network.class);
425                 Subnet mockSubnet = mock(Subnet.class);
426                 Subnet shallowCopySubnet = mock(Subnet.class);
427                 when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
428                 doReturn(shallowCopy).when(spy).shallowCopyId();
429                                 
430                 doNothing().when(aaiNetworkResources).updateNetwork(network);
431                 doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
432                 
433                 spy.getSubnets().add(mockSubnet);
434                 aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
435                         
436                 verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
437                 verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
438                 verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
439         }
440         @Test
441         public void updateNetworkCreatedkExceptionTest() throws Exception {
442                 expectedException.expect(BpmnError.class);
443                 doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
444                 aaiUpdateTasks.updateNetworkCreated(execution);
445         }
446         
447         @Test
448         public void updateObjectNetworkTest() {
449                 doNothing().when(aaiNetworkResources).updateNetwork(network);
450                 
451                 aaiUpdateTasks.updateObjectNetwork(execution);
452                 
453                 verify(aaiNetworkResources, times(1)).updateNetwork(network);
454         }
455         
456         @Test
457         public void updateObjectNetworkExceptionText() {
458                 expectedException.expect(BpmnError.class);
459                 
460                 doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network);
461                 
462                 aaiUpdateTasks.updateObjectNetwork(execution);
463         }
464         
465         @Test
466         public void test_updateServiceInstance() {
467                 doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
468                 aaiUpdateTasks.updateServiceInstance(execution);
469                 verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
470         }
471
472         @Test
473         public void test_updateServiceInstance_exception() {
474                 expectedException.expect(BpmnError.class);
475                 doThrow(Exception.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
476                 aaiUpdateTasks.updateServiceInstance(execution);
477         }
478         
479         @Test
480         public void updateObjectVnfTest() {
481                 doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
482                 
483                 aaiUpdateTasks.updateObjectVnf(execution);
484                 
485                 verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
486         }
487         
488         @Test
489         public void updateObjectVnfExceptionTest() {
490                 expectedException.expect(BpmnError.class);
491                 doThrow(Exception.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
492                 aaiUpdateTasks.updateObjectVnf(execution);
493         }
494         
495         @Test
496         public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
497                 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
498
499                 aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
500
501                 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
502                 assertEquals("", vfModule.getHeatStackId());
503         }
504         
505         @Test
506         public void updateModelVfModuleTest() {
507                 doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
508                 aaiUpdateTasks.updateModelVfModule(execution);
509                 verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
510         }
511         
512         @Test
513         public void updateModelVfModuleExceptionTest() {
514                 expectedException.expect(BpmnError.class);
515                 doThrow(Exception.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
516                 aaiUpdateTasks.updateModelVfModule(execution);
517         }
518         
519         @Test
520         public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
521                 gBBInput = execution.getGeneralBuildingBlock();
522                 doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
523
524                 aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
525
526                 verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
527         }
528         @Test
529         public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
530                 gBBInput = execution.getGeneralBuildingBlock();
531                 doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
532
533                 aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
534
535                 verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
536         }
537 }