use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableDematerializeTest method errorPassThru.
@Test
public void errorPassThru() {
Exception exception = new Exception("test");
Observable<Notification<Integer>> o = Observable.error(exception);
Observable<Integer> dematerialize = o.dematerialize(Functions.<Notification<Integer>>identity());
Observer<Integer> observer = TestHelper.mockObserver();
dematerialize.subscribe(observer);
verify(observer, times(1)).onError(exception);
verify(observer, times(0)).onComplete();
verify(observer, times(0)).onNext(any(Integer.class));
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableDoOnEachTest method onCompleteAfterCrash.
@Test
public void onCompleteAfterCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Observable.wrap(new ObservableSource<Object>() {
@Override
public void subscribe(Observer<? super Object> observer) {
observer.onSubscribe(Disposable.empty());
observer.onComplete();
}
}).doAfterTerminate(new Action() {
@Override
public void run() throws Exception {
throw new IOException();
}
}).test().assertResult();
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableDoOnEachTest method onCompleteCrash.
@Test
public void onCompleteCrash() {
Observable.wrap(new ObservableSource<Object>() {
@Override
public void subscribe(Observer<? super Object> observer) {
observer.onSubscribe(Disposable.empty());
observer.onComplete();
}
}).doOnComplete(new Action() {
@Override
public void run() throws Exception {
throw new IOException();
}
}).test().assertFailure(IOException.class);
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableFlatMapTest method flatMapTransformsMaxConcurrentNormal.
@Test
public void flatMapTransformsMaxConcurrentNormal() {
final int m = 2;
final AtomicInteger subscriptionCount = new AtomicInteger();
Observable<Integer> onNext = composer(Observable.fromIterable(Arrays.asList(1, 2, 3)).observeOn(Schedulers.computation()), subscriptionCount, m).subscribeOn(Schedulers.computation());
Observable<Integer> onComplete = composer(Observable.fromIterable(Arrays.asList(4)), subscriptionCount, m).subscribeOn(Schedulers.computation());
Observable<Integer> onError = Observable.fromIterable(Arrays.asList(5));
Observable<Integer> source = Observable.fromIterable(Arrays.asList(10, 20, 30));
Observer<Object> o = TestHelper.mockObserver();
TestObserverEx<Object> to = new TestObserverEx<>(o);
Function<Throwable, Observable<Integer>> just = just(onError);
source.flatMap(just(onNext), just, just0(onComplete), m).subscribe(to);
to.awaitDone(1, TimeUnit.SECONDS);
to.assertNoErrors();
to.assertTerminated();
verify(o, times(3)).onNext(1);
verify(o, times(3)).onNext(2);
verify(o, times(3)).onNext(3);
verify(o).onNext(4);
verify(o).onComplete();
verify(o, never()).onNext(5);
verify(o, never()).onError(any(Throwable.class));
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableDebounceTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
observer = TestHelper.mockObserver();
innerScheduler = scheduler.createWorker();
}
Aggregations