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");
import java.util.Optional;
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.junit.MockitoJUnitRunner;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.orchestration.NetworkAdapterResources;
-public class NetworkAdapterCreateTasksTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class NetworkAdapterCreateTasksTest extends TestDataSetup {
+
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
+ @Mock
+ protected NetworkAdapterResources networkAdapterResources;
@InjectMocks
private NetworkAdapterCreateTasks networkAdapterCreateTasks = new NetworkAdapterCreateTasks();
}
@Test
- public void createNetworkTest() throws Exception {
+ public void createNetworkTest() {
String cloudRegionPo = "cloudRegionPo";
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
execution.setVariable("cloudRegionPo", cloudRegionPo);
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.io.UnsupportedEncodingException;
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.junit.MockitoJUnitRunner;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-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.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.onap.so.client.adapter.network.NetworkAdapterClientException;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class NetworkAdapterDeleteTasksTest extends TestDataSetup {
-public class NetworkAdapterDeleteTasksTest extends BaseTaskTest {
-
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
@InjectMocks
private NetworkAdapterDeleteTasks networkAdapterDeleteTasks = new NetworkAdapterDeleteTasks();
}
@Test
- public void test_deleteNetwork() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ public void test_deleteNetwork() {
DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
doReturn(deleteNetworkRequest).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(requestContext,
cloudRegion, serviceInstance, l3Network);
}
@Test
- public void test_deleteNetwork_exception() throws UnsupportedEncodingException, NetworkAdapterClientException {
+ public void test_deleteNetwork_exception() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(networkAdapterObjectMapper).deleteNetworkRequestMapper(
import static org.junit.Assert.assertNotNull;
import javax.xml.bind.JAXBException;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.FileUtil;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-public class NetworkAdapterImplTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class NetworkAdapterImplTest extends TestDataSetup {
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
@InjectMocks
private NetworkAdapterImpl networkAdapterImpl = new NetworkAdapterImpl();
package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.io.UnsupportedEncodingException;
import java.util.Map;
-import java.util.Optional;
-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.onap.so.adapters.nwrest.CreateNetworkRequest;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
-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.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-import org.onap.so.client.adapter.network.NetworkAdapterClientException;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.exception.BBObjectNotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-public class NetworkAdapterUpdateTasksTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class NetworkAdapterUpdateTasksTest extends TestDataSetup {
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected NetworkAdapterObjectMapper networkAdapterObjectMapper;
@InjectMocks
private NetworkAdapterUpdateTasks networkAdapterUpdateTasks = new NetworkAdapterUpdateTasks();
}
@Test
- public void updateNetworkTest() throws Exception {
+ public void updateNetworkTest() {
String cloudRegionPo = "cloudRegionPo";
UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
execution.setVariable("cloudRegionPo", cloudRegionPo);
import static org.mockito.Mockito.when;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest;
-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.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.VnfAdapterVfModuleResources;
+import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-public class VnfAdapterCreateTasksTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class VnfAdapterCreateTasksTest extends TestDataSetup {
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
+ @Mock
+ protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
@InjectMocks
private VnfAdapterCreateTasks vnfAdapterCreateTasks = new VnfAdapterCreateTasks();
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.junit.MockitoJUnitRunner;
import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest;
-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.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
-
-public class VnfAdapterDeleteTasksTest extends BaseTaskTest {
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.VnfAdapterVfModuleResources;
+import org.onap.so.client.orchestration.VnfAdapterVolumeGroupResources;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class VnfAdapterDeleteTasksTest extends TestDataSetup {
+
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected VnfAdapterVfModuleResources vnfAdapterVfModuleResources;
+ @Mock
+ protected VnfAdapterVolumeGroupResources vnfAdapterVolumeGroupResources;
@InjectMocks
private VnfAdapterDeleteTasks vnfAdapterDeleteTasks = new VnfAdapterDeleteTasks();
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.junit.MockitoJUnitRunner;
import org.onap.so.FileUtil;
-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.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
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.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class VnfAdapterImplTest extends BaseTaskTest {
-
+import org.onap.so.client.exception.ExceptionBuilder;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class VnfAdapterImplTest extends TestDataSetup {
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
@InjectMocks
private VnfAdapterImpl vnfAdapterImpl = new VnfAdapterImpl();
execution.setVariable("WorkflowResponse", VNF_ADAPTER_REST_DELETE_RESPONSE);
vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(vfModule.getHeatStackId());
- assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
- assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
- assertEquals(genericVnf.getIpv4OamAddress(), "");
- assertEquals(execution.getVariable("oamManagementV4Address"), "");
- assertEquals(genericVnf.getManagementV6Address(), "");
- assertEquals(execution.getVariable("oamManagementV6Address"), "");
+ assertEquals("", vfModule.getContrailServiceInstanceFqdn());
+ assertEquals("", execution.getVariable("contrailServiceInstanceFqdn"));
+ assertEquals("", genericVnf.getIpv4OamAddress());
+ assertEquals("", execution.getVariable("oamManagementV4Address"));
+ assertEquals("", genericVnf.getManagementV6Address());
+ assertEquals("", execution.getVariable("oamManagementV6Address"));
assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
}
import java.util.ArrayList;
import java.util.Optional;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Vserver;
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.db.catalog.client.CatalogDbClient;
-public class AppcOrchestratorPreProcessorTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AppcOrchestratorPreProcessorTest extends TestDataSetup {
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected CatalogDbClient catalogDbClient;
@InjectMocks
private AppcOrchestratorPreProcessor appcOrchestratorPreProcessor = new AppcOrchestratorPreProcessor();
}
@Test
- public void addVmInfoToAppcTaskRequestTest() throws Exception {
+ public void addVmInfoToAppcTaskRequestTest() {
ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest();
ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf();
appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf);
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Vserver;
import org.onap.appc.client.lcm.model.Action;
-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.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.db.catalog.client.CatalogDbClient;
-public class AppcRunTasksTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AppcRunTasksTest extends TestDataSetup {
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
-
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+ @Mock
+ protected CatalogDbClient catalogDbClient;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected ApplicationControllerAction appCClient;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
@InjectMocks
private AppcRunTasks appcRunTasks = new AppcRunTasks();
}
@Test
- public void testUserParams() throws Exception {
+ public void testUserParams() {
Map<String, Object> userParams = new HashMap<String, Object>();
userParams.put("existing_software_version", "3.1");
userParams.put("new_software_version", "3.2");
import static org.apache.commons.lang3.StringUtils.*;
-import java.util.LinkedHashMap;
+import java.util.Map;
import org.json.JSONObject;
import org.onap.so.client.exception.BadResponseException;
import org.slf4j.Logger;
private static final Logger logger = LoggerFactory.getLogger(SniroValidator.class);
+ private static final String MESSAGE_NOT_PROVIDED = "error message not provided";
+
/**
* Validates the synchronous homing response from sniro manager
*
* @throws BadResponseException
*/
- public void validateDemandsResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
+ public void validateDemandsResponse(Map<String, Object> response) throws BadResponseException {
logger.debug("Validating Sniro Managers synchronous response");
if (!response.isEmpty()) {
JSONObject jsonResponse = new JSONObject(response);
} else {
String message = jsonResponse.getString("statusMessage");
if (isNotBlank(message)) {
- logger.debug("Sniro Managers response indicates failed: " + message);
+ logger.debug("Sniro Managers response indicates failed: {}", message);
} else {
logger.debug("Sniro Managers response indicates failed: no status message provided");
- message = "error message not provided";
+ message = MESSAGE_NOT_PROVIDED;
}
throw new BadResponseException("Sniro Managers synchronous response indicates failed: " + message);
}
}
} else {
logger.debug("Sniro Managers synchronous response is empty");
- throw new BadResponseException("Sniro Managers synchronous response i is empty");
+ throw new BadResponseException("Sniro Managers synchronous response is empty");
}
}
} else {
String message = jsonResponse.getJSONObject("serviceException").getString("text");
if (isNotBlank(message)) {
- logger.debug("Sniro Managers response contains a service exception: " + message);
+ logger.debug("Sniro Managers response contains a service exception: {}", message);
} else {
logger.debug(
"Sniro Managers response contains a service exception: no service exception text provided");
- message = "error message not provided";
+ message = MESSAGE_NOT_PROVIDED;
}
throw new BadResponseException(
"Sniro Managers asynchronous response contains a service exception: " + message);
*
* @throws BadResponseException
*/
- public void validateReleaseResponse(LinkedHashMap<String, Object> response) throws BadResponseException {
+ public void validateReleaseResponse(Map<String, Object> response) throws BadResponseException {
logger.debug("Validating Sniro Conductors response");
if (!response.isEmpty()) {
String status = (String) response.get("status");
} else {
String message = (String) response.get("message");
if (isNotBlank(message)) {
- logger.debug("Sniro Conductors response indicates failed: " + message);
+ logger.debug("Sniro Conductors response indicates failed: {}", message);
} else {
logger.debug("Sniro Conductors response indicates failed: error message not provided");
- message = "error message not provided";
+ message = MESSAGE_NOT_PROVIDED;
}
throw new BadResponseException(
"Sniro Conductors synchronous response indicates failed: " + message);
--- /dev/null
+package org.onap.so.client.sniro;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.so.client.exception.BadResponseException;
+
+public class SniroValidatorTest {
+
+ @Test
+ public void validateDemandsResponse_success() throws BadResponseException {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "accepted");
+ new SniroValidator().validateDemandsResponse(testMap);
+ }
+
+ @Test
+ public void validateDemandsResponse_emptyResponse() {
+ try {
+ new SniroValidator().validateDemandsResponse(new LinkedHashMap<>());
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response is empty");
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithErrorMessage() {
+ String message = "An error occurred";
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "not_accepted");
+ testMap.put("statusMessage", message);
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response indicates failed: " + message);
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithoutMessage() {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("requestStatus", "not_accepted");
+ testMap.put("statusMessage", "");
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("error message not provided");
+ }
+ }
+
+ @Test
+ public void validateDemandsResponse_responseWithoutRequestStatus() {
+ Map<String, Object> testMap = new LinkedHashMap<>();
+ testMap.put("statusMessage", "");
+ try {
+ new SniroValidator().validateDemandsResponse(testMap);
+ } catch (BadResponseException e) {
+ assertThat(e.getMessage()).contains("Sniro Managers synchronous response does not contain: request status");
+ }
+ }
+}