use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableDeferTest method deferFunctionThrows.
@Test
public void deferFunctionThrows() throws Throwable {
Supplier<Observable<String>> factory = mock(Supplier.class);
when(factory.get()).thenThrow(new TestException());
Observable<String> result = Observable.defer(factory);
Observer<String> o = TestHelper.mockObserver();
result.subscribe(o);
verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any(String.class));
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method delaySupplierErrors.
@Test
public void delaySupplierErrors() {
final PublishSubject<Integer> ps = PublishSubject.create();
Observable<Integer> source = Observable.range(1, 5);
TestObserver<Integer> to = new TestObserver<>();
source.delaySubscription(ps).subscribe(to);
to.assertNoValues();
to.assertNoErrors();
to.assertNotComplete();
ps.onError(new TestException());
to.assertNoValues();
to.assertNotComplete();
to.assertError(TestException.class);
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableSourceThrows.
@Test
public void delayWithObservableSourceThrows() {
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);
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 io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableSubscriptionFunctionThrows.
@Test
public void delayWithObservableSubscriptionFunctionThrows() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Supplier<Observable<Integer>> subFunc = new Supplier<Observable<Integer>>() {
@Override
public Observable<Integer> get() {
throw new TestException();
}
};
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.onNext(1);
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.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableDelayTest method delayWithObservableSubscriptionRunCompletion.
@Test
public void delayWithObservableSubscriptionRunCompletion() {
PublishSubject<Integer> source = PublishSubject.create();
final PublishSubject<Integer> sdelay = PublishSubject.create();
final PublishSubject<Integer> delay = PublishSubject.create();
Supplier<Observable<Integer>> subFunc = new Supplier<Observable<Integer>>() {
@Override
public Observable<Integer> get() {
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();
}
Aggregations