@Test public void shouldCollectFromEmptyStream() { final ListResult<Object> collected = Stream.of().collect(ListResult.collector()).build(); assertThat(collected).isNotNull(); assertThat(collected.getItems()).isEmpty(); }
@Test public void shouldCollectFromStreamWithSomeElements() { final ListResult<String> collected = IntStream.range(1, 11).mapToObj(String::valueOf) .collect(ListResult.collector()).build(); assertThat(collected).isNotNull(); assertThat(collected.getItems()).containsExactly("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"); } }
@Test public void shouldCollectFromSingletonStream() { final ListResult<String> collected = Stream.of("item").collect(ListResult.collector()).build(); assertThat(collected).isNotNull(); assertThat(collected.getItems()).containsExactly("item"); }