Search in sources :

Example 1 with LazyEither

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));
}
Also used : Arrays(java.util.Arrays) PersistentSet(com.oath.cyclops.types.persistent.PersistentSet) LazyEither(cyclops.control.LazyEither) Matchers.not(org.hamcrest.Matchers.not) Trampoline(cyclops.control.Trampoline) Monoids(cyclops.companion.Monoids) HashSet(cyclops.data.HashSet) Future(cyclops.control.Future) Seq(cyclops.data.Seq) StreamSupport(java.util.stream.StreamSupport) Semigroups(cyclops.companion.Semigroups) NoSuchElementException(java.util.NoSuchElementException) Before(org.junit.Before) Maybe(cyclops.control.Maybe) cyclops.control(cyclops.control) Spouts(cyclops.reactive.Spouts) Streams(cyclops.companion.Streams) CompletableEither(cyclops.control.LazyEither.CompletableEither) Monoid(cyclops.function.Monoid) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReactiveSeq(cyclops.reactive.ReactiveSeq) Mutable(com.oath.cyclops.util.box.Mutable) Stream(java.util.stream.Stream) Ignore(org.junit.Ignore) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Optional(java.util.Optional) Assert(org.junit.Assert) Reducers(cyclops.companion.Reducers) NoSuchElementException(java.util.NoSuchElementException) Test(org.junit.Test)

Aggregations

PersistentSet (com.oath.cyclops.types.persistent.PersistentSet)1 Mutable (com.oath.cyclops.util.box.Mutable)1 Monoids (cyclops.companion.Monoids)1 Reducers (cyclops.companion.Reducers)1 Semigroups (cyclops.companion.Semigroups)1 Streams (cyclops.companion.Streams)1 cyclops.control (cyclops.control)1 Future (cyclops.control.Future)1 LazyEither (cyclops.control.LazyEither)1 CompletableEither (cyclops.control.LazyEither.CompletableEither)1 Maybe (cyclops.control.Maybe)1 Trampoline (cyclops.control.Trampoline)1 HashSet (cyclops.data.HashSet)1 Seq (cyclops.data.Seq)1 Monoid (cyclops.function.Monoid)1 ReactiveSeq (cyclops.reactive.ReactiveSeq)1 Spouts (cyclops.reactive.Spouts)1 Arrays (java.util.Arrays)1 NoSuchElementException (java.util.NoSuchElementException)1 Optional (java.util.Optional)1