use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class PathVariableMapMethodArgumentResolverTests method setup.
@Before
public void setup() throws Exception {
this.resolver = new PathVariableMapMethodArgumentResolver(new ReactiveAdapterRegistry());
Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
this.paramMap = new MethodParameter(method, 0);
this.paramNamedMap = new MethodParameter(method, 1);
this.paramMapNoAnnot = new MethodParameter(method, 2);
this.paramMonoMap = new MethodParameter(method, 3);
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ErrorsArgumentResolverTests method resolveErrorsAfterMonoModelAttribute.
@Test(expected = IllegalArgumentException.class)
public void resolveErrorsAfterMonoModelAttribute() throws Exception {
MethodParameter parameter = this.testMethod.arg(BindingResult.class);
this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange).block(Duration.ofMillis(5000));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestAttributeMethodArgumentResolverTests method resolveOptional.
@Test
public void resolveOptional() throws Exception {
MethodParameter param = initMethodParameter(3);
Mono<Object> mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
assertNotNull(mono.block());
assertEquals(Optional.class, mono.block().getClass());
assertFalse(((Optional<?>) mono.block()).isPresent());
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
initializer.setConversionService(new DefaultFormattingConversionService());
BindingContext bindingContext = new BindingContext(initializer);
Foo foo = new Foo();
this.exchange.getAttributes().put("foo", foo);
mono = this.resolver.resolveArgument(param, bindingContext, this.exchange);
assertNotNull(mono.block());
assertEquals(Optional.class, mono.block().getClass());
Optional<?> optional = (Optional<?>) mono.block();
assertTrue(optional.isPresent());
assertSame(foo, optional.get());
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestAttributeMethodArgumentResolverTests method resolveNotRequired.
@Test
public void resolveNotRequired() throws Exception {
MethodParameter param = initMethodParameter(2);
Mono<Object> mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
assertNull(mono.block());
Foo foo = new Foo();
this.exchange.getAttributes().put("foo", foo);
mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
assertSame(foo, mono.block());
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class RequestAttributeMethodArgumentResolverTests method resolveWithName.
@Test
public void resolveWithName() throws Exception {
MethodParameter param = initMethodParameter(1);
Foo foo = new Foo();
this.exchange.getAttributes().put("specialFoo", foo);
Mono<Object> mono = this.resolver.resolveArgument(param, new BindingContext(), this.exchange);
assertSame(foo, mono.block());
}
Aggregations