Search in sources :

Example 1 with RemoveIpFromVmNicCmd

use of com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd 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();
}
Also used : NetworkService(com.cloud.network.NetworkService) RemoveIpFromVmNicCmd(com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Example 2 with RemoveIpFromVmNicCmd

use of com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd 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());
    }
}
Also used : SuccessResponse(com.cloud.api.response.SuccessResponse) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) NetworkService(com.cloud.network.NetworkService) RemoveIpFromVmNicCmd(com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Aggregations

RemoveIpFromVmNicCmd (com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd)2 NetworkService (com.cloud.network.NetworkService)2 Test (org.junit.Test)2 SuccessResponse (com.cloud.api.response.SuccessResponse)1 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)1