use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class XFlatMapTest method singlePublisher.
@Test
public void singlePublisher() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestSubscriber<Integer> ts = Single.just(1).subscribeOn(Schedulers.io()).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
sleep();
return Flowable.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(ts);
ts.cancel();
Thread.sleep(SLEEP_AFTER_CANCEL);
ts.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions.Function 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.functions.Function 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.functions.Function 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.functions.Function in project RxJava by ReactiveX.
the class XFlatMapTest method maybePublisher.
@Test
public void maybePublisher() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestSubscriber<Integer> ts = Maybe.just(1).subscribeOn(Schedulers.io()).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
sleep();
return Flowable.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(ts);
ts.cancel();
Thread.sleep(SLEEP_AFTER_CANCEL);
ts.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations