@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(); }
@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); }