Source:
public void testGetFirstPage() { BatchingVisitable<Long> visitor = ListVisitor.create(Lists.newArrayList(0L, 1L, 2L, 3L)); TokenBackedBasicResultsPage<Long, Long> page = BatchingVisitables.getFirstPage(visitor, 0); assertEquals("anonymous assert 6BC9FC", 0, page.getResults().size()); assertEquals("anonymous assert 7EBA34", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 1); assertEquals("anonymous assert 1B3BD6", 1, page.getResults().size()); assertEquals("anonymous assert BDAB68", Lists.newArrayList(0L), page.getResults()); assertEquals("anonymous assert F4E06A", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 3); assertEquals("anonymous assert 87CB3C", 3, page.getResults().size()); assertEquals("anonymous assert 0AB14A", Lists.newArrayList(0L, 1L, 2L), page.getResults()); assertEquals("anonymous assert 178C51", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 4); assertEquals("anonymous assert 6215D2", 4, page.getResults().size()); assertEquals("anonymous assert C1D8C0", Lists.newArrayList(0L, 1L, 2L, 3L), page.getResults()); assertEquals("anonymous assert 91F5FF", false, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 7); assertEquals("anonymous assert 77AABC", 4, page.getResults().size()); assertEquals("anonymous assert E250DA", Lists.newArrayList(0L, 1L, 2L, 3L), page.getResults()); assertEquals("anonymous assert 516AA9", false, page.moreResultsAvailable()); try { BatchingVisitables.getFirstPage(visitor, -1); fail("Should not allow visiting -1 elements."); } catch (IllegalArgumentException e) { } }

Target:
public void testGetFirstPage() { BatchingVisitable<Long> visitor = ListVisitor.create(Lists.newArrayList(0L, 1L, 2L, 3L)); TokenBackedBasicResultsPage<Long, Long> page = BatchingVisitables.getFirstPage(visitor, 0); assertEquals("page results had wrong size!", 0, page.getResults().size()); assertEquals("page.moreResultsAvailable was wrong", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 1); assertEquals("page results had wrong size!", 1, page.getResults().size()); assertEquals("page.getResults was wrong", Lists.newArrayList(0L), page.getResults()); assertEquals("page.moreResultsAvailable was wrong", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 3); assertEquals("page results had wrong size!", 3, page.getResults().size()); assertEquals("page.getResults was wrong", Lists.newArrayList(0L, 1L, 2L), page.getResults()); assertEquals("page.moreResultsAvailable was wrong", true, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 4); assertEquals("page results had wrong size!", 4, page.getResults().size()); assertEquals("page.getResults was wrong", Lists.newArrayList(0L, 1L, 2L, 3L), page.getResults()); assertEquals("page.moreResultsAvailable was wrong", false, page.moreResultsAvailable()); page = BatchingVisitables.getFirstPage(visitor, 7); assertEquals("page results had wrong size!", 4, page.getResults().size()); assertEquals("page.getResults was wrong", Lists.newArrayList(0L, 1L, 2L, 3L), page.getResults()); assertEquals("page.moreResultsAvailable was wrong", false, page.moreResultsAvailable()); try { BatchingVisitables.getFirstPage(visitor, -1); fail("Should not allow visiting -1 elements."); } catch (IllegalArgumentException e) { } }