use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class LambdaObserverTest method disposedObserverShouldReportErrorOnGlobalErrorHandler.
@Test
public void disposedObserverShouldReportErrorOnGlobalErrorHandler() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final List<Throwable> observerErrors = Collections.synchronizedList(new ArrayList<>());
LambdaObserver<Integer> o = new LambdaObserver<>(Functions.<Integer>emptyConsumer(), new Consumer<Throwable>() {
@Override
public void accept(Throwable t) {
observerErrors.add(t);
}
}, Functions.EMPTY_ACTION, Functions.<Disposable>emptyConsumer());
o.dispose();
o.onError(new IOException());
o.onError(new IOException());
assertTrue(observerErrors.isEmpty());
TestHelper.assertUndeliverable(errors, 0, IOException.class);
TestHelper.assertUndeliverable(errors, 1, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class ObservableDematerializeTest method honorsContractWhenThrows.
@Test
public void honorsContractWhenThrows() {
Observable<Integer> source = Observable.error(new TestException());
Observable<Integer> result = source.materialize().dematerialize(Functions.<Notification<Integer>>identity());
Observer<Integer> o = TestHelper.mockObserver();
result.subscribe(o);
verify(o, never()).onNext(any(Integer.class));
verify(o, never()).onComplete();
verify(o).onError(any(TestException.class));
}
use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class ObservableDematerializeTest method eventsAfterDematerializedTerminal.
@Test
public void eventsAfterDematerializedTerminal() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Notification<Object>>() {
@Override
protected void subscribeActual(Observer<? super Notification<Object>> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(Notification.createOnComplete());
observer.onNext(Notification.<Object>createOnNext(1));
observer.onNext(Notification.createOnError(new TestException("First")));
observer.onError(new TestException("Second"));
}
}.dematerialize(Functions.<Notification<Object>>identity()).test().assertResult();
TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
TestHelper.assertUndeliverable(errors, 1, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions in project RxJava by ReactiveX.
the class SingleSubscribeTest method consumerDispose.
@Test
public void consumerDispose() {
PublishSubject<Integer> ps = PublishSubject.create();
Disposable d = ps.single(-99).subscribe(Functions.<Integer>emptyConsumer());
assertFalse(d.isDisposed());
d.dispose();
assertTrue(d.isDisposed());
assertFalse(ps.hasObservers());
}
Aggregations