Add support for records in BindingReflectionHintsRegistrar

Closes gh-28721
This commit is contained in:
Sébastien Deleuze
2022-06-30 11:43:16 +02:00
parent 89a6101b2e
commit da68781b9e
2 changed files with 52 additions and 12 deletions

View File

@@ -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) {}
}