use of reactor.core.publisher.Mono in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method cannotResolveArg.
@Test
public void cannotResolveArg() {
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method);
assertThatIllegalStateException().isThrownBy(mono::block).withMessage("Could not resolve parameter [0] in " + method.toGenericString() + ": No suitable resolver");
}
use of reactor.core.publisher.Mono in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method illegalArgumentException.
@Test
public void illegalArgumentException() {
this.resolvers.add(stubResolver(1));
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method);
assertThatIllegalStateException().isThrownBy(mono::block).withCauseInstanceOf(IllegalArgumentException.class).withMessageContaining("Controller [").withMessageContaining("Method [").withMessageContaining("with argument values:").withMessageContaining("[0] [type=java.lang.Integer] [value=1]");
}
use of reactor.core.publisher.Mono in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method resolveProvidedArg.
@Test
public void resolveProvidedArg() {
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method, "value1");
assertHandlerResultValue(mono, "success:value1");
}
use of reactor.core.publisher.Mono in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method exceptionInResolvingArg.
@Test
public void exceptionInResolvingArg() {
this.resolvers.add(stubResolver(Mono.error(new UnsupportedMediaTypeStatusException("boo"))));
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method);
assertThatExceptionOfType(UnsupportedMediaTypeStatusException.class).isThrownBy(mono::block).withMessage("415 UNSUPPORTED_MEDIA_TYPE \"boo\"");
}
use of reactor.core.publisher.Mono in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method validationErrorForMono.
@Test
void validationErrorForMono() throws Exception {
MethodParameter parameter = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, Pojo.class);
testValidationError(parameter, resolvedArgumentMono -> {
Object value = resolvedArgumentMono.block(Duration.ofSeconds(5));
assertThat(value).isInstanceOf(Mono.class);
return (Mono<?>) value;
});
}
Aggregations