use of com.cloud.network.NetworkService in project cloudstack by apache.
the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkFailure.
@Test
public void testCreateProviderToPhysicalNetworkFailure() throws ResourceAllocationException {
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 (ServerApiException exception) {
Assert.assertEquals("Failed to add service provider entity to physical network", exception.getDescription());
}
}
use of com.cloud.network.NetworkService in project cloudstack by apache.
the class AddIpToVmNicTest method testRemoveIpFromVmNicFailure.
@Test
public void testRemoveIpFromVmNicFailure() throws InsufficientAddressCapacityException {
NetworkService networkService = Mockito.mock(NetworkService.class);
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 (InvalidParameterValueException exception) {
Assert.assertEquals("Failed to remove secondary ip address for the nic", exception.getLocalizedMessage());
}
}
use of com.cloud.network.NetworkService in project cloudstack by apache.
the class AddIpToVmNicTest method testCreateFailure.
@Test
public void testCreateFailure() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
NetworkService networkService = Mockito.mock(NetworkService.class);
AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.any())).thenReturn(null);
ipTonicCmd._networkService = networkService;
try {
ipTonicCmd.execute();
} catch (InsufficientAddressCapacityException e) {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
}
use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddIpToVmNicTest method testRemoveIpFromVmNicSuccess.
@Test
public void testRemoveIpFromVmNicSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
final NetworkService networkService = Mockito.mock(NetworkService.class);
final RemoveIpFromVmNicCmd removeIpFromNic = Mockito.mock(RemoveIpFromVmNicCmd.class);
Mockito.when(networkService.releaseSecondaryIpFromNic(Matchers.anyInt())).thenReturn(true);
removeIpFromNic._networkService = networkService;
removeIpFromNic.execute();
}
use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.
the class AddIpToVmNicTest method testCreateFailure.
@Test
public void testCreateFailure() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
final NetworkService networkService = Mockito.mock(NetworkService.class);
final AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.anyString())).thenReturn(null);
ipTonicCmd._networkService = networkService;
try {
ipTonicCmd.execute();
} catch (final InsufficientAddressCapacityException e) {
throw new InvalidParameterValueException("Allocating guest ip for nic failed");
}
}
Aggregations