use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherCancelDuringSingle.
@Test
public void flatMapPublisherCancelDuringSingle() {
final AtomicBoolean disposed = new AtomicBoolean();
TestSubscriberEx<Integer> ts = Single.<Integer>never().doOnDispose(new Action() {
@Override
public void run() throws Exception {
disposed.set(true);
}
}).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
return Flowable.range(v, 5);
}
}).to(TestHelper.<Integer>testConsumer()).assertNoValues().assertNotTerminated();
assertFalse(disposed.get());
ts.cancel();
assertTrue(disposed.get());
ts.assertNotTerminated();
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherCancelDuringFlowable.
@Test
public void flatMapPublisherCancelDuringFlowable() {
final AtomicBoolean disposed = new AtomicBoolean();
TestSubscriberEx<Integer> ts = Single.just(1).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
return Flowable.<Integer>never().doOnCancel(new Action() {
@Override
public void run() throws Exception {
disposed.set(true);
}
});
}
}).to(TestHelper.<Integer>testConsumer()).assertNoValues().assertNotTerminated();
assertFalse(disposed.get());
ts.cancel();
assertTrue(disposed.get());
ts.assertNotTerminated();
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherSingleError.
@Test
public void flatMapPublisherSingleError() {
final TestException ex = new TestException();
Single.<Integer>error(ex).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
return Flowable.just(1);
}
}).test().assertNoValues().assertError(ex);
}
use of io.reactivex.rxjava3.functions.Function in project RxJava by ReactiveX.
the class SingleFlatMapTest method flatMapPublisherMapperThrows.
@Test
public void flatMapPublisherMapperThrows() {
final TestException ex = new TestException();
Single.just(1).flatMapPublisher(new Function<Integer, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Integer v) throws Exception {
throw ex;
}
}).test().assertNoValues().assertError(ex);
}
use of io.reactivex.rxjava3.functions.Function 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());
}
Aggregations