Register hints for superclass in BindingReflectionHintsRegistrar

Closes gh-31552
This commit is contained in:
Sébastien Deleuze
2023-11-09 11:08:41 +01:00
parent 1e78cc35e5
commit 620f558547
2 changed files with 29 additions and 0 deletions

View File

@@ -63,6 +63,28 @@ class BindingReflectionHintsRegistrarTests {
});
}
@Test
void registerTypeForSerializationWithExtendingClass() {
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleExtendingClass.class);
assertThat(this.hints.reflection().typeHints()).satisfiesExactlyInAnyOrder(
typeHint -> {
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleEmptyClass.class));
assertThat(typeHint.getMemberCategories()).containsExactlyInAnyOrder(
MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
assertThat(typeHint.constructors()).isEmpty();
assertThat(typeHint.fields()).isEmpty();
assertThat(typeHint.methods()).isEmpty();
},
typeHint -> {
assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleExtendingClass.class));
assertThat(typeHint.getMemberCategories()).containsExactlyInAnyOrder(
MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
assertThat(typeHint.constructors()).isEmpty();
assertThat(typeHint.fields()).isEmpty();
assertThat(typeHint.methods()).isEmpty();
});
}
@Test
void registerTypeForSerializationWithNoProperty() {
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleClassWithNoProperty.class);
@@ -284,6 +306,9 @@ class BindingReflectionHintsRegistrarTests {
static class SampleEmptyClass {
}
static class SampleExtendingClass extends SampleEmptyClass {
}
static class SampleClassWithNoProperty {
String name() {