use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableNormal1.
@Test
public void testDelayWithFlowableNormal1() {
PublishProcessor<Integer> source = PublishProcessor.create();
final List<PublishProcessor<Integer>> delays = new ArrayList<PublishProcessor<Integer>>();
final int n = 10;
for (int i = 0; i < n; i++) {
PublishProcessor<Integer> delay = PublishProcessor.create();
delays.add(delay);
}
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delays.get(t1);
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
for (int i = 0; i < n; i++) {
source.onNext(i);
delays.get(i).onNext(i);
inOrder.verify(o).onNext(i);
}
source.onComplete();
inOrder.verify(o).onComplete();
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableDelayFunctionThrows.
@Test
public void testDelayWithFlowableDelayFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
throw new TestException();
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithError.
@Test
public void testDelayWithError() {
Flowable<Long> source = Flowable.interval(1L, TimeUnit.SECONDS, scheduler).map(new Function<Long, Long>() {
@Override
public Long apply(Long value) {
if (value == 1L) {
throw new RuntimeException("error!");
}
return value;
}
});
Flowable<Long> delayed = source.delay(1L, TimeUnit.SECONDS, scheduler);
delayed.subscribe(observer);
InOrder inOrder = inOrder(observer);
scheduler.advanceTimeTo(1999L, TimeUnit.MILLISECONDS);
verify(observer, never()).onNext(anyLong());
verify(observer, never()).onComplete();
verify(observer, never()).onError(any(Throwable.class));
scheduler.advanceTimeTo(2000L, TimeUnit.MILLISECONDS);
inOrder.verify(observer, times(1)).onError(any(Throwable.class));
inOrder.verify(observer, never()).onNext(anyLong());
verify(observer, never()).onComplete();
scheduler.advanceTimeTo(5000L, TimeUnit.MILLISECONDS);
inOrder.verify(observer, never()).onNext(anyLong());
inOrder.verify(observer, never()).onError(any(Throwable.class));
verify(observer, never()).onComplete();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableSourceThrows.
@Test
public void testDelayWithFlowableSourceThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
source.onError(new TestException());
delay.onNext(1);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableSubscriptionFunctionThrows.
@Test
public void testDelayWithFlowableSubscriptionFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Callable<Flowable<Integer>> subFunc = new Callable<Flowable<Integer>>() {
@Override
public Flowable<Integer> call() {
throw new TestException();
}
};
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(Flowable.defer(subFunc), delayFunc).subscribe(o);
source.onNext(1);
delay.onNext(1);
source.onNext(2);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
Aggregations