use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeTimeoutPublisherTest method fallbackError.
@Test
public void fallbackError() {
PublishProcessor<Integer> pp1 = PublishProcessor.create();
PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserver<Integer> to = pp1.singleElement().timeout(pp2, Maybe.<Integer>error(new TestException())).test();
assertTrue(pp1.hasSubscribers());
assertTrue(pp2.hasSubscribers());
pp2.onNext(1);
pp2.onComplete();
assertFalse(pp1.hasSubscribers());
assertFalse(pp2.hasSubscribers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeMergeTest method delayErrorWithMaxConcurrencyAsync.
@Test
public void delayErrorWithMaxConcurrencyAsync() {
final AtomicInteger count = new AtomicInteger();
@SuppressWarnings("unchecked") Maybe<Integer>[] sources = new Maybe[3];
for (int i = 0; i < 3; i++) {
final int j = i + 1;
sources[i] = Maybe.fromCallable(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return count.incrementAndGet() - j;
}
}).subscribeOn(Schedulers.io());
}
for (int i = 0; i < 1000; i++) {
count.set(0);
Maybe.mergeDelayError(Flowable.fromArray(sources), 1).test().awaitDone(5, TimeUnit.SECONDS).assertResult(0, 0, 0);
}
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeOfTypeTest method errorNotInstance.
@Test
public void errorNotInstance() {
TestObserver<String> to = Maybe.<Integer>error(new TestException()).ofType(String.class).test();
// don't make this fluent, target type required!
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableConcatWithMaybeTest method otherError.
@Test
public void otherError() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
Flowable.range(1, 5).concatWith(Maybe.<Integer>error(new TestException())).subscribe(ts);
ts.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class FlowableFirstTest method firstWithPredicate.
@Test
public void firstWithPredicate() {
Maybe<Integer> maybe = Flowable.just(1, 2, 3, 4, 5, 6).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