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