use of io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method testDelayWithObservableSubscriptionRunCompletion.
@Test
public void testDelayWithObservableSubscriptionRunCompletion() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> sdelay = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Callable<Observable<Integer>> subFunc = new Callable<Observable<Integer>>() {
@Override
public Observable<Integer> call() {
return sdelay;
}
};
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return delay;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(Observable.defer(subFunc), delayFunc).subscribe(o);
source.onNext(1);
sdelay.onComplete();
source.onNext(2);
delay.onNext(2);
inOrder.verify(o).onNext(2);
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
verify(o, never()).onComplete();
}
use of io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method testDelayWithObservableSubscriptionThrows.
@Test
public void testDelayWithObservableSubscriptionThrows() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Callable<Observable<Integer>> subFunc = new Callable<Observable<Integer>>() {
@Override
public Observable<Integer> call() {
return delay;
}
};
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return delay;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(Observable.defer(subFunc), delayFunc).subscribe(o);
source.onNext(1);
delay.onError(new TestException());
source.onNext(2);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method testDelayWithObservableEmptyDelayer.
@Test
public void testDelayWithObservableEmptyDelayer() {
PublishSubject<Integer> source = PublishSubject.create();
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return Observable.empty();
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
source.onComplete();
inOrder.verify(o).onNext(1);
inOrder.verify(o).onComplete();
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
}
use of io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method testDelayWithObservableDelayFunctionThrows.
@Test
public void testDelayWithObservableDelayFunctionThrows() {
PublishSubject<Integer> source = PublishSubject.create();
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
throw new TestException();
}
};
Observer<Object> o = TestHelper.mockObserver();
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 io.reactivex.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method testDelayWithObservableSingleSend1.
@Test
public void testDelayWithObservableSingleSend1() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Function<Integer, Observable<Integer>> delayFunc = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return delay;
}
};
Observer<Object> o = TestHelper.mockObserver();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
delay.onNext(1);
delay.onNext(2);
inOrder.verify(o).onNext(1);
inOrder.verifyNoMoreInteractions();
verify(o, never()).onError(any(Throwable.class));
}
Aggregations