@Test
public void testUnion() throws Exception {

    List<String> words = asList("a", "b", "c", "d", "e");
    DataGenerator<List<String>> batchGen = DataGenerator.union(
            DataGenerator.items(words),
            DataGenerator.range(0, 5),
            (t, n) -> t + '-' + n
    ).batch(25);
    List<String> data = batchGen.getValue();
    data.sort(Comparator.naturalOrder());
    List<String> expected = words.stream().flatMap(w -> {
        List<String> items = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            items.add(w + '-' + i);
        }
        return items.stream();
    }).collect(Collectors.toList());
    assertThat(data).containsAll(expected);
    assertThat(batchGen.apply().isClosed()).isTrue();
}