ExecutorDao { List<Executor> fetchAllExecutors() throws ExecutorManagerException { try { return this.dbOperator .query(FetchExecutorHandler.FETCH_ALL_EXECUTORS, new FetchExecutorHandler()); } catch (final Exception e) { throw new ExecutorManagerException("Error fetching 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 testFetchEmptyExecutors() throws Exception { final List<Executor> executors = this.executorDao.fetchAllExecutors(); assertThat(executors.size()).isEqualTo(0); }
@Test public void testFetchAllExecutors() throws Exception { final List<Executor> executors = addTestExecutors(); executors.get(0).setActive(false); this.executorDao.updateExecutor(executors.get(0)); final List<Executor> fetchedExecutors = this.executorDao.fetchAllExecutors(); assertThat(executors.size()).isEqualTo(fetchedExecutors.size()); assertThat(executors.toArray()).isEqualTo(fetchedExecutors.toArray()); }