Add reflection hints for @RequestPart
Closes gh-29749
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -183,6 +183,24 @@ public class ControllerMappingReflectiveProcessorTests {
|
||||
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleController.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerReflectiveHintsForMethodWithPartToConvert() throws NoSuchMethodException {
|
||||
Method method = SampleController.class.getDeclaredMethod("postPartToConvert", 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)));
|
||||
}
|
||||
|
||||
static class SampleController {
|
||||
|
||||
@GetMapping
|
||||
@@ -225,6 +243,10 @@ public class ControllerMappingReflectiveProcessorTests {
|
||||
void postRawHttpEntity(HttpEntity entity) {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
void postPartToConvert(@RequestPart Request request) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RestController
|
||||
|
||||
Reference in New Issue
Block a user