ResultSet implements Iterable<Result> { public boolean allItemsAvailable() { return readCompleted.isDone(); } ResultSet(final ResultQueue resultQueue, final ExecutorService executor,
                     final CompletableFuture<Void> readCompleted, final RequestMessage originalRequestMessage,
                     final Host host); RequestMessage getOriginalRequestMessage(); Host getHost(); CompletableFuture<Map<String,Object>> statusAttributes(); boolean allItemsAvailable(); CompletableFuture<Void> allItemsAvailableAsync(); int getAvailableItemCount(); Result one(); CompletableFuture<List<Result>> some(final int items); CompletableFuture<List<Result>> all(); Stream<Result> stream(); @Override Iterator<Result> iterator();  }
@Test public void shouldHaveAllItemsAvailableOnReadComplete() { assertThat(resultSet.allItemsAvailable(), is(false)); readCompleted.complete(null); assertThat(resultSet.allItemsAvailable(), is(true)); }
@Test public void shouldHaveAllItemsAvailableOnReadCompleteWhileLoading() throws Exception { assertThat(resultSet.allItemsAvailable(), is(false)); final AtomicBoolean atLeastOnce = new AtomicBoolean(false); addToQueue(1000, 1, true, true); while (!readCompleted.isDone()) { atLeastOnce.set(true); if (!atLeastOnce.get()) assertThat(resultSet.allItemsAvailable(), is(false)); } assertThat(atLeastOnce.get(), is(true)); assertThat(resultSet.allItemsAvailable(), is(true)); }