use of io.reactivex.rxjava3.core.Maybe in project spring-framework by spring-projects.
the class RequestBodyMethodArgumentResolverTests method emptyBodyWithMaybe.
@Test
public void emptyBodyWithMaybe() {
MethodParameter param = this.testMethod.annot(requestBody()).arg(Maybe.class, String.class);
Maybe<String> maybe = resolveValueWithEmptyBody(param);
StepVerifier.create(maybe.toFlowable()).expectNextCount(0).expectError(ServerWebInputException.class).verify();
param = this.testMethod.annot(requestBody().notRequired()).arg(Maybe.class, String.class);
maybe = resolveValueWithEmptyBody(param);
StepVerifier.create(maybe.toFlowable()).expectNextCount(0).expectComplete().verify();
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class MaybeCacheTest method crossCancelOnError.
@Test
public void crossCancelOnError() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
PublishProcessor<Integer> pp = PublishProcessor.create();
Maybe<Integer> source = pp.singleElement().cache();
source.subscribe(Functions.emptyConsumer(), new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
ts.cancel();
}
});
source.toFlowable().subscribe(ts);
pp.onError(new TestException());
ts.assertEmpty();
}
use of io.reactivex.rxjava3.core.Maybe 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.core.Maybe in project RxJava by ReactiveX.
the class MaybeConcatArrayTest method errorAfterTermination.
@Test
public void errorAfterTermination() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final MaybeObserver<?>[] o = { null };
Maybe.concatArrayDelayError(Maybe.just(1), Maybe.error(new IOException()), new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onSuccess(2);
o[0] = observer;
}
}).test().assertFailure(IOException.class, 1, 2);
o[0].onError(new TestException());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Maybe 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());
});
}
Aggregations