use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method observableObservable.
@Test
public void observableObservable() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Observable.just(1).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer v) throws Exception {
sleep();
return Observable.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method observerSingle.
@Test
public void observerSingle() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Observable.just(1).subscribeOn(Schedulers.io()).flatMapSingle(new Function<Integer, Single<Integer>>() {
@Override
public Single<Integer> apply(Integer v) throws Exception {
sleep();
return Single.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method singleCombiner.
@Test
public void singleCombiner() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Single.just(1).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Single<Integer>>() {
@Override
public Single<Integer> apply(Integer v) throws Exception {
sleep();
return Single.<Integer>error(new TestException());
}
}, (a, b) -> a + b).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method singleNotificationError.
@Test
public void singleNotificationError() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Single.<Integer>error(new TestException()).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Single<Integer>>() {
@Override
public Single<Integer> apply(Integer v) throws Exception {
sleep();
return Single.<Integer>error(new TestException());
}
}, new Function<Throwable, Single<Integer>>() {
@Override
public Single<Integer> apply(Throwable v) throws Exception {
sleep();
return Single.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method maybeNotificationEmpty.
@Test
public void maybeNotificationEmpty() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Maybe.<Integer>empty().subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Maybe<Integer>>() {
@Override
public Maybe<Integer> apply(Integer v) throws Exception {
sleep();
return Maybe.<Integer>error(new TestException());
}
}, new Function<Throwable, Maybe<Integer>>() {
@Override
public Maybe<Integer> apply(Throwable v) throws Exception {
sleep();
return Maybe.<Integer>error(new TestException());
}
}, new Supplier<Maybe<Integer>>() {
@Override
public Maybe<Integer> get() throws Exception {
sleep();
return Maybe.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations