use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddIpToVmNicTest method testRemoveIpFromVmNicFailure.
@Test
public void testRemoveIpFromVmNicFailure() throws InsufficientAddressCapacityException {
final NetworkService networkService = Mockito.mock(NetworkService.class);
final RemoveIpFromVmNicCmd removeIpFromNic = Mockito.mock(RemoveIpFromVmNicCmd.class);
Mockito.when(networkService.releaseSecondaryIpFromNic(Matchers.anyInt())).thenReturn(false);
removeIpFromNic._networkService = networkService;
successResponseGenerator = Mockito.mock(SuccessResponse.class);
try {
removeIpFromNic.execute();
} catch (final InvalidParameterValueException exception) {
Assert.assertEquals("Failed to remove secondary ip address for the nic", exception.getLocalizedMessage());
}
}
use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkFailure.
@Test
public void testCreateProviderToPhysicalNetworkFailure() throws ResourceAllocationException {
final NetworkService networkService = Mockito.mock(NetworkService.class);
addNetworkServiceProviderCmd._networkService = networkService;
Mockito.when(networkService.addProviderToPhysicalNetwork(Matchers.anyLong(), Matchers.anyString(), Matchers.anyLong(), Matchers.anyList())).thenReturn(null);
try {
addNetworkServiceProviderCmd.create();
} catch (final ServerApiException exception) {
Assert.assertEquals("Failed to add service provider entity to physical network", exception.getDescription());
}
}
use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddIpToVmNicTest method testCreateSuccess.
@Test
public void testCreateSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
final NetworkService networkService = Mockito.mock(NetworkService.class);
final AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
final NicSecondaryIp secIp = Mockito.mock(NicSecondaryIp.class);
Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.anyString())).thenReturn(secIp);
ipTonicCmd._networkService = networkService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
final NicSecondaryIpResponse ipres = Mockito.mock(NicSecondaryIpResponse.class);
Mockito.when(responseGenerator.createSecondaryIPToNicResponse(secIp)).thenReturn(ipres);
ipTonicCmd._responseGenerator = responseGenerator;
ipTonicCmd.execute();
}
use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkSuccess.
@Test
public void testCreateProviderToPhysicalNetworkSuccess() {
final NetworkService networkService = Mockito.mock(NetworkService.class);
addNetworkServiceProviderCmd._networkService = networkService;
final PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito.mock(PhysicalNetworkServiceProvider.class);
Mockito.when(networkService.addProviderToPhysicalNetwork(Matchers.anyLong(), Matchers.anyString(), Matchers.anyLong(), Matchers.anyList())).thenReturn(physicalNetworkServiceProvider);
try {
addNetworkServiceProviderCmd.create();
} catch (final ResourceAllocationException e) {
e.printStackTrace();
}
}
use of com.cloud.network.NetworkService in project cloudstack by apache.
the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkSuccess.
@Test
public void testCreateProviderToPhysicalNetworkSuccess() {
NetworkService networkService = Mockito.mock(NetworkService.class);
addNetworkServiceProviderCmd._networkService = networkService;
PhysicalNetworkServiceProvider physicalNetworkServiceProvider = Mockito.mock(PhysicalNetworkServiceProvider.class);
Mockito.when(networkService.addProviderToPhysicalNetwork(Matchers.anyLong(), Matchers.anyString(), Matchers.anyLong(), Matchers.anyList())).thenReturn(physicalNetworkServiceProvider);
try {
addNetworkServiceProviderCmd.create();
} catch (ResourceAllocationException e) {
e.printStackTrace();
}
}
Aggregations