use of io.reactivex.rxjava3.functions.Consumer in project RxJava by ReactiveX.
the class MaybeDoAfterSuccessTest method consumerThrows.
@Test
public void consumerThrows() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Maybe.just(1).doAfterSuccess(new Consumer<Integer>() {
@Override
public void accept(Integer e) throws Exception {
throw new TestException();
}
}).test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions.Consumer in project RxJava by ReactiveX.
the class MaybeDoOnEventTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Disposable bs = Disposable.empty();
new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
observer.onSuccess(1);
}
}.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable d) throws Exception {
throw new TestException("First");
}
}).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions.Consumer in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method oneArgErrorAsync.
@Test
public void oneArgErrorAsync() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
Maybe.<Integer>error(new TestException()).delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
});
}
use of io.reactivex.rxjava3.functions.Consumer 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.functions.Consumer in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method oneArgSuccessFails.
@Test
public void oneArgSuccessFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
doThrow(new TestException()).when(success).accept(any());
Maybe.just(1).blockingSubscribe(success);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success).accept(1);
});
}
Aggregations