Search in sources :

Example 6 with PublishProcessor

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));
}
Also used : InOrder(org.mockito.InOrder) PublishProcessor(io.reactivex.processors.PublishProcessor)

Aggregations

PublishProcessor (io.reactivex.processors.PublishProcessor)6 Method (java.lang.reflect.Method)3 TestException (io.reactivex.exceptions.TestException)2 InOrder (org.mockito.InOrder)2 Test (org.junit.Test)1