use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class ObservableMergeWithMaybeTest method onErrorMainOverflow.
@Test
public void onErrorMainOverflow() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<Observer<?>> observerRef = new AtomicReference<>();
TestObserver<Integer> to = new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observerRef.set(observer);
}
}.mergeWith(Maybe.<Integer>error(new IOException())).test();
observerRef.get().onError(new TestException());
to.assertFailure(IOException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class RxJavaPluginsTest method maybeCreate.
@SuppressWarnings("rawtypes")
@Test
public void maybeCreate() {
try {
RxJavaPlugins.setOnMaybeAssembly(new Function<Maybe, Maybe>() {
@Override
public Maybe apply(Maybe t) {
return new MaybeError(new TestException());
}
});
Maybe.empty().test().assertNoValues().assertNotComplete().assertError(TestException.class);
} finally {
RxJavaPlugins.reset();
}
// make sure the reset worked
Maybe.empty().test().assertNoValues().assertNoErrors().assertComplete();
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableConcatWithMaybeTest method normalEmpty.
@Test
public void normalEmpty() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
Flowable.range(1, 5).concatWith(Maybe.<Integer>fromAction(new Action() {
@Override
public void run() throws Exception {
ts.onNext(100);
}
})).subscribe(ts);
ts.assertResult(1, 2, 3, 4, 5, 100);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableConcatWithMaybeTest method mainError.
@Test
public void mainError() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
Flowable.<Integer>error(new TestException()).concatWith(Maybe.<Integer>fromAction(new Action() {
@Override
public void run() throws Exception {
ts.onNext(100);
}
})).subscribe(ts);
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableFirstTest method firstWithPredicateAndOneElement.
@Test
public void firstWithPredicateAndOneElement() {
Maybe<Integer> maybe = Flowable.just(1, 2).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return t1 % 2 == 0;
}
}).firstElement();
maybe.subscribe(wm);
InOrder inOrder = inOrder(wm);
inOrder.verify(wm, times(1)).onSuccess(2);
inOrder.verifyNoMoreInteractions();
}
Aggregations