Search in sources :

Example 6 with BaseSimpleReactStream

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

the class SimpleReactTest method streamParallelOf.

@Test
public void streamParallelOf() {
    BaseSimpleReactStream value = BaseSimpleReactStream.parallel(1, 2);
    assertThat(value.getTaskExecutor(), is(ForkJoinPool.commonPool()));
}
Also used : BaseSimpleReactStream(com.oath.cyclops.types.futurestream.BaseSimpleReactStream) Test(org.junit.Test)

Example 7 with BaseSimpleReactStream

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

the class SimpleReactTest method testSeparatedChains.

@Test
public void testSeparatedChains() {
    // .split(2);
    BaseSimpleReactStream<String> orgBuilder = new SimpleReact().ofAsync(() -> "Hello", () -> "World");
    BaseSimpleReactStream builder = orgBuilder;
    for (int i = 0; i < 1000; i++) {
        builder = builder.then(input -> input + " " + counter++);
    }
    List<String> results = orgBuilder.block();
    assertThat(results.get(0), is("Hello"));
    List<String> completeResults = builder.block();
    assertThat(completeResults.get(0).length(), greaterThan(100));
}
Also used : BaseSimpleReactStream(com.oath.cyclops.types.futurestream.BaseSimpleReactStream) Arrays(java.util.Arrays) LazyReact(cyclops.futurestream.LazyReact) Matchers(org.mockito.Matchers) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) BaseSimpleReactStream(com.oath.cyclops.types.futurestream.BaseSimpleReactStream) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Assert.assertThat(org.junit.Assert.assertThat) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Map(java.util.Map) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) Set(java.util.Set) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Matchers.any(org.mockito.Matchers.any) ExecutionException(java.util.concurrent.ExecutionException) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito(org.mockito.Mockito) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Stream(java.util.stream.Stream) ForkJoinPool(java.util.concurrent.ForkJoinPool) SimpleReact(cyclops.futurestream.SimpleReact) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) Matchers.containsString(org.hamcrest.Matchers.containsString) Mockito.mock(org.mockito.Mockito.mock) SimpleReact(cyclops.futurestream.SimpleReact) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 8 with BaseSimpleReactStream

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

the class SimpleReactTest method syncAndAsyncTest.

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

Example 9 with BaseSimpleReactStream

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

the class SimpleReactTest method asyncSyncTest.

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

Aggregations

BaseSimpleReactStream (com.oath.cyclops.types.futurestream.BaseSimpleReactStream)9 Test (org.junit.Test)9 SimpleReact (cyclops.futurestream.SimpleReact)4 Arrays (java.util.Arrays)4 List (java.util.List)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 ExecutionException (java.util.concurrent.ExecutionException)4 ForkJoinPool (java.util.concurrent.ForkJoinPool)4 Matchers.hasItem (org.hamcrest.Matchers.hasItem)4 Matchers.is (org.hamcrest.Matchers.is)4 Assert.assertThat (org.junit.Assert.assertThat)4 LazyReact (cyclops.futurestream.LazyReact)3 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Set (java.util.Set)2