@Test
void batchedStreamOf() {

    Stream<Integer> sourceStream = IntStream.rangeClosed(1, 10)
            .boxed();
    List<List<Integer>> batches = BatchingIterator.batchedStreamOf(sourceStream, 3)
            .collect(Collectors.toList());
    assertThat(batches).hasSize(4);
    assertThat(batches.get(0)).containsExactly(1, 2, 3);
    assertThat(batches.get(1)).containsExactly(4, 5, 6);
    assertThat(batches.get(2)).containsExactly(7, 8, 9);
    assertThat(batches.get(3)).containsExactly(10);
}