Search in sources :

Example 1 with EmptyCollector

use of com.oath.cyclops.react.collectors.lazy.EmptyCollector in project cyclops by aol.

the class EmptyCollectorTest method testAcceptMock50.

@Test
public void testAcceptMock50() {
    collector = new EmptyCollector<>(new MaxActive(500, 450), cf -> cf.join());
    FastFuture cf = Mockito.mock(FastFuture.class);
    BDDMockito.given(cf.isDone()).willReturn(true);
    for (int i = 0; i < 1000; i++) {
        collector.accept(cf);
    }
    Mockito.verify(cf, Mockito.times(501)).isDone();
}
Also used : FastFuture(com.oath.cyclops.internal.react.async.future.FastFuture) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) EmptyCollector(com.oath.cyclops.react.collectors.lazy.EmptyCollector) Mockito.verify(org.mockito.Mockito.verify) Assert.assertThat(org.junit.Assert.assertThat) BDDMockito(org.mockito.BDDMockito) Mockito(org.mockito.Mockito) BDDMockito.given(org.mockito.BDDMockito.given) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) FastFuture(com.oath.cyclops.internal.react.async.future.FastFuture) Test(org.junit.Test)

Example 2 with EmptyCollector

use of com.oath.cyclops.react.collectors.lazy.EmptyCollector in project cyclops by aol.

the class EmptyCollectorTest method testAcceptMock495.

@Test
public void testAcceptMock495() {
    collector = new EmptyCollector<>(new MaxActive(500, 5), cf -> cf.join());
    FastFuture cf = Mockito.mock(FastFuture.class);
    BDDMockito.given(cf.isDone()).willReturn(true);
    for (int i = 0; i < 1000; i++) {
        collector.accept(cf);
    }
    Mockito.verify(cf, Mockito.times(501)).isDone();
}
Also used : FastFuture(com.oath.cyclops.internal.react.async.future.FastFuture) Mockito.atLeastOnce(org.mockito.Mockito.atLeastOnce) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) EmptyCollector(com.oath.cyclops.react.collectors.lazy.EmptyCollector) Mockito.verify(org.mockito.Mockito.verify) Assert.assertThat(org.junit.Assert.assertThat) BDDMockito(org.mockito.BDDMockito) Mockito(org.mockito.Mockito) BDDMockito.given(org.mockito.BDDMockito.given) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) FastFuture(com.oath.cyclops.internal.react.async.future.FastFuture) Test(org.junit.Test)

Example 3 with EmptyCollector

use of com.oath.cyclops.react.collectors.lazy.EmptyCollector in project cyclops by aol.

the class LazyStream method runThread.

default void runThread(final Runnable r) {
    final Function<FastFuture, U> safeJoin = (final FastFuture cf) -> (U) BlockingStreamHelper.getSafe(cf, getErrorHandler());
    new Thread(() -> new Runner(r).run(getLastActive(), new EmptyCollector(getMaxActive(), safeJoin))).start();
}
Also used : Runner(com.oath.cyclops.internal.react.stream.Runner) EmptyCollector(com.oath.cyclops.react.collectors.lazy.EmptyCollector) FastFuture(com.oath.cyclops.internal.react.async.future.FastFuture)

Aggregations

FastFuture (com.oath.cyclops.internal.react.async.future.FastFuture)3 EmptyCollector (com.oath.cyclops.react.collectors.lazy.EmptyCollector)3 Matchers.is (org.hamcrest.Matchers.is)2 Assert.assertThat (org.junit.Assert.assertThat)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2 Test (org.junit.Test)2 BDDMockito (org.mockito.BDDMockito)2 BDDMockito.given (org.mockito.BDDMockito.given)2 Mockito (org.mockito.Mockito)2 Mockito.atLeastOnce (org.mockito.Mockito.atLeastOnce)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.times (org.mockito.Mockito.times)2 Mockito.verify (org.mockito.Mockito.verify)2 Runner (com.oath.cyclops.internal.react.stream.Runner)1