use of com.cloud.agent.api.NetworkRulesVmSecondaryIpCommand in project cloudstack by apache.
the class LibvirtComputingResourceTest method testNetworkRulesVmSecondaryIpCommandFailure.
@SuppressWarnings("unchecked")
@Test
public void testNetworkRulesVmSecondaryIpCommandFailure() {
final String vmName = "Test";
final String vmMac = "00:00:00:00";
final String secondaryIp = "127.0.0.1";
final boolean action = true;
final NetworkRulesVmSecondaryIpCommand command = new NetworkRulesVmSecondaryIpCommand(vmName, vmMac, secondaryIp, action);
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
try {
when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class);
} catch (final LibvirtException e) {
fail(e.getMessage());
}
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, libvirtComputingResource);
assertFalse(answer.getResult());
try {
verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName());
} catch (final LibvirtException e) {
fail(e.getMessage());
}
verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
}
Aggregations