Search in sources :

Example 1 with RemoveIpFromVmNicCmd

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

Example 2 with RemoveIpFromVmNicCmd

use of org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd in project cloudstack by apache.

the class AddIpToVmNicTest method testRemoveIpFromVmNicSuccess.

@Test
public void testRemoveIpFromVmNicSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    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(org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Aggregations

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