Search in sources :

Example 1 with SimpleReactStream

use of com.oath.cyclops.types.futurestream.SimpleReactStream in project cyclops by aol.

the class TakeSkipSliceTest method testZipWithFutures.

@Test
public void testZipWithFutures() {
    SimpleReactStream stream = of("a", "b");
    List<Tuple2<Integer, String>> result = of(1, 2).zip(stream).block();
    assertThat(result.size(), is(asList(tuple(1, "a"), tuple(2, "b")).size()));
}
Also used : Tuple2(cyclops.data.tuple.Tuple2) BaseSimpleReactStream(com.oath.cyclops.types.futurestream.BaseSimpleReactStream) SimpleReactStream(com.oath.cyclops.types.futurestream.SimpleReactStream) Test(org.junit.Test)

Example 2 with SimpleReactStream

use of com.oath.cyclops.types.futurestream.SimpleReactStream in project cyclops by aol.

the class BlockingTest method testFirstSimple.

@Test
public void testFirstSimple() throws InterruptedException, ExecutionException {
    SimpleReactStream<Integer> stage = new SimpleReact().<Integer>ofAsync(() -> 1, () -> 2, () -> 3, () -> 5).then(it -> it * 100).then(it -> sleep(it));
    int result = stage.block().firstValue(null);
    assertThat(result, is(100));
    stage.block();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) SimpleReactStream(com.oath.cyclops.types.futurestream.SimpleReactStream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleReact(cyclops.futurestream.SimpleReact) Set(java.util.Set) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SimpleReact(cyclops.futurestream.SimpleReact) Test(org.junit.Test)

Aggregations

SimpleReactStream (com.oath.cyclops.types.futurestream.SimpleReactStream)2 Test (org.junit.Test)2 BaseSimpleReactStream (com.oath.cyclops.types.futurestream.BaseSimpleReactStream)1 Tuple2 (cyclops.data.tuple.Tuple2)1 SimpleReact (cyclops.futurestream.SimpleReact)1 List (java.util.List)1 Set (java.util.Set)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 Matchers.greaterThan (org.hamcrest.Matchers.greaterThan)1 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)1 Matchers.is (org.hamcrest.Matchers.is)1 Assert.assertThat (org.junit.Assert.assertThat)1