@Test
public void testComposeTry() {

    final AtomicInteger counter = new AtomicInteger(0);
    assertEquals("skip divide by 0 with no side effects",
            Arrays.asList(3, 4, 6, 12),
            Stream.of(4, 3, 2, 1, 0)
                    .flatMap(Util.composeTry(
                            Stream::of,
                            Stream::empty,
                            (value) -> 12 / value, null))
                    .collect(Collectors.toList()));
    assertEquals("skip divide by 0 with counter update as side effect",
            Arrays.asList(3, 4, 6, 12),
            Stream.of(4, 3, 2, 1, 0)
                    .flatMap(Util.composeTry(
                            Stream::of,
                            Stream::empty,
                            (value) -> 12 / value,
                            (element, error) -> counter.incrementAndGet()))
                    .collect(Collectors.toList()));
    assertEquals("counter should have incremented to 1", 1, counter.get());
}