28
28
29
29
import javax .lang .model .element .Modifier ;
30
30
31
- import org .junit .jupiter .api .BeforeEach ;
32
31
import org .junit .jupiter .api .Nested ;
33
32
import org .junit .jupiter .api .Test ;
34
33
import org .reactivestreams .Publisher ;
@@ -311,7 +310,7 @@ void propertyValuesWhenContainsBeanReference() {
311
310
assertThat (actual .getPropertyValues ().contains ("myService" )).isTrue ();
312
311
assertThat (actual .getPropertyValues ().get ("myService" ))
313
312
.isInstanceOfSatisfying (RuntimeBeanReference .class ,
314
- beanReference -> assertThat (beanReference .getBeanName ()).isEqualTo ("test" ));
313
+ beanReference -> assertThat (beanReference .getBeanName ()).isEqualTo ("test" ));
315
314
});
316
315
}
317
316
@@ -361,7 +360,7 @@ void propertyValuesWhenValuesOnFactoryBeanClass() {
361
360
assertThat (actual .getPropertyValues ().get ("prefix" )).isEqualTo ("Hello" );
362
361
assertThat (actual .getPropertyValues ().get ("name" )).isEqualTo ("World" );
363
362
});
364
- assertHasMethodInvokeHints (PropertyValuesFactoryBean .class , "setPrefix" , "setName" );
363
+ assertHasMethodInvokeHints (PropertyValuesFactoryBean .class , "setPrefix" , "setName" );
365
364
assertHasDeclaredFieldsHint (PropertyValuesFactoryBean .class );
366
365
}
367
366
@@ -440,48 +439,50 @@ void multipleItems() {
440
439
@ Nested
441
440
class InitDestroyMethodTests {
442
441
443
- private final String privateInitMethod = InitDestroyBean .class .getName () + ".privateInit" ;
444
- private final String privateDestroyMethod = InitDestroyBean .class .getName () + ".privateDestroy" ;
442
+ private static final String privateInitMethod = InitDestroyBean .class .getName () + ".privateInit" ;
445
443
446
- @ BeforeEach
447
- void setTargetType () {
448
- beanDefinition .setTargetType (InitDestroyBean .class );
449
- }
444
+ private static final String privateDestroyMethod = InitDestroyBean .class .getName () + ".privateDestroy" ;
450
445
451
446
@ Test
452
447
void noInitMethod () {
448
+ beanDefinition .setTargetType (InitDestroyBean .class );
453
449
compile ((beanDef , compiled ) -> assertThat (beanDef .getInitMethodNames ()).isNull ());
454
450
}
455
451
456
452
@ Test
457
453
void singleInitMethod () {
454
+ beanDefinition .setTargetType (InitDestroyBean .class );
458
455
beanDefinition .setInitMethodName ("init" );
459
456
compile ((beanDef , compiled ) -> assertThat (beanDef .getInitMethodNames ()).containsExactly ("init" ));
460
457
assertHasMethodInvokeHints (InitDestroyBean .class , "init" );
461
458
}
462
459
463
460
@ Test
464
461
void privateInitMethod () {
462
+ beanDefinition .setTargetType (InitDestroyBean .class );
465
463
beanDefinition .setInitMethodName (privateInitMethod );
466
464
compile ((beanDef , compiled ) -> assertThat (beanDef .getInitMethodNames ()).containsExactly (privateInitMethod ));
467
465
assertHasMethodInvokeHints (InitDestroyBean .class , "privateInit" );
468
466
}
469
467
470
468
@ Test
471
469
void multipleInitMethods () {
470
+ beanDefinition .setTargetType (InitDestroyBean .class );
472
471
beanDefinition .setInitMethodNames ("init" , privateInitMethod );
473
472
compile ((beanDef , compiled ) -> assertThat (beanDef .getInitMethodNames ()).containsExactly ("init" , privateInitMethod ));
474
473
assertHasMethodInvokeHints (InitDestroyBean .class , "init" , "privateInit" );
475
474
}
476
475
477
476
@ Test
478
477
void noDestroyMethod () {
478
+ beanDefinition .setTargetType (InitDestroyBean .class );
479
479
compile ((beanDef , compiled ) -> assertThat (beanDef .getDestroyMethodNames ()).isNull ());
480
480
assertReflectionOnPublisher ();
481
481
}
482
482
483
483
@ Test
484
484
void singleDestroyMethod () {
485
+ beanDefinition .setTargetType (InitDestroyBean .class );
485
486
beanDefinition .setDestroyMethodName ("destroy" );
486
487
compile ((beanDef , compiled ) -> assertThat (beanDef .getDestroyMethodNames ()).containsExactly ("destroy" ));
487
488
assertHasMethodInvokeHints (InitDestroyBean .class , "destroy" );
@@ -490,6 +491,7 @@ void singleDestroyMethod() {
490
491
491
492
@ Test
492
493
void privateDestroyMethod () {
494
+ beanDefinition .setTargetType (InitDestroyBean .class );
493
495
beanDefinition .setDestroyMethodName (privateDestroyMethod );
494
496
compile ((beanDef , compiled ) -> assertThat (beanDef .getDestroyMethodNames ()).containsExactly (privateDestroyMethod ));
495
497
assertHasMethodInvokeHints (InitDestroyBean .class , "privateDestroy" );
@@ -498,6 +500,7 @@ void privateDestroyMethod() {
498
500
499
501
@ Test
500
502
void multipleDestroyMethods () {
503
+ beanDefinition .setTargetType (InitDestroyBean .class );
501
504
beanDefinition .setDestroyMethodNames ("destroy" , privateDestroyMethod );
502
505
compile ((beanDef , compiled ) -> assertThat (beanDef .getDestroyMethodNames ()).containsExactly ("destroy" , privateDestroyMethod ));
503
506
assertHasMethodInvokeHints (InitDestroyBean .class , "destroy" , "privateDestroy" );
@@ -512,8 +515,8 @@ private void assertReflectionOnPublisher() {
512
515
513
516
private void assertHasMethodInvokeHints (Class <?> beanType , String ... methodNames ) {
514
517
assertThat (methodNames ).allMatch (methodName -> RuntimeHintsPredicates .reflection ()
515
- .onMethod (beanType , methodName ).invoke ()
516
- .test (this .generationContext .getRuntimeHints ()));
518
+ .onMethod (beanType , methodName ).invoke ()
519
+ .test (this .generationContext .getRuntimeHints ()));
517
520
}
518
521
519
522
private void assertHasDeclaredFieldsHint (Class <?> beanType ) {
0 commit comments