ExecutorDao { List<Executor> fetchActiveExecutors() throws ExecutorManagerException { try { return this.dbOperator .query(FetchExecutorHandler.FETCH_ACTIVE_EXECUTORS, new FetchExecutorHandler()); } catch (final SQLException e) { throw new ExecutorManagerException("Error fetching active executors", 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 testFetchEmptyActiveExecutors() throws Exception { final List<Executor> executors = this.executorDao.fetchActiveExecutors(); assertThat(executors.size()).isEqualTo(0); }
@Test public void testFetchActiveExecutors() throws Exception { final List<Executor> executors = addTestExecutors(); executors.get(0).setActive(true); this.executorDao.updateExecutor(executors.get(0)); final List<Executor> fetchedExecutors = this.executorDao.fetchActiveExecutors(); assertThat(executors.size()).isEqualTo(fetchedExecutors.size() + 2); assertThat(executors.get(0)).isEqualTo(fetchedExecutors.get(0)); }