use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class FlowableToCompletableTest method shouldUseUnsafeSubscribeInternallyNotSubscribe.
@Test
public void shouldUseUnsafeSubscribeInternallyNotSubscribe() {
TestSubscriber<String> subscriber = TestSubscriber.create();
final AtomicBoolean unsubscribed = new AtomicBoolean(false);
Completable cmp = Flowable.just("Hello World!").doOnCancel(new Action() {
@Override
public void run() {
unsubscribed.set(true);
}
}).ignoreElements();
cmp.<String>toFlowable().subscribe(subscriber);
subscriber.assertComplete();
assertFalse(unsubscribed.get());
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class SchedulerWhenTest method disposed.
@Test
public void disposed() {
SchedulerWhen sw = new SchedulerWhen(new Function<Flowable<Flowable<Completable>>, Completable>() {
@Override
public Completable apply(Flowable<Flowable<Completable>> v) throws Exception {
return Completable.never();
}
}, Schedulers.single());
assertFalse(sw.isDisposed());
sw.dispose();
assertTrue(sw.isDisposed());
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class XFlatMapTest method maybeCompletable.
@Test
public void maybeCompletable() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Void> to = Maybe.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();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class XFlatMapTest method singleCompletable.
@Test
public void singleCompletable() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Void> to = Single.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();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class XFlatMapTest method observerCompletable.
@Test
public void observerCompletable() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Void> to = 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();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations