use of cyclops.control.LazyEither in project cyclops by aol.
the class EitherTest method completableNoneTest.
@Test
public void completableNoneTest() {
CompletableEither<Integer, Integer> completable = LazyEither.either();
LazyEither<Throwable, Integer> mapped = completable.map(i -> i * 2).flatMap(i -> LazyEither.right(i + 1));
completable.completeExceptionally(new NoSuchElementException());
mapped.printOut();
assertThat(mapped.isPresent(), equalTo(false));
assertThat(mapped.leftOrElse(null), instanceOf(NoSuchElementException.class));
}
Aggregations