VM.Record vmr = mock(VM.Record.class);
when(vm.getRecord(conn)).thenThrow(new XmlRpcException("XmlRpcException"));
when(vm.getRecord(conn)).thenReturn(vmr);
vmr.powerState = Types.VmPowerState.RUNNING;
vmr.residentOn = mock(Host.class);
XenAPIObject object = mock(XenAPIObject.class);
doReturn(new String("OpaqueRef:NULL")).when(object).toWireString();
doNothing().when(_resource).scaleVM(conn, vm, vmSpec, host);
_resource.execute(cmd);
verify(iter, times(2)).hasNext();