@Test
public void when_oneElement() {

  assertThat(Stream.of(1).collect(when(i -> i + 1))).hasValue(2);
  assertThat(Stream.of(1, 2).collect(when(i -> i + 1))).isEmpty();
  assertThat(Stream.of(1).collect(when(x -> x == 1, i -> i + 1))).hasValue(2);
  assertThat(Stream.of(1).collect(when(x -> x == 2, i -> i + 1))).isEmpty();
}