### Question:
BatchSpliterator implements Spliterator<T> { @Override public Spliterator<T> trySplit() { HoldingConsumer<T> holder = new HoldingConsumer<>(); if (tryAdvance(holder)) { Object[] a = new Object[batchSize]; int j = 0; do { a[j] = holder.value(); } while (++j < batchSize && tryAdvance(holder)); return Spliterators.spliterator(a, 0, j, characteristics()); } return null; } BatchSpliterator(Spliterator<T> spliterator, int batchSize); @Override boolean tryAdvance(Consumer<? super T> action); @Override Spliterator<T> trySplit(); @Override long estimateSize(); @Override int characteristics();  }### Answer:
@Test public void trySplit() { Spliterator<Integer> s; for (int i = 0; i < spliteratorSize / batchSize; i++) { s = spliterator.trySplit(); assertNotNull(s); assertEquals(s.estimateSize(), batchSize); } assertNotNull(spliterator); assertEquals(spliterator.trySplit().estimateSize(), spliteratorSize % batchSize); assertNull(spliterator.trySplit()); }