|
35 | 35 | import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
|
36 | 36 | import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
37 | 37 | import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrarTests.BaseProperties.InheritedNested;
|
| 38 | +import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrarTests.ComplexNestedProperties.ListenerRetry; |
| 39 | +import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrarTests.ComplexNestedProperties.Retry; |
| 40 | +import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrarTests.ComplexNestedProperties.Simple; |
38 | 41 | import org.springframework.context.ApplicationContext;
|
39 | 42 | import org.springframework.context.ApplicationContextAware;
|
40 | 43 | import org.springframework.context.EnvironmentAware;
|
@@ -259,6 +262,23 @@ void registerHintsWhenHasInheritedNestedProperties() {
|
259 | 262 | .satisfies(javaBeanBinding(InheritedNested.class, "getAlpha", "setAlpha"));
|
260 | 263 | }
|
261 | 264 |
|
| 265 | + @Test |
| 266 | + void registerHintsWhenHasComplexNestedProperties() { |
| 267 | + RuntimeHints runtimeHints = registerHints(ComplexNestedProperties.class); |
| 268 | + assertThat(runtimeHints.reflection().typeHints()).hasSize(4); |
| 269 | + assertThat(runtimeHints.reflection().getTypeHint(Retry.class)).satisfies((entry) -> { |
| 270 | + assertThat(entry.getMemberCategories()).isEmpty(); |
| 271 | + assertThat(entry.methods()).extracting(ExecutableHint::getName) |
| 272 | + .containsExactlyInAnyOrder("getCount", "setCount"); |
| 273 | + }); |
| 274 | + assertThat(runtimeHints.reflection().getTypeHint(ListenerRetry.class)) |
| 275 | + .satisfies(javaBeanBinding(ListenerRetry.class, "isStateless", "setStateless")); |
| 276 | + assertThat(runtimeHints.reflection().getTypeHint(Simple.class)) |
| 277 | + .satisfies(javaBeanBinding(Simple.class, "getRetry")); |
| 278 | + assertThat(runtimeHints.reflection().getTypeHint(ComplexNestedProperties.class)) |
| 279 | + .satisfies(javaBeanBinding(ComplexNestedProperties.class, "getSimple")); |
| 280 | + } |
| 281 | + |
262 | 282 | private Consumer<TypeHint> javaBeanBinding(Class<?> type, String... expectedMethods) {
|
263 | 283 | return javaBeanBinding(type, type.getDeclaredConstructors()[0], expectedMethods);
|
264 | 284 | }
|
@@ -723,4 +743,52 @@ public void setBravo(String bravo) {
|
723 | 743 |
|
724 | 744 | }
|
725 | 745 |
|
| 746 | + public static class ComplexNestedProperties { |
| 747 | + |
| 748 | + private final Simple simple = new Simple(); |
| 749 | + |
| 750 | + public Simple getSimple() { |
| 751 | + return this.simple; |
| 752 | + } |
| 753 | + |
| 754 | + public static class Simple { |
| 755 | + |
| 756 | + private final ListenerRetry retry = new ListenerRetry(); |
| 757 | + |
| 758 | + public ListenerRetry getRetry() { |
| 759 | + return this.retry; |
| 760 | + } |
| 761 | + |
| 762 | + } |
| 763 | + |
| 764 | + public abstract static class Retry { |
| 765 | + |
| 766 | + private int count = 5; |
| 767 | + |
| 768 | + public int getCount() { |
| 769 | + return this.count; |
| 770 | + } |
| 771 | + |
| 772 | + public void setCount(int count) { |
| 773 | + this.count = count; |
| 774 | + } |
| 775 | + |
| 776 | + } |
| 777 | + |
| 778 | + public static class ListenerRetry extends Retry { |
| 779 | + |
| 780 | + private boolean stateless; |
| 781 | + |
| 782 | + public boolean isStateless() { |
| 783 | + return this.stateless; |
| 784 | + } |
| 785 | + |
| 786 | + public void setStateless(boolean stateless) { |
| 787 | + this.stateless = stateless; |
| 788 | + } |
| 789 | + |
| 790 | + } |
| 791 | + |
| 792 | + } |
| 793 | + |
726 | 794 | }
|
0 commit comments