@Test public void shouldThrowNoSuchElementWhenReadingPastEnd() throws IOException { ElasticSearchClient client = Mockito.mock(ElasticSearchClient.class); ElasticSearchResponse initialResponse = Mockito.mock(ElasticSearchResponse.class); int batchSize = 5; String scrollId = "testScrollId"; List<RawQuery.Result<String>> initialResults = makeTestResults(batchSize-1); setupResultMocks(initialResults, initialResponse, scrollId); ElasticSearchScroll scroll = new ElasticSearchScroll(client, initialResponse, batchSize); for(int i=0; i<batchSize-1; i++){ scroll.next(); } Assertions.assertThrows(NoSuchElementException.class, scroll::next); }
@Override public Result<String> next() { if (hasNext()) { return queue.remove(); } throw new NoSuchElementException(); }
ElasticSearchScroll implements Iterator<RawQuery.Result<String>> { @Override public Result<String> next() { if (hasNext()) { return queue.remove(); } throw new NoSuchElementException(); } }
ElasticSearchScroll implements Iterator<RawQuery.Result<String>> { @Override public Result<String> next() { if (hasNext()) { return queue.remove(); } throw new NoSuchElementException(); } ElasticSearchScroll(ElasticSearchClient client, ElasticSearchResponse initialResponse, int nbDocByQuery); }
ElasticSearchScroll implements Iterator<RawQuery.Result<String>> { @Override public Result<String> next() { if (hasNext()) { return queue.remove(); } throw new NoSuchElementException(); } ElasticSearchScroll(ElasticSearchClient client, ElasticSearchResponse initialResponse, int nbDocByQuery); @Override boolean hasNext(); @Override Result<String> next(); }
ElasticSearchScroll implements Iterator<RawQuery.Result<String>> { @Override public Result<String> next() { if (hasNext()) { return queue.remove(); } throw new NoSuchElementException(); } ElasticSearchScroll(ElasticSearchClient client, ElasticSearchResponse initialResponse, int nbDocByQuery); @Override boolean hasNext(); @Override Result<String> next();  }