@Test
 public void testCountVmsOnHost() throws Throwable {
   HostEntity hostEntity = new HostEntity();
   hostEntity.setAddress(vm.host);
   hostEntity.setId(hostId);
   int countOfVmsOnHost = vmDcpBackend.countVmsOnHost(hostEntity);
   assertThat(countOfVmsOnHost, is(1));
 }
  @Test
  public void testHappy() throws Exception {
    EnterMaintenanceModeResponse response =
        new EnterMaintenanceModeResponse(
            new EnterMaintenanceModeResult(EnterMaintenanceModeResultCode.OK));
    when(deployerClient.enterSuspendedMode(hostEntity.getId())).thenReturn(response);

    command.execute();
    verify(deployerClient).enterSuspendedMode(hostEntity.getId());
    verify(hostBackend).updateState(hostEntity, HostState.SUSPENDED);
  }
  @Test(expectedExceptions = HostStateChangeException.class)
  public void testFailedHostExitMaintenanceMode() throws Exception {
    when(deployerClient.enterSuspendedMode(hostEntity.getId()))
        .thenThrow(new RpcException("Test Rpc Exception"));

    command.execute();
  }
  @Test(expectedExceptions = HostStateChangeException.class)
  public void testHostInvalid() throws Exception {
    when(deployerClient.enterSuspendedMode(hostEntity.getId()))
        .thenThrow(new HostNotFoundException("Error"));
    doNothing().when(hostBackend).updateState(hostEntity, HostState.SUSPENDED);

    command.execute();
  }
  @BeforeMethod
  public void setUp() {
    taskCommand = mock(TaskCommand.class);
    stepBackend = mock(StepBackend.class);
    hostBackend = mock(HostBackend.class);
    deployerClient = mock(DeployerClient.class);

    hostEntity = new HostEntity();
    hostEntity.setId("host-1");
    hostEntity.setUsername("username");
    hostEntity.setPassword("password");
    hostEntity.setAddress("192.168.0.1");
    hostEntity.setUsageTags(UsageTag.MGMT.toString());

    step = new StepEntity();
    step.setId("step-1");
    step.addResource(hostEntity);

    command = new HostEnterSuspendedModeStepCmd(taskCommand, stepBackend, step, hostBackend);
    when(taskCommand.getDeployerClient()).thenReturn(deployerClient);
  }