use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableConcatTest method concatVeryLongObservableOfObservables.
@Test
public void concatVeryLongObservableOfObservables() {
final int n = 10000;
Flowable<Flowable<Integer>> source = Flowable.range(0, n).map(new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer v) {
return Flowable.just(v);
}
});
Single<List<Integer>> result = Flowable.concat(source).toList();
SingleObserver<List<Integer>> o = TestHelper.mockSingleObserver();
InOrder inOrder = inOrder(o);
result.subscribe(o);
List<Integer> list = new ArrayList<Integer>(n);
for (int i = 0; i < n; i++) {
list.add(i);
}
inOrder.verify(o).onSuccess(list);
verify(o, never()).onError(any(Throwable.class));
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableConcatTest method testMultipleObservers.
@Test
public void testMultipleObservers() {
Subscriber<Object> o1 = TestHelper.mockSubscriber();
Subscriber<Object> o2 = TestHelper.mockSubscriber();
TestScheduler s = new TestScheduler();
Flowable<Long> timer = Flowable.interval(500, TimeUnit.MILLISECONDS, s).take(2);
Flowable<Long> o = Flowable.concat(timer, timer);
o.subscribe(o1);
o.subscribe(o2);
InOrder inOrder1 = inOrder(o1);
InOrder inOrder2 = inOrder(o2);
s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
inOrder1.verify(o1, times(1)).onNext(0L);
inOrder2.verify(o2, times(1)).onNext(0L);
s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
inOrder1.verify(o1, times(1)).onNext(1L);
inOrder2.verify(o2, times(1)).onNext(1L);
s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
inOrder1.verify(o1, times(1)).onNext(0L);
inOrder2.verify(o2, times(1)).onNext(0L);
s.advanceTimeBy(500, TimeUnit.MILLISECONDS);
inOrder1.verify(o1, times(1)).onNext(1L);
inOrder2.verify(o2, times(1)).onNext(1L);
inOrder1.verify(o1, times(1)).onComplete();
inOrder2.verify(o2, times(1)).onComplete();
verify(o1, never()).onError(any(Throwable.class));
verify(o2, never()).onError(any(Throwable.class));
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableConcatTest method concatVeryLongObservableOfObservablesTakeHalf.
@Test
public void concatVeryLongObservableOfObservablesTakeHalf() {
final int n = 10000;
Flowable<Flowable<Integer>> source = Flowable.range(0, n).map(new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer v) {
return Flowable.just(v);
}
});
Single<List<Integer>> result = Flowable.concat(source).take(n / 2).toList();
SingleObserver<List<Integer>> o = TestHelper.mockSingleObserver();
InOrder inOrder = inOrder(o);
result.subscribe(o);
List<Integer> list = new ArrayList<Integer>(n);
for (int i = 0; i < n / 2; i++) {
list.add(i);
}
inOrder.verify(o).onSuccess(list);
verify(o, never()).onError(any(Throwable.class));
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableAmbTest method testAmb3.
@Test
public void testAmb3() {
Flowable<String> Flowable1 = createFlowable(new String[] { "1" }, 2000, null);
Flowable<String> Flowable2 = createFlowable(new String[] {}, 1000, null);
Flowable<String> Flowable3 = createFlowable(new String[] { "3" }, 3000, null);
@SuppressWarnings("unchecked") Flowable<String> o = Flowable.ambArray(Flowable1, Flowable2, Flowable3);
@SuppressWarnings("unchecked") DefaultSubscriber<String> observer = mock(DefaultSubscriber.class);
o.subscribe(observer);
scheduler.advanceTimeBy(100000, TimeUnit.MILLISECONDS);
InOrder inOrder = inOrder(observer);
inOrder.verify(observer, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project RxJava by ReactiveX.
the class FlowableAmbTest method testAmb.
@Test
public void testAmb() {
Flowable<String> Flowable1 = createFlowable(new String[] { "1", "11", "111", "1111" }, 2000, null);
Flowable<String> Flowable2 = createFlowable(new String[] { "2", "22", "222", "2222" }, 1000, null);
Flowable<String> Flowable3 = createFlowable(new String[] { "3", "33", "333", "3333" }, 3000, null);
@SuppressWarnings("unchecked") Flowable<String> o = Flowable.ambArray(Flowable1, Flowable2, Flowable3);
@SuppressWarnings("unchecked") DefaultSubscriber<String> observer = mock(DefaultSubscriber.class);
o.subscribe(observer);
scheduler.advanceTimeBy(100000, TimeUnit.MILLISECONDS);
InOrder inOrder = inOrder(observer);
inOrder.verify(observer, times(1)).onNext("2");
inOrder.verify(observer, times(1)).onNext("22");
inOrder.verify(observer, times(1)).onNext("222");
inOrder.verify(observer, times(1)).onNext("2222");
inOrder.verify(observer, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
Aggregations