@Test
public void testLimit() throws Exception {

    DataGenerator<Long> genWithLimit = DataGenerator.range(0, 9).limit(2);
    DataGenerator<List<Long>> batchGen = genWithLimit.batch(2);
    assertThat(batchGen.getValue()).isEqualTo(asList(0L, 1L));
    assertThat(batchGen.apply().isClosed()).isTrue();
}