use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method singleNotificationSuccess.
@Test
public void singleNotificationSuccess() 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());
}
}, 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 maybeNotificationSuccess.
@Test
public void maybeNotificationSuccess() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Maybe.just(1).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();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method maybeNotificationError.
@Test
public void maybeNotificationError() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Maybe.<Integer>error(new TestException()).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();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class XFlatMapTest method singleSingle.
@Test
public void singleSingle() 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());
}
}).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 MaybeTest method subscribeOnSuccess.
@Test
public void subscribeOnSuccess() {
String main = Thread.currentThread().getName();
TestObserver<String> to = Maybe.fromCallable(new Callable<String>() {
@Override
public String call() throws Exception {
return Thread.currentThread().getName();
}
}).subscribeOn(Schedulers.single()).test().awaitDone(5, TimeUnit.SECONDS).assertValueCount(1);
assertNotEquals(main, to.values().get(0));
}
Aggregations