Add reflection hints for data binding in Web controllers
Closes gh-28623
This commit is contained in:
@@ -74,6 +74,24 @@ public class RequestMappingReflectiveProcessorTests {
|
||||
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(String.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerReflectiveHintsForMethodWithModelAttribute() throws NoSuchMethodException {
|
||||
Method method = SampleController.class.getDeclaredMethod("postForm", Request.class);
|
||||
processor.registerReflectionHints(hints, method);
|
||||
assertThat(hints.typeHints()).satisfiesExactlyInAnyOrder(
|
||||
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleController.class)),
|
||||
typeHint -> {
|
||||
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(Request.class));
|
||||
assertThat(typeHint.getMemberCategories()).containsExactlyInAnyOrder(
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
|
||||
MemberCategory.DECLARED_FIELDS);
|
||||
assertThat(typeHint.methods()).satisfiesExactlyInAnyOrder(
|
||||
hint -> assertThat(hint.getName()).isEqualTo("getMessage"),
|
||||
hint -> assertThat(hint.getName()).isEqualTo("setMessage"));
|
||||
},
|
||||
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(String.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerReflectiveHintsForMethodWithRestController() throws NoSuchMethodException {
|
||||
Method method = SampleRestController.class.getDeclaredMethod("get");
|
||||
@@ -177,6 +195,10 @@ public class RequestMappingReflectiveProcessorTests {
|
||||
void post(@RequestBody Request request) {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
void postForm(@ModelAttribute Request request) {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ResponseBody
|
||||
String message() {
|
||||
|
||||
Reference in New Issue
Block a user