use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method illegalArgumentExceptionIsWrappedWithInvocationDetails.
@Test
public void illegalArgumentExceptionIsWrappedWithInvocationDetails() throws Exception {
Mono<Object> resolvedValue = Mono.just(1);
Method method = on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method, resolverFor(resolvedValue));
try {
mono.block();
fail("Expected IllegalStateException");
} catch (IllegalStateException ex) {
assertThat(ex.getMessage(), is("Failed to invoke handler method with resolved arguments: " + "[0][type=java.lang.Integer][value=1] " + "on " + method.toGenericString()));
}
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method resolverThrowsException.
@Test
public void resolverThrowsException() throws Exception {
Mono<Object> resolvedValue = Mono.error(new UnsupportedMediaTypeStatusException("boo"));
Method method = on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method, resolverFor(resolvedValue));
try {
mono.block();
fail("Expected UnsupportedMediaTypeStatusException");
} catch (UnsupportedMediaTypeStatusException ex) {
assertThat(ex.getMessage(), is("Request failure [status: 415, reason: \"boo\"]"));
}
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method noMatchingResolver.
@Test
public void noMatchingResolver() throws Exception {
Method method = on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method);
try {
mono.block();
fail("Expected IllegalStateException");
} catch (IllegalStateException ex) {
assertThat(ex.getMessage(), is("No suitable resolver for argument 0 of type 'java.lang.String' " + "on " + method.toGenericString()));
}
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class InvocableHandlerMethodTests method invokeMethodWithNoValue.
@Test
public void invokeMethodWithNoValue() throws Exception {
Mono<Object> resolvedValue = Mono.empty();
Method method = on(TestController.class).mockCall(o -> o.singleArg(null)).method();
Mono<HandlerResult> mono = invoke(new TestController(), method, resolverFor(resolvedValue));
assertHandlerResultValue(mono, "success:null");
}
use of org.springframework.web.reactive.HandlerResult in project spring-framework by spring-projects.
the class ViewResolutionResultHandlerTests method testSupports.
private void testSupports(MethodParameter returnType) {
ViewResolutionResultHandler resultHandler = resultHandler(mock(ViewResolver.class));
HandlerResult handlerResult = new HandlerResult(new Object(), null, returnType, this.bindingContext);
assertTrue(resultHandler.supports(handlerResult));
}
Aggregations