Search in sources :

Example 21 with FutureStream

use of cyclops.futurestream.FutureStream in project cyclops by aol.

the class LazySeqTest method testZipWithFuturesStream.

@Test
public void testZipWithFuturesStream() {
    Stream stream = of("a", "b");
    FutureStream<Tuple2<Integer, String>> seq = of(1, 2).actOnFutures().zip(stream);
    // .map(tuple -> Tuple.tuple(tuple.v1.join(),tuple.v2)).collect(CyclopsCollectors.toList());
    List<Tuple2<Integer, String>> result = seq.block();
    assertThat(result.size(), is(asList(tuple(1, "a"), tuple(2, "b")).size()));
}
Also used : Tuple2(cyclops.data.tuple.Tuple2) FutureStream(cyclops.futurestream.FutureStream) Stream(java.util.stream.Stream) BaseSeqTest(cyclops.futurestream.react.base.BaseSeqTest) Test(org.junit.Test)

Example 22 with FutureStream

use of cyclops.futurestream.FutureStream in project cyclops by aol.

the class LazySeqTest method testZipWithFutures.

@Test
public void testZipWithFutures() {
    FutureStream stream = of("a", "b");
    FutureStream<Tuple2<Integer, String>> seq = of(1, 2).actOnFutures().zip(stream);
    // .map(tuple -> Tuple.tuple(tuple.v1.join(),tuple.v2)).collect(CyclopsCollectors.toList());
    List<Tuple2<Integer, String>> result = seq.block();
    System.out.println(result);
    assertThat(result.size(), is(asList(tuple(1, "a"), tuple(2, "b")).size()));
}
Also used : Tuple2(cyclops.data.tuple.Tuple2) FutureStream(cyclops.futurestream.FutureStream) BaseSeqTest(cyclops.futurestream.react.base.BaseSeqTest) Test(org.junit.Test)

Example 23 with FutureStream

use of cyclops.futurestream.FutureStream in project cyclops by aol.

the class BaseSequentialSeqTest method asyncSyncTest.

@Test
public void asyncSyncTest() {
    FutureStream stream = of(1, 2, 3, 4).async().sync();
    assertThat(stream.isAsync(), is(false));
}
Also used : FutureStream(cyclops.futurestream.FutureStream) Test(org.junit.Test)

Example 24 with FutureStream

use of cyclops.futurestream.FutureStream in project cyclops by aol.

the class BaseSequentialSeqTest method syncAndAsyncTest.

@Test
public void syncAndAsyncTest() {
    FutureStream stream = of(1, 2, 3, 4).sync().async();
    assertThat(stream.isAsync(), is(true));
}
Also used : FutureStream(cyclops.futurestream.FutureStream) Test(org.junit.Test)

Example 25 with FutureStream

use of cyclops.futurestream.FutureStream in project cyclops by aol.

the class OperationsOnFuturesTest method testShuffleRandom.

@Test
public void testShuffleRandom() {
    Random r = new Random();
    Supplier<FutureStream<Integer>> s = () -> of(1, 2, 3);
    Assert.assertEquals(3, s.get().actOnFutures().shuffle(r).toList().size());
    assertThat(s.get().actOnFutures().shuffle(r).toList(), hasItems(1, 2, 3));
}
Also used : Random(java.util.Random) FutureStream(cyclops.futurestream.FutureStream) Test(org.junit.Test)

Aggregations

FutureStream (cyclops.futurestream.FutureStream)31 Test (org.junit.Test)27 Tuple2 (cyclops.data.tuple.Tuple2)19 Stream (java.util.stream.Stream)17 BaseSeqTest (cyclops.futurestream.react.base.BaseSeqTest)16 LazyReact (cyclops.futurestream.LazyReact)12 Queue (com.oath.cyclops.async.adapters.Queue)11 ReactiveSeq (cyclops.reactive.ReactiveSeq)11 Collectors (java.util.stream.Collectors)11 QueueFactories (com.oath.cyclops.async.QueueFactories)8 Collection (java.util.Collection)8 Signal (com.oath.cyclops.async.adapters.Signal)7 ThreadPools (com.oath.cyclops.react.ThreadPools)7 Tuple.tuple (cyclops.data.tuple.Tuple.tuple)7 Serializable (java.io.Serializable)7 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)6 ForkJoinPool (java.util.concurrent.ForkJoinPool)6 Matchers.is (org.hamcrest.Matchers.is)6 Ignore (org.junit.Ignore)6