HostSetAvailabilityZoneStepCmd extends StepCommand { @Override protected void execute() throws HostSetAvailabilityZoneFailedException, HostNotFoundException { List<HostEntity> hostList = step.getTransientResourceEntities(Host.KIND); Preconditions.checkArgument(hostList.size() == 1); HostEntity hostEntity = hostList.get(0); hostBackend.updateAvailabilityZone(hostEntity); } HostSetAvailabilityZoneStepCmd(TaskCommand taskCommand,
                                        StepBackend stepBackend,
                                        StepEntity step,
                                        HostBackend hostBackend);   }
@Test public void testSuccess() throws InterruptedException, RpcException, ApiFeException { ProvisionResponse provisionResponse = new ProvisionResponse(); provisionResponse.setResult(ProvisionResultCode.OK); command.execute(); verify(hostBackend).updateAvailabilityZone(hostEntity); }
@Test(expectedExceptions = HostNotFoundException.class) public void testHostNotFound() throws RpcException, InterruptedException, ApiFeException { doThrow(new HostNotFoundException("HostNotFound")).when(hostBackend).updateAvailabilityZone(hostEntity); command.execute(); }