use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method threeArgEmptyFails.
@Test
public void threeArgEmptyFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
@SuppressWarnings("unchecked") Consumer<? super Throwable> consumer = mock(Consumer.class);
Action action = mock(Action.class);
doThrow(new TestException()).when(action).run();
Maybe.<Integer>empty().delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success, consumer, action);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
verify(consumer, never()).accept(any());
verify(action).run();
});
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method twoArgErrorFails.
@Test
public void twoArgErrorFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
@SuppressWarnings("unchecked") Consumer<? super Throwable> consumer = mock(Consumer.class);
doThrow(new TestException()).when(consumer).accept(any());
Maybe.<Integer>error(new TestException()).delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success, consumer);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
verify(consumer).accept(any(TestException.class));
});
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class RxJavaPluginsTest method clearIsPassthrough.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void clearIsPassthrough() {
try {
RxJavaPlugins.reset();
assertNull(RxJavaPlugins.onAssembly((Observable) null));
assertNull(RxJavaPlugins.onAssembly((ConnectableObservable) null));
assertNull(RxJavaPlugins.onAssembly((Flowable) null));
assertNull(RxJavaPlugins.onAssembly((ConnectableFlowable) null));
Observable oos = new Observable() {
@Override
public void subscribeActual(Observer t) {
}
};
Flowable fos = new Flowable() {
@Override
public void subscribeActual(Subscriber t) {
}
};
assertSame(oos, RxJavaPlugins.onAssembly(oos));
assertSame(fos, RxJavaPlugins.onAssembly(fos));
assertNull(RxJavaPlugins.onAssembly((Single) null));
Single sos = new Single() {
@Override
public void subscribeActual(SingleObserver t) {
}
};
assertSame(sos, RxJavaPlugins.onAssembly(sos));
assertNull(RxJavaPlugins.onAssembly((Completable) null));
Completable cos = new Completable() {
@Override
public void subscribeActual(CompletableObserver t) {
}
};
assertSame(cos, RxJavaPlugins.onAssembly(cos));
assertNull(RxJavaPlugins.onAssembly((Maybe) null));
Maybe myb = new Maybe() {
@Override
public void subscribeActual(MaybeObserver t) {
}
};
assertSame(myb, RxJavaPlugins.onAssembly(myb));
Runnable action = Functions.EMPTY_RUNNABLE;
assertSame(action, RxJavaPlugins.onSchedule(action));
class AllSubscriber implements Subscriber, Observer, SingleObserver, CompletableObserver, MaybeObserver {
@Override
public void onSuccess(Object value) {
}
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSubscribe(Subscription s) {
}
@Override
public void onNext(Object t) {
}
@Override
public void onError(Throwable t) {
}
@Override
public void onComplete() {
}
}
AllSubscriber all = new AllSubscriber();
Subscriber[] allArray = { all };
assertNull(RxJavaPlugins.onSubscribe(Observable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Observable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Flowable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Flowable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Single.just(1), null));
assertSame(all, RxJavaPlugins.onSubscribe(Single.just(1), all));
assertNull(RxJavaPlugins.onSubscribe(Completable.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Completable.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Maybe.never(), null));
assertSame(all, RxJavaPlugins.onSubscribe(Maybe.never(), all));
assertNull(RxJavaPlugins.onSubscribe(Flowable.never().parallel(), null));
assertSame(allArray, RxJavaPlugins.onSubscribe(Flowable.never().parallel(), allArray));
final Scheduler s = ImmediateThinScheduler.INSTANCE;
Supplier<Scheduler> c = new Supplier<Scheduler>() {
@Override
public Scheduler get() throws Exception {
return s;
}
};
assertSame(s, RxJavaPlugins.onComputationScheduler(s));
assertSame(s, RxJavaPlugins.onIoScheduler(s));
assertSame(s, RxJavaPlugins.onNewThreadScheduler(s));
assertSame(s, RxJavaPlugins.onSingleScheduler(s));
assertSame(s, RxJavaPlugins.initComputationScheduler(c));
assertSame(s, RxJavaPlugins.initIoScheduler(c));
assertSame(s, RxJavaPlugins.initNewThreadScheduler(c));
assertSame(s, RxJavaPlugins.initSingleScheduler(c));
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class ObservableConcatWithMaybeTest method normalEmpty.
@Test
public void normalEmpty() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.range(1, 5).concatWith(Maybe.<Integer>fromAction(new Action() {
@Override
public void run() throws Exception {
to.onNext(100);
}
})).subscribe(to);
to.assertResult(1, 2, 3, 4, 5, 100);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class ObservableConcatWithMaybeTest method otherError.
@Test
public void otherError() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.range(1, 5).concatWith(Maybe.<Integer>error(new TestException())).subscribe(to);
to.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
Aggregations