@@ -105,6 +105,23 @@ void generateBeanDefinitionMethodGeneratesMethod() {
105
105
});
106
106
}
107
107
108
+ @ Test // gh-29556
109
+ void generateBeanDefinitionMethodGeneratesMethodWithInstanceSupplier () {
110
+ RegisteredBean registeredBean = registerBean (new RootBeanDefinition (TestBean .class , TestBean ::new ));
111
+ BeanDefinitionMethodGenerator generator = new BeanDefinitionMethodGenerator (
112
+ this .methodGeneratorFactory , registeredBean , null ,
113
+ List .of ((generationContext , beanRegistrationCode ) -> { }));
114
+ MethodReference method = generator .generateBeanDefinitionMethod (
115
+ this .generationContext , this .beanRegistrationsCode );
116
+ compile (method , (actual , compiled ) -> {
117
+ SourceFile sourceFile = compiled .getSourceFile (".*BeanDefinitions" );
118
+ assertThat (sourceFile ).contains ("Get the bean definition for 'testBean'" );
119
+ assertThat (sourceFile ).contains ("beanType = TestBean.class" );
120
+ assertThat (sourceFile ).contains ("setInstanceSupplier(TestBean::new)" );
121
+ assertThat (actual ).isInstanceOf (RootBeanDefinition .class );
122
+ });
123
+ }
124
+
108
125
@ Test
109
126
void generateBeanDefinitionMethodWhenHasInnerClassTargetMethodGeneratesMethod () {
110
127
this .beanFactory .registerBeanDefinition ("testBeanConfiguration" , new RootBeanDefinition (
@@ -493,8 +510,8 @@ void generateBeanDefinitionMethodWhenBeanIsOfPrimitiveType() {
493
510
testBeanDefinitionMethodInCurrentFile (Boolean .class , beanDefinition );
494
511
}
495
512
496
- @ Test
497
- void throwExceptionWithInstanceSupplier () {
513
+ @ Test // gh-29556
514
+ void throwExceptionWithInstanceSupplierWithoutAotContribution () {
498
515
RegisteredBean registeredBean = registerBean (new RootBeanDefinition (TestBean .class , TestBean ::new ));
499
516
assertThatIllegalArgumentException ().isThrownBy (() -> new BeanDefinitionMethodGenerator (
500
517
this .methodGeneratorFactory , registeredBean , null ,
0 commit comments