|
34 | 34 | import org.reactivestreams.Publisher;
|
35 | 35 |
|
36 | 36 | import org.springframework.aot.generate.GeneratedClass;
|
| 37 | +import org.springframework.aot.hint.MemberCategory; |
37 | 38 | import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
38 | 39 | import org.springframework.aot.test.generate.TestGenerationContext;
|
39 | 40 | import org.springframework.beans.factory.FactoryBean;
|
@@ -240,6 +241,21 @@ void propertyValuesWhenValues() {
|
240 | 241 | assertThat(actual.getPropertyValues().get("spring")).isEqualTo("framework");
|
241 | 242 | });
|
242 | 243 | assertHasMethodInvokeHints(PropertyValuesBean.class, "setTest", "setSpring");
|
| 244 | + assertHasDecalredFieldsHint(PropertyValuesBean.class); |
| 245 | + } |
| 246 | + |
| 247 | + @Test |
| 248 | + void propertyValuesWhenValuesOnParentClass() { |
| 249 | + this.beanDefinition.setTargetType(ExtendedPropertyValuesBean.class); |
| 250 | + this.beanDefinition.getPropertyValues().add("test", String.class); |
| 251 | + this.beanDefinition.getPropertyValues().add("spring", "framework"); |
| 252 | + compile((actual, compiled) -> { |
| 253 | + assertThat(actual.getPropertyValues().get("test")).isEqualTo(String.class); |
| 254 | + assertThat(actual.getPropertyValues().get("spring")).isEqualTo("framework"); |
| 255 | + }); |
| 256 | + assertHasMethodInvokeHints(PropertyValuesBean.class, "setTest", "setSpring"); |
| 257 | + assertHasDecalredFieldsHint(ExtendedPropertyValuesBean.class); |
| 258 | + assertHasDecalredFieldsHint(PropertyValuesBean.class); |
243 | 259 | }
|
244 | 260 |
|
245 | 261 | @Test
|
@@ -300,6 +316,7 @@ void propertyValuesWhenValuesOnFactoryBeanClass() {
|
300 | 316 | assertThat(actual.getPropertyValues().get("name")).isEqualTo("World");
|
301 | 317 | });
|
302 | 318 | assertHasMethodInvokeHints(PropertyValuesFactoryBean.class, "setPrefix", "setName" );
|
| 319 | + assertHasDecalredFieldsHint(PropertyValuesFactoryBean.class); |
303 | 320 | }
|
304 | 321 |
|
305 | 322 | @Test
|
@@ -453,6 +470,12 @@ private void assertHasMethodInvokeHints(Class<?> beanType, String... methodNames
|
453 | 470 | .test(this.generationContext.getRuntimeHints()));
|
454 | 471 | }
|
455 | 472 |
|
| 473 | + private void assertHasDecalredFieldsHint(Class<?> beanType) { |
| 474 | + assertThat(RuntimeHintsPredicates.reflection() |
| 475 | + .onType(beanType).withMemberCategory(MemberCategory.DECLARED_FIELDS)) |
| 476 | + .accepts(this.generationContext.getRuntimeHints()); |
| 477 | + } |
| 478 | + |
456 | 479 | private void compile(BiConsumer<RootBeanDefinition, Compiled> result) {
|
457 | 480 | compile(attribute -> true, result);
|
458 | 481 | }
|
@@ -524,6 +547,10 @@ public void setSpring(String spring) {
|
524 | 547 |
|
525 | 548 | }
|
526 | 549 |
|
| 550 | + static class ExtendedPropertyValuesBean extends PropertyValuesBean { |
| 551 | + |
| 552 | + } |
| 553 | + |
527 | 554 | static class PropertyValuesFactoryBean implements FactoryBean<String> {
|
528 | 555 |
|
529 | 556 | private String prefix;
|
|
0 commit comments