Add support for records in BindingReflectionHintsRegistrar
Closes gh-28721
This commit is contained in:
@@ -203,6 +203,26 @@ public class BindingReflectionHintsRegistrarTests {
|
||||
.satisfies(typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleEnum.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void registerTypeForSerializationWithRecord() {
|
||||
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleRecord.class);
|
||||
assertThat(this.hints.reflection().typeHints()).satisfiesExactlyInAnyOrder(
|
||||
typeHint -> {
|
||||
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(String.class));
|
||||
assertThat(typeHint.getMemberCategories()).isEmpty();
|
||||
assertThat(typeHint.constructors()).isEmpty();
|
||||
assertThat(typeHint.fields()).isEmpty();
|
||||
assertThat(typeHint.methods()).isEmpty();
|
||||
},
|
||||
typeHint -> {
|
||||
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleRecord.class));
|
||||
assertThat(typeHint.methods()).singleElement().satisfies(methodHint -> {
|
||||
assertThat(methodHint.getName()).isEqualTo("name");
|
||||
assertThat(methodHint.getModes()).containsOnly(ExecutableMode.INVOKE);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static class SampleEmptyClass {
|
||||
}
|
||||
@@ -285,4 +305,6 @@ public class BindingReflectionHintsRegistrarTests {
|
||||
value1, value2
|
||||
}
|
||||
|
||||
record SampleRecord(String name) {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user