Search in sources :

Example 71 with SimpleReact

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

the class ReactPoolTest method testRoundRobin.

@Test
public void testRoundRobin() {
    SimpleReact react1 = Mockito.mock(SimpleReact.class);
    SimpleReact react2 = Mockito.mock(SimpleReact.class);
    ReactPool<SimpleReact> pool = ReactPool.boundedPool(asList(react1, react2));
    List<Supplier<String>> suppliers = Arrays.asList(() -> "hello", () -> "world");
    pool.react((er) -> er.fromIterableAsync(suppliers));
    pool.react((er) -> er.fromIterableAsync(suppliers));
    Mockito.verify(react1, Mockito.times(1)).fromIterableAsync(suppliers);
    Mockito.verify(react2, Mockito.times(1)).fromIterableAsync(suppliers);
}
Also used : SimpleReact(cyclops.futurestream.SimpleReact) Supplier(java.util.function.Supplier) Test(org.junit.Test)

Aggregations

SimpleReact (cyclops.futurestream.SimpleReact)71 Test (org.junit.Test)70 Assert.assertThat (org.junit.Assert.assertThat)54 Matchers.is (org.hamcrest.Matchers.is)52 List (java.util.List)50 ExecutionException (java.util.concurrent.ExecutionException)46 Collectors (java.util.stream.Collectors)36 Set (java.util.Set)33 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)31 Matchers.hasItem (org.hamcrest.Matchers.hasItem)30 Matchers.greaterThan (org.hamcrest.Matchers.greaterThan)25 Arrays (java.util.Arrays)24 CompletableFuture (java.util.concurrent.CompletableFuture)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)21 Stream (java.util.stream.Stream)21 LazyReact (cyclops.futurestream.LazyReact)20 BaseSimpleReactStream (com.oath.cyclops.types.futurestream.BaseSimpleReactStream)17 ArrayList (java.util.ArrayList)16 ForkJoinPool (java.util.concurrent.ForkJoinPool)16 Ignore (org.junit.Ignore)14