ExecutorDao { public void updateExecutor(final Executor executor) throws ExecutorManagerException { final String UPDATE = "UPDATE executors SET host=?, port=?, active=? where id=?"; try { final int rows = this.dbOperator.update(UPDATE, executor.getHost(), executor.getPort(), executor.isActive(), executor.getId()); if (rows == 0) { throw new ExecutorManagerException("No executor with id :" + executor.getId()); } } catch (final SQLException e) { throw new ExecutorManagerException("Error inactivating executor " + executor.getId(), e); } } @Inject  ExecutorDao(final DatabaseOperator dbOperator); Executor fetchExecutor(final String host, final int port); Executor fetchExecutor(final int executorId); void updateExecutor(final Executor executor);  }
@Test public void testMissingExecutorUpdate() throws Exception { final Executor executor = new Executor(1, "localhost", 1234, true); assertThatThrownBy(() -> this.executorDao.updateExecutor(executor)) .isInstanceOf(ExecutorManagerException.class) .hasMessageContaining("No executor with id"); }