@Test public void asyncFusion() { AssertSubscriber<Object> ts = AssertSubscriber.create(); UnicastProcessor<Integer> up = UnicastProcessor.create(new ConcurrentLinkedQueue<>()); up.filter(v -> (v & 1) == 0).subscribe(ts); for (int i = 1; i < 11; i++) { up.onNext(i); } up.onComplete(); ts.assertValues(2, 4, 6, 8, 10).assertNoError().assertComplete(); }
@Test public void asyncFusionBackpressured2() { AssertSubscriber<Object> ts = AssertSubscriber.create(1); UnicastProcessor<Integer> up = UnicastProcessor.create(new ConcurrentLinkedQueue<>()); Flux.just(1).hide().flatMap(w -> up.filter(v -> (v & 1) == 0), false, 1, 1).subscribe(ts); up.onNext(1); up.onNext(2); ts.assertValues(2).assertNoError().assertNotComplete(); up.onComplete(); ts.assertValues(2).assertNoError().assertComplete(); }