use of io.reactivex.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableReorder.
@Test
public void testDelayWithFlowableReorder() {
int n = 3;
PublishProcessor<Integer> source = PublishProcessor.create();
final List<PublishProcessor<Integer>> subjects = new ArrayList<PublishProcessor<Integer>>();
for (int i = 0; i < n; i++) {
subjects.add(PublishProcessor.<Integer>create());
}
Flowable<Integer> result = source.delay(new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return subjects.get(t1);
}
});
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
result.subscribe(o);
for (int i = 0; i < n; i++) {
source.onNext(i);
}
source.onComplete();
inOrder.verify(o, never()).onNext(anyInt());
inOrder.verify(o, never()).onComplete();
for (int i = n - 1; i >= 0; i--) {
subjects.get(i).onComplete();
inOrder.verify(o).onNext(i);
}
inOrder.verify(o).onComplete();
verify(o, never()).onError(any(Throwable.class));
}
Aggregations