use of io.reactivex.rxjava3.core.Maybe in project spring-framework by spring-projects.
the class HttpEntityMethodArgumentResolverTests method httpEntityWithMaybeBody.
@Test
public void httpEntityWithMaybeBody() {
ServerWebExchange exchange = postExchange("line1");
ResolvableType type = httpEntityType(Maybe.class, String.class);
HttpEntity<Maybe<String>> httpEntity = resolveValue(exchange, type);
assertThat(httpEntity.getHeaders()).isEqualTo(exchange.getRequest().getHeaders());
assertThat(httpEntity.getBody().blockingGet()).isEqualTo("line1");
}
use of io.reactivex.rxjava3.core.Maybe in project spring-framework by spring-projects.
the class HttpEntityMethodArgumentResolverTests method emptyBodyWithMaybe.
@Test
public void emptyBodyWithMaybe() {
ResolvableType type = httpEntityType(Maybe.class, String.class);
HttpEntity<Maybe<String>> entity = resolveValueWithEmptyBody(type);
StepVerifier.create(entity.getBody().toFlowable()).expectNextCount(0).expectComplete().verify();
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class TransformerTest method maybeTransformerThrows.
@Test
public void maybeTransformerThrows() {
try {
Maybe.just(1).compose(new MaybeTransformer<Integer, Integer>() {
@Override
public Maybe<Integer> apply(Maybe<Integer> v) {
throw new TestException("Forced failure");
}
});
fail("Should have thrown!");
} catch (TestException ex) {
assertEquals("Forced failure", ex.getMessage());
}
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class XFlatMapTest method maybeMaybe.
@Test
public void maybeMaybe() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Maybe.just(1).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Maybe<Integer>>() {
@Override
public Maybe<Integer> apply(Integer v) throws Exception {
sleep();
return Maybe.<Integer>error(new TestException());
}
}).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Maybe in project RxJava by ReactiveX.
the class XFlatMapTest method maybeCombiner.
@Test
public void maybeCombiner() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserver<Integer> to = Maybe.just(1).subscribeOn(Schedulers.io()).flatMap(new Function<Integer, Maybe<Integer>>() {
@Override
public Maybe<Integer> apply(Integer v) throws Exception {
sleep();
return Maybe.<Integer>error(new TestException());
}
}, (a, b) -> a + b).test();
cb.await();
beforeCancelSleep(to);
to.dispose();
Thread.sleep(SLEEP_AFTER_CANCEL);
to.assertEmpty();
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations