use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method bindExistingSingle.
@Test
public void bindExistingSingle() throws Exception {
Foo foo = new Foo();
foo.setName("Jim");
this.bindContext.getModel().addAttribute("foo", Single.just(foo));
MethodParameter parameter = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
testBindFoo(parameter, value -> {
assertEquals(Foo.class, value.getClass());
return (Foo) value;
});
assertSame(foo, this.bindContext.getModel().asMap().get("foo"));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method createAndBindToSingle.
@Test
public void createAndBindToSingle() throws Exception {
MethodParameter parameter = this.testMethod.annotPresent(ModelAttribute.class).arg(Single.class, Foo.class);
testBindFoo(parameter, single -> {
assertTrue(single.getClass().getName(), single instanceof Single);
Object value = ((Single<?>) single).toBlocking().value();
assertEquals(Foo.class, value.getClass());
return (Foo) value;
});
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method bindExistingMonoToMono.
@Test
public void bindExistingMonoToMono() throws Exception {
Foo foo = new Foo();
foo.setName("Jim");
this.bindContext.getModel().addAttribute("foo", Mono.just(foo));
MethodParameter parameter = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Mono.class, Foo.class);
testBindFoo(parameter, mono -> {
assertTrue(mono.getClass().getName(), mono instanceof Mono);
Object value = ((Mono<?>) mono).block(Duration.ofSeconds(5));
assertEquals(Foo.class, value.getClass());
return (Foo) value;
});
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method bindExisting.
@Test
public void bindExisting() throws Exception {
Foo foo = new Foo();
foo.setName("Jim");
this.bindContext.getModel().addAttribute(foo);
MethodParameter parameter = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
testBindFoo(parameter, value -> {
assertEquals(Foo.class, value.getClass());
return (Foo) value;
});
assertSame(foo, this.bindContext.getModel().asMap().get("foo"));
}
use of org.springframework.core.MethodParameter in project spring-framework by spring-projects.
the class ModelAttributeMethodArgumentResolverTests method validationError.
@Test
public void validationError() throws Exception {
MethodParameter parameter = this.testMethod.annotNotPresent(ModelAttribute.class).arg(Foo.class);
testValidationError(parameter, Function.identity());
}
Aggregations