import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
-import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAICollectionResources;
+import org.onap.so.client.orchestration.AAIConfigurationResources;
+import org.onap.so.client.orchestration.AAINetworkResources;
+import org.onap.so.client.orchestration.AAIPnfResources;
+import org.onap.so.client.orchestration.AAIServiceInstanceResources;
+import org.onap.so.client.orchestration.AAIVfModuleResources;
+import org.onap.so.client.orchestration.AAIVnfResources;
+import org.onap.so.client.orchestration.AAIVolumeGroupResources;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-public class AAIUpdateTasksTest extends BaseTaskTest {
-
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAIUpdateTasksTest extends TestDataSetup {
+
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Mock
+ protected AAIPnfResources aaiPnfResources;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected AAIVfModuleResources aaiVfModuleResources;
+ @Mock
+ protected AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Mock
+ protected AAINetworkResources aaiNetworkResources;
+ @Mock
+ protected AAICollectionResources aaiCollectionResources;
+ @Mock
+ protected AAIConfigurationResources aaiConfigurationResources;
@InjectMocks
private AAIUpdateTasks aaiUpdateTasks = new AAIUpdateTasks();
}
@Test
- public void updateOrchestrationStatusAssignedServiceTest() throws Exception {
+ public void updateOrchestrationStatusAssignedServiceTest() {
doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateOrchestrationStatusAssignedServiceExceptionTest() throws Exception {
+ public void updateOrchestrationStatusAssignedServiceExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
}
@Test
- public void updateOrchestrationStatusActiveServiceTest() throws Exception {
+ public void updateOrchestrationStatusActiveServiceTest() {
doNothing().when(aaiServiceInstanceResources).updateOrchestrationStatusServiceInstance(serviceInstance,
OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusActiveServiceExceptionTest() throws Exception {
+ public void updateOrchestrationStatusActiveServiceExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiServiceInstanceResources)
}
@Test
- public void updateOrchestrationStatusAssignedVnfTest() throws Exception {
+ public void updateOrchestrationStatusAssignedVnfTest() {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED);
aaiUpdateTasks.updateOrchestrationStatusAssignedVnf(execution);
}
@Test
- public void updateOrchestrationStatusAssignedVnfExceptionTest() throws Exception {
+ public void updateOrchestrationStatusAssignedVnfExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
}
@Test
- public void updateOrchestrationStatusActiveVnfTest() throws Exception {
+ public void updateOrchestrationStatusActiveVnfTest() {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ACTIVE);
aaiUpdateTasks.updateOrchestrationStatusActiveVnf(execution);
}
@Test
- public void updateOrchestrationStatusActiveVnfExceptionTest() throws Exception {
+ public void updateOrchestrationStatusActiveVnfExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf,
}
@Test
- public void updateOrchestrationStatusAssignVfModuleTest() throws Exception {
+ public void updateOrchestrationStatusAssignVfModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.ASSIGNED);
aaiUpdateTasks.updateOrchestrationStatusAssignedVfModule(execution);
}
@Test
- public void updateOrchestrationStatusAssignVfModuleExceptionTest() throws Exception {
+ public void updateOrchestrationStatusAssignVfModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
genericVnf, OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateOrchestrationStatusCreatedVfModuleTest() throws Exception {
+ public void updateOrchestrationStatusCreatedVfModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CREATED);
aaiUpdateTasks.updateOrchestrationStatusCreatedVfModule(execution);
}
@Test
- public void updateOrchestrationStatusCreatedVfModuleExceptionTest() throws Exception {
+ public void updateOrchestrationStatusCreatedVfModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
genericVnf, OrchestrationStatus.CREATED);
}
@Test
- public void updateOrchestrationStatusPendingActivatefModuleTest() throws Exception {
+ public void updateOrchestrationStatusPendingActivatefModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.PENDING_ACTIVATION);
}
@Test
- public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() throws Exception {
+ public void updateOrchestrationStatusPendingActivatefModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
genericVnf, OrchestrationStatus.PENDING_ACTIVATION);
}
@Test
- public void updateOrchestrationStatusDectivateVfModuleTest() throws Exception {
+ public void updateOrchestrationStatusDectivateVfModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CREATED);
}
@Test
- public void updateOrchestrationStatusDectivateVfModuleExceptionTest() throws Exception {
+ public void updateOrchestrationStatusDectivateVfModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
genericVnf, OrchestrationStatus.CREATED);
}
@Test
- public void updateHeatStackIdVfModuleTest() throws Exception {
+ public void updateHeatStackIdVfModuleTest() {
execution.setVariable("heatStackId", "newHeatStackId");
doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
}
@Test
- public void updateHeatStackIdVfModuleToNullTest() throws Exception {
+ public void updateHeatStackIdVfModuleToNullTest() {
execution.setVariable("heatStackId", null);
doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
aaiUpdateTasks.updateHeatStackIdVfModule(execution);
verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf);
- assertEquals(vfModule.getHeatStackId(), "");
+ assertEquals("", vfModule.getHeatStackId());
}
@Test
- public void updateHeatStackIdVfModuleExceptionTest() throws Exception {
+ public void updateHeatStackIdVfModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf);
expectedException.expect(BpmnError.class);
}
@Test
- public void updateOrchestrationStatusActiveVolumeGroupTest() throws Exception {
+ public void updateOrchestrationStatusActiveVolumeGroupTest() {
doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() throws Exception {
+ public void updateOrchestrationStatusActiveVolumeGroupExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
cloudRegion, OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusCreatedVolumeGroupTest() throws Exception {
+ public void updateOrchestrationStatusCreatedVolumeGroupTest() {
doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
OrchestrationStatus.CREATED);
}
@Test
- public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() throws Exception {
+ public void updateOrchestrationStatusCreatedVolumeGroupExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
cloudRegion, OrchestrationStatus.CREATED);
}
@Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup() throws Exception {
+ public void test_updateOrchestrationStatusAssignedVolumeGroup() {
doNothing().when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
OrchestrationStatus.ASSIGNED);
}
@Test
- public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() throws Exception {
+ public void test_updateOrchestrationStatusAssignedVolumeGroup_exception() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateOrchestrationStatusVolumeGroup(volumeGroup,
cloudRegion, OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateHeatStackIdVolumeGroupTest() throws Exception {
+ public void updateHeatStackIdVolumeGroupTest() {
execution.setVariable("heatStackId", "newHeatStackId");
doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
}
@Test
- public void updateHeatStackIdVolumeGroupToNullTest() throws Exception {
+ public void updateHeatStackIdVolumeGroupToNullTest() {
execution.setVariable("heatStackId", null);
doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution);
verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
- assertEquals(volumeGroup.getHeatStackId(), "");
+ assertEquals("", volumeGroup.getHeatStackId());
}
@Test
- public void updateHeatStackIdVolumeGroupExceptionTest() throws Exception {
+ public void updateHeatStackIdVolumeGroupExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup,
cloudRegion);
}
@Test
- public void updateNetworkExceptionTest() throws Exception {
+ public void updateNetworkExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiNetworkResources).updateNetwork(network);
}
@Test
- public void updateOstatusActivedNetworkCollectionTest() throws Exception {
+ public void updateOstatusActivedNetworkCollectionTest() {
doNothing().when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
verify(aaiCollectionResources, times(1)).updateCollection(serviceInstance.getCollection());
}
@Test
- public void updateOstatusActiveNetworkColectionExceptionTest() throws Exception {
+ public void updateOstatusActiveNetworkColectionExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiCollectionResources).updateCollection(serviceInstance.getCollection());
aaiUpdateTasks.updateOrchestrationStatusActiveNetworkCollection(execution);
}
@Test
- public void updateOrchestrationStatusActivateVfModuleTest() throws Exception {
+ public void updateOrchestrationStatusActivateVfModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusActivateVfModuleExceptionTest() throws Exception {
+ public void updateOrchestrationStatusActivateVfModuleExceptionTest() {
doThrow(RuntimeException.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule,
genericVnf, OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusDeleteVfModuleTest() throws Exception {
+ public void updateOrchestrationStatusDeleteVfModuleTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateOrchestrationStatusDeactivateFabricConfigurationTest() throws Exception {
+ public void updateOrchestrationStatusDeactivateFabricConfigurationTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateOrchestrationStatusActivateFabricConfigurationTest() throws Exception {
+ public void updateOrchestrationStatusActivateFabricConfigurationTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
OrchestrationStatus.ACTIVE);
}
@Test
- public void updateOrchestrationStatusAssignedFabricConfigurationTest() throws Exception {
+ public void updateOrchestrationStatusAssignedFabricConfigurationTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).updateOrchestrationStatusConfiguration(configuration,
OrchestrationStatus.ASSIGNED);
}
@Test
- public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ public void updateContrailServiceInstanceFqdnVfModuleTest() {
execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
}
@Test
- public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
+ public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() {
aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
}
@Test
- public void updateIpv4OamAddressVnfTest() throws Exception {
+ public void updateIpv4OamAddressVnfTest() {
execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
}
@Test
- public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
+ public void updateIpv4OamAddressVnfNoUpdateTest() {
aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
}
@Test
- public void updateManagementV6AddressVnfTest() throws Exception {
+ public void updateManagementV6AddressVnfTest() {
execution.setVariable("oamManagementV6Address", "newManagementV6Address");
doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
}
@Test
- public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
+ public void updateManagementV6AddressVnfNoUpdateTest() {
aaiUpdateTasks.updateManagementV6AddressVnf(execution);
verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
}
@Test
- public void updateOrchestrationStatusVnfConfigureTest() throws Exception {
+ public void updateOrchestrationStatusVnfConfigureTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CONFIGURE);
}
@Test
- public void updateOrchestrationStatusVnfConfiguredTest() throws Exception {
+ public void updateOrchestrationStatusVnfConfiguredTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CONFIGURED);
}
@Test
- public void updateOrchestrationStatusVnfConfigAssignedTest() throws Exception {
+ public void updateOrchestrationStatusVnfConfigAssignedTest() {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGASSIGNED);
aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-assign");
}
@Test
- public void updateOrchestrationStatusVnfConfigDeployedTest() throws Exception {
+ public void updateOrchestrationStatusVnfConfigDeployedTest() {
doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.CONFIGDEPLOYED);
aaiUpdateTasks.updateOrchestrationStatus(execution, "vnf", "config-deploy");
}
@Test
- public void updateOrchestrationStatusVfModuleConfigDeployedTest() throws Exception {
+ public void updateOrchestrationStatusVfModuleConfigDeployedTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CONFIGDEPLOYED);
aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-deploy");
}
@Test
- public void updateOrchestrationStatusVfModuleConfigAssignedTest() throws Exception {
+ public void updateOrchestrationStatusVfModuleConfigAssignedTest() {
doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf,
OrchestrationStatus.CONFIGASSIGNED);
aaiUpdateTasks.updateOrchestrationStatus(execution, "vfmodule", "config-assign");