use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageReaderArgumentResolverTests method monoTestBean.
@Test
public void monoTestBean() throws Exception {
String body = "{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}";
ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class);
MethodParameter param = this.testMethod.arg(type);
Mono<Object> mono = resolveValue(param, body);
assertEquals(new TestBean("FOOFOO", "BARBAR"), mono.block());
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageReaderArgumentResolverTests method validateFluxTestBean.
@Test
@SuppressWarnings("unchecked")
public void validateFluxTestBean() throws Exception {
String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\"}]";
ResolvableType type = forClassWithGenerics(Flux.class, TestBean.class);
MethodParameter param = this.testMethod.arg(type);
Flux<TestBean> flux = resolveValue(param, body);
StepVerifier.create(flux).expectNext(new TestBean("f1", "b1")).expectError(ServerWebInputException.class).verify();
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class MessageReaderArgumentResolverTests method validateMonoTestBean.
@Test
@SuppressWarnings("unchecked")
public void validateMonoTestBean() throws Exception {
String body = "{\"bar\":\"b1\"}";
ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class);
MethodParameter param = this.testMethod.arg(type);
Mono<TestBean> mono = resolveValue(param, body);
StepVerifier.create(mono).expectNextCount(0).expectError(ServerWebInputException.class).verify();
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ErrorsArgumentResolverTests method supports.
@Test
public void supports() throws Exception {
MethodParameter parameter = this.testMethod.arg(Errors.class);
assertTrue(this.resolver.supportsParameter(parameter));
parameter = this.testMethod.arg(BindingResult.class);
assertTrue(this.resolver.supportsParameter(parameter));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ErrorsArgumentResolverTests method doesNotSupport.
@Test
public void doesNotSupport() throws Exception {
MethodParameter parameter = this.testMethod.arg(String.class);
assertFalse(this.resolver.supportsParameter(parameter));
try {
parameter = this.testMethod.arg(ResolvableType.forClassWithGenerics(Mono.class, Errors.class));
assertFalse(this.resolver.supportsParameter(parameter));
fail();
} catch (IllegalStateException ex) {
assertTrue("Unexpected error message:\n" + ex.getMessage(), ex.getMessage().startsWith("ErrorsMethodArgumentResolver doesn't support reactive type wrapper"));
}
}
Aggregations