### Question:
PagingSpliterator extends Spliterators.AbstractSpliterator<T> { PagingSpliterator(final Function<Paging, List<T>> fetchPageFunction) { super(Long.MAX_VALUE, 0); currentPage = Paging.at(0, FETCH_SIZE_DEFAULT); this.fetchPage = fetchPageFunction; loadPage(); } PagingSpliterator(final Function<Paging, List<T>> fetchPageFunction); @Override boolean tryAdvance(final Consumer<? super T> action);  }### Answer:
@Test public void testPagingSpliterator() { PagingSpliterator<Integer> integerPagingSpliterator = new PagingSpliterator<>( paging -> { List<Integer> data; if (paging.getOffset() < 100) { data = IntStream.range(paging.getOffset(), paging.getOffset() + paging.getLimit()) .boxed() .collect(Collectors.toList()); if (data.size() > paging.getLimit()) { throw new IllegalStateException(); } } else { data = Collections.emptyList(); } return data; } ); List<Integer> actual = StreamSupport.stream(integerPagingSpliterator, false) .collect(Collectors.toList()); List<Integer> expected = IntStream.range(0, 128) .boxed() .collect(Collectors.toList()); assertThat(actual, is(expected)); }