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