use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableAllTest method predicateThrowsObservable.
@Test
public void predicateThrowsObservable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.all(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).toObservable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableBlockingTest method blockingSubscribeObserverError.
@Test
public void blockingSubscribeObserverError() {
final List<Object> list = new ArrayList<>();
final TestException ex = new TestException();
Observable.range(1, 5).concatWith(Observable.<Integer>error(ex)).subscribeOn(Schedulers.computation()).blockingSubscribe(new Observer<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object value) {
list.add(value);
}
@Override
public void onError(Throwable e) {
list.add(e);
}
@Override
public void onComplete() {
list.add(100);
}
});
assertEquals(Arrays.asList(1, 2, 3, 4, 5, ex), list);
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class ObservableBlockingTest method blockingSubscribeConsumerConsumerError.
@Test
public void blockingSubscribeConsumerConsumerError() {
final List<Object> list = new ArrayList<>();
TestException ex = new TestException();
Consumer<Object> cons = new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
list.add(v);
}
};
Observable.range(1, 5).concatWith(Observable.<Integer>error(ex)).subscribeOn(Schedulers.computation()).blockingSubscribe(cons, cons);
assertEquals(Arrays.asList(1, 2, 3, 4, 5, ex), list);
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class BlockingObservableLatestTest method hasNextThrows.
@Test(expected = RuntimeException.class)
public void hasNextThrows() {
TestScheduler scheduler = new TestScheduler();
Observable<Long> source = Observable.<Long>error(new RuntimeException("Forced failure!")).subscribeOn(scheduler);
Iterable<Long> iter = source.blockingLatest();
Iterator<Long> it = iter.iterator();
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
it.hasNext();
}
use of io.reactivex.rxjava3.core.Observable in project RxJava by ReactiveX.
the class BlockingObservableLatestTest method nextThrows.
@Test(expected = RuntimeException.class)
public void nextThrows() {
TestScheduler scheduler = new TestScheduler();
Observable<Long> source = Observable.<Long>error(new RuntimeException("Forced failure!")).subscribeOn(scheduler);
Iterable<Long> iter = source.blockingLatest();
Iterator<Long> it = iter.iterator();
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
it.next();
}
Aggregations