2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.infrastructure.aai.tasks;
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;
35 import java.util.HashMap;
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;
59 public class AAIUpdateTasksTest extends BaseTaskTest{
62 private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
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;
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();
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);
92 doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
96 public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
97 doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
99 aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
101 verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
105 public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
106 expectedException.expect(BpmnError.class);
108 doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ASSIGNED);
110 aaiUpdateTasks.updateOrchestrationStatusAssignedService(execution);
114 public void updateOrchestrationStatusActiveServiceTest() throws Exception {
115 doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
117 aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
119 verify(aaiServiceInstanceResources, times(1)).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
123 public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
124 expectedException.expect(BpmnError.class);
126 doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance, OrchestrationStatus.ACTIVE);
128 aaiUpdateTasks.updateOrchestrationStatusActiveService(execution);
132 public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
133 doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
135 aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
137 verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
141 public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
142 expectedException.expect(BpmnError.class);
144 doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
146 aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
150 public void updateOrchestrationStatusActiveVnfTest() throws Exception {
151 doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
153 aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
155 verify(aaiVnfResources, times(1)).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
159 public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
160 expectedException.expect(BpmnError.class);
162 doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
164 aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
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());
176 public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
177 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
179 expectedException.expect(BpmnError.class);
181 aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
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());
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());
207 public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception {
208 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
210 expectedException.expect(BpmnError.class);
212 aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution);
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);
223 public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
224 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
226 expectedException.expect(BpmnError.class);
228 aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
232 public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
233 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
235 aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
237 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
241 public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
242 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
244 expectedException.expect(BpmnError.class);
246 aaiUpdateTasks.updateOrchestrationStatusPendingActivationVfModule(execution);
250 public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
251 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
253 aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
255 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
259 public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
260 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.CREATED);
262 expectedException.expect(BpmnError.class);
264 aaiUpdateTasks.updateOrchestrationStatusDeactivateVfModule(execution);
268 public void updateHeatStackIdVfModuleTest() throws Exception {
269 execution.setVariable("heatStackId", "newHeatStackId");
270 doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
272 aaiUpdateTasks.updateHeatStackIdVfModule(execution);
274 verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
275 assertEquals("newHeatStackId", vfModule.getHeatStackId());
279 public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
280 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
282 expectedException.expect(BpmnError.class);
284 aaiUpdateTasks.updateHeatStackIdVfModule(execution);
288 public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
289 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
291 aaiUpdateTasks.updateOrchestrationStatusActiveVolumeGroup(execution);
293 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ACTIVE);
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);
304 public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
305 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
307 aaiUpdateTasks.updateOrchestrationStatusCreatedVolumeGroup(execution);
309 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.CREATED);
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);
320 public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
321 doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
323 aaiUpdateTasks.updateOrchestrationStatusAssignedVolumeGroup(execution);
325 verify(aaiVolumeGroupResources, times(1)).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion, OrchestrationStatus.ASSIGNED);
326 assertEquals("", volumeGroup.getHeatStackId());
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);
336 public void updateHeatStackIdVolumeGroupTest() throws Exception {
337 execution.setVariable("heatStackId", "newHeatStackId");
338 doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
340 aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
342 verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
343 assertEquals("newHeatStackId", volumeGroup.getHeatStackId());
347 public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
348 expectedException.expect(BpmnError.class);
349 doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
350 aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
354 public void updateNetworkExceptionTest() throws Exception {
355 expectedException.expect(BpmnError.class);
357 doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
359 aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE);
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());
370 public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
371 expectedException.expect(BpmnError.class);
372 doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
373 aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
377 public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
378 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
380 aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
382 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
386 public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
387 doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ACTIVE);
389 expectedException.expect(BpmnError.class);
391 aaiUpdateTasks.updateOrchestrationStatusActivateVfModule(execution);
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);
403 network.getSubnets().add(subnet);
405 execution.setVariable("createNetworkResponse", createNetworkResponse);
407 doNothing().when(aaiNetworkResources).updateNetwork(network);
408 doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
410 aaiUpdateTasks.updateNetworkCreated(execution);
411 verify(aaiNetworkResources, times(1)).updateNetwork(network);
412 verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
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());
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);
435 public void updateNetworkAAITest() {
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();
444 doNothing().when(aaiNetworkResources).updateNetwork(network);
445 doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
447 spy.getSubnets().add(mockSubnet);
448 aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
450 verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
451 verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
452 verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
455 public void updateNetworkCreatedkExceptionTest() throws Exception {
456 expectedException.expect(BpmnError.class);
457 doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
458 aaiUpdateTasks.updateNetworkCreated(execution);
462 public void updateObjectNetworkTest() {
463 doNothing().when(aaiNetworkResources).updateNetwork(network);
465 aaiUpdateTasks.updateObjectNetwork(execution);
467 verify(aaiNetworkResources, times(1)).updateNetwork(network);
471 public void updateObjectNetworkExceptionText() {
472 expectedException.expect(BpmnError.class);
474 doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
476 aaiUpdateTasks.updateObjectNetwork(execution);
480 public void test_updateServiceInstance() {
481 doNothing().when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
482 aaiUpdateTasks.updateServiceInstance(execution);
483 verify(aaiServiceInstanceResources, times(1)).updateServiceInstance(serviceInstance);
487 public void test_updateServiceInstance_exception() {
488 expectedException.expect(BpmnError.class);
489 doThrow(RuntimeException.class).when(aaiServiceInstanceResources).updateServiceInstance(serviceInstance);
490 aaiUpdateTasks.updateServiceInstance(execution);
494 public void updateObjectVnfTest() {
495 doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
497 aaiUpdateTasks.updateObjectVnf(execution);
499 verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
503 public void updateObjectVnfExceptionTest() {
504 expectedException.expect(BpmnError.class);
505 doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(genericVnf);
506 aaiUpdateTasks.updateObjectVnf(execution);
510 public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
511 doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
513 aaiUpdateTasks.updateOrchestrationStatusDeleteVfModule(execution);
515 verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED);
516 assertEquals("", vfModule.getHeatStackId());
520 public void updateModelVfModuleTest() {
521 doNothing().when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
522 aaiUpdateTasks.updateModelVfModule(execution);
523 verify(aaiVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf);
527 public void updateModelVfModuleExceptionTest() {
528 expectedException.expect(BpmnError.class);
529 doThrow(RuntimeException.class).when(aaiVfModuleResources).changeAssignVfModule(vfModule, genericVnf);
530 aaiUpdateTasks.updateModelVfModule(execution);
534 public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
535 gBBInput = execution.getGeneralBuildingBlock();
536 doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
538 aaiUpdateTasks.updateOrchestrationStatusDeactivateFabricConfiguration(execution);
540 verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ASSIGNED);
543 public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
544 gBBInput = execution.getGeneralBuildingBlock();
545 doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
547 aaiUpdateTasks.updateOrchestrationStatusActivateFabricConfiguration(execution);
549 verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);