use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class ParallelReduceSeedTest method collectAsync3.
@Test
public void collectAsync3() {
Scheduler s = Schedulers.newParallel("test", 3);
Supplier<List<Integer>> as = () -> new ArrayList<>();
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 100000).hide().publishOn(s).parallel(3).runOn(s).filter(t -> true).collect(as, (a, b) -> a.add(b)).doOnNext(v -> System.out.println(v.size())).groups().flatMap(v -> v).reduce(0, (a, b) -> b.size() + a).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValues(100_000).assertNoError().assertComplete();
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class ParallelReduceSeedTest method collectAsyncFused.
@Test
public void collectAsyncFused() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Scheduler scheduler = Schedulers.newParallel("test", 3);
Flux.range(1, 100000).parallel(3).runOn(scheduler).collect(ArrayList::new, ArrayList::add).sequential().reduce(0, (a, b) -> a + b.size()).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValues(100_000).assertNoError().assertComplete();
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class ParallelReduceSeedTest method collectAsync3Fused.
@Test
public void collectAsync3Fused() {
Scheduler s = Schedulers.newParallel("test", 3);
Supplier<List<Integer>> as = () -> new ArrayList<>();
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 100000).publishOn(s).parallel(3).runOn(s).collect(as, (a, b) -> a.add(b)).doOnNext(v -> System.out.println(v.size())).groups().flatMap(v -> v).reduce(0, (a, b) -> b.size() + a).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValues(100_000).assertNoError().assertComplete();
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class ParallelReduceSeedTest method collectAsync.
@Test
public void collectAsync() {
Scheduler s = Schedulers.newParallel("test", 3);
Supplier<List<Integer>> as = () -> new ArrayList<>();
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 100000).hide().parallel(3).runOn(s).collect(as, (a, b) -> a.add(b)).doOnNext(v -> System.out.println(v.size())).sequential().reduce(0, (a, b) -> a + b.size()).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValues(100_000).assertNoError().assertComplete();
}
use of reactor.test.subscriber.AssertSubscriber in project reactor-core by reactor.
the class ParallelReduceSeedTest method collectAsync2.
@Test
public void collectAsync2() {
Scheduler s = Schedulers.newParallel("test", 3);
Supplier<List<Integer>> as = () -> new ArrayList<>();
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Flux.range(1, 100000).hide().publishOn(s).parallel(3).runOn(s).hide().collect(as, (a, b) -> a.add(b)).doOnNext(v -> System.out.println(v.size())).sequential().reduce(0, (a, b) -> a + b.size()).subscribe(ts);
ts.await(Duration.ofSeconds(5));
ts.assertValues(100_000).assertNoError().assertComplete();
}
Aggregations