|
34 | 34 | import org.springframework.boot.context.properties.BoundConfigurationProperties;
|
35 | 35 | import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
|
36 | 36 | import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
| 37 | +import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrarTests.BaseProperties.InheritedNested; |
37 | 38 | import org.springframework.context.ApplicationContext;
|
38 | 39 | import org.springframework.context.ApplicationContextAware;
|
39 | 40 | import org.springframework.context.EnvironmentAware;
|
@@ -243,6 +244,21 @@ void registerHintsWhenHasPackagePrivateGettersAndSetters() {
|
243 | 244 | "setBravo"));
|
244 | 245 | }
|
245 | 246 |
|
| 247 | + @Test |
| 248 | + void registerHintsWhenHasInheritedNestedProperties() { |
| 249 | + RuntimeHints runtimeHints = registerHints(ExtendingProperties.class); |
| 250 | + assertThat(runtimeHints.reflection().typeHints()).hasSize(3); |
| 251 | + assertThat(runtimeHints.reflection().getTypeHint(BaseProperties.class)).satisfies((entry) -> { |
| 252 | + assertThat(entry.getMemberCategories()).isEmpty(); |
| 253 | + assertThat(entry.methods()).extracting(ExecutableHint::getName) |
| 254 | + .containsExactlyInAnyOrder("getInheritedNested", "setInheritedNested"); |
| 255 | + }); |
| 256 | + assertThat(runtimeHints.reflection().getTypeHint(ExtendingProperties.class)) |
| 257 | + .satisfies(javaBeanBinding(ExtendingProperties.class, "getBravo", "setBravo")); |
| 258 | + assertThat(runtimeHints.reflection().getTypeHint(InheritedNested.class)) |
| 259 | + .satisfies(javaBeanBinding(InheritedNested.class, "getAlpha", "setAlpha")); |
| 260 | + } |
| 261 | + |
246 | 262 | private Consumer<TypeHint> javaBeanBinding(Class<?> type, String... expectedMethods) {
|
247 | 263 | return javaBeanBinding(type, type.getDeclaredConstructors()[0], expectedMethods);
|
248 | 264 | }
|
@@ -665,4 +681,46 @@ public void setField(String field) {
|
665 | 681 |
|
666 | 682 | }
|
667 | 683 |
|
| 684 | + public abstract static class BaseProperties { |
| 685 | + |
| 686 | + private InheritedNested inheritedNested; |
| 687 | + |
| 688 | + public InheritedNested getInheritedNested() { |
| 689 | + return this.inheritedNested; |
| 690 | + } |
| 691 | + |
| 692 | + public void setInheritedNested(InheritedNested inheritedNested) { |
| 693 | + this.inheritedNested = inheritedNested; |
| 694 | + } |
| 695 | + |
| 696 | + public static class InheritedNested { |
| 697 | + |
| 698 | + private String alpha; |
| 699 | + |
| 700 | + public String getAlpha() { |
| 701 | + return this.alpha; |
| 702 | + } |
| 703 | + |
| 704 | + public void setAlpha(String alpha) { |
| 705 | + this.alpha = alpha; |
| 706 | + } |
| 707 | + |
| 708 | + } |
| 709 | + |
| 710 | + } |
| 711 | + |
| 712 | + public static class ExtendingProperties extends BaseProperties { |
| 713 | + |
| 714 | + private String bravo; |
| 715 | + |
| 716 | + public String getBravo() { |
| 717 | + return this.bravo; |
| 718 | + } |
| 719 | + |
| 720 | + public void setBravo(String bravo) { |
| 721 | + this.bravo = bravo; |
| 722 | + } |
| 723 | + |
| 724 | + } |
| 725 | + |
668 | 726 | }
|
0 commit comments