Skip to content

Commit b85fcb6

Browse files
committed
Polish
1 parent 134bb6e commit b85fcb6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanDefinitionPropertiesCodeGeneratorTests.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import javax.lang.model.element.Modifier;
3030

31-
import org.junit.jupiter.api.BeforeEach;
3231
import org.junit.jupiter.api.Nested;
3332
import org.junit.jupiter.api.Test;
3433
import org.reactivestreams.Publisher;
@@ -311,7 +310,7 @@ void propertyValuesWhenContainsBeanReference() {
311310
assertThat(actual.getPropertyValues().contains("myService")).isTrue();
312311
assertThat(actual.getPropertyValues().get("myService"))
313312
.isInstanceOfSatisfying(RuntimeBeanReference.class,
314-
beanReference -> assertThat(beanReference.getBeanName()).isEqualTo("test"));
313+
beanReference -> assertThat(beanReference.getBeanName()).isEqualTo("test"));
315314
});
316315
}
317316

@@ -361,7 +360,7 @@ void propertyValuesWhenValuesOnFactoryBeanClass() {
361360
assertThat(actual.getPropertyValues().get("prefix")).isEqualTo("Hello");
362361
assertThat(actual.getPropertyValues().get("name")).isEqualTo("World");
363362
});
364-
assertHasMethodInvokeHints(PropertyValuesFactoryBean.class, "setPrefix", "setName" );
363+
assertHasMethodInvokeHints(PropertyValuesFactoryBean.class, "setPrefix", "setName");
365364
assertHasDeclaredFieldsHint(PropertyValuesFactoryBean.class);
366365
}
367366

@@ -440,48 +439,50 @@ void multipleItems() {
440439
@Nested
441440
class InitDestroyMethodTests {
442441

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";
445443

446-
@BeforeEach
447-
void setTargetType() {
448-
beanDefinition.setTargetType(InitDestroyBean.class);
449-
}
444+
private static final String privateDestroyMethod = InitDestroyBean.class.getName() + ".privateDestroy";
450445

451446
@Test
452447
void noInitMethod() {
448+
beanDefinition.setTargetType(InitDestroyBean.class);
453449
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).isNull());
454450
}
455451

456452
@Test
457453
void singleInitMethod() {
454+
beanDefinition.setTargetType(InitDestroyBean.class);
458455
beanDefinition.setInitMethodName("init");
459456
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init"));
460457
assertHasMethodInvokeHints(InitDestroyBean.class, "init");
461458
}
462459

463460
@Test
464461
void privateInitMethod() {
462+
beanDefinition.setTargetType(InitDestroyBean.class);
465463
beanDefinition.setInitMethodName(privateInitMethod);
466464
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly(privateInitMethod));
467465
assertHasMethodInvokeHints(InitDestroyBean.class, "privateInit");
468466
}
469467

470468
@Test
471469
void multipleInitMethods() {
470+
beanDefinition.setTargetType(InitDestroyBean.class);
472471
beanDefinition.setInitMethodNames("init", privateInitMethod);
473472
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init", privateInitMethod));
474473
assertHasMethodInvokeHints(InitDestroyBean.class, "init", "privateInit");
475474
}
476475

477476
@Test
478477
void noDestroyMethod() {
478+
beanDefinition.setTargetType(InitDestroyBean.class);
479479
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).isNull());
480480
assertReflectionOnPublisher();
481481
}
482482

483483
@Test
484484
void singleDestroyMethod() {
485+
beanDefinition.setTargetType(InitDestroyBean.class);
485486
beanDefinition.setDestroyMethodName("destroy");
486487
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy"));
487488
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy");
@@ -490,6 +491,7 @@ void singleDestroyMethod() {
490491

491492
@Test
492493
void privateDestroyMethod() {
494+
beanDefinition.setTargetType(InitDestroyBean.class);
493495
beanDefinition.setDestroyMethodName(privateDestroyMethod);
494496
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly(privateDestroyMethod));
495497
assertHasMethodInvokeHints(InitDestroyBean.class, "privateDestroy");
@@ -498,6 +500,7 @@ void privateDestroyMethod() {
498500

499501
@Test
500502
void multipleDestroyMethods() {
503+
beanDefinition.setTargetType(InitDestroyBean.class);
501504
beanDefinition.setDestroyMethodNames("destroy", privateDestroyMethod);
502505
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy", privateDestroyMethod));
503506
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy", "privateDestroy");
@@ -512,8 +515,8 @@ private void assertReflectionOnPublisher() {
512515

513516
private void assertHasMethodInvokeHints(Class<?> beanType, String... methodNames) {
514517
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()));
517520
}
518521

519522
private void assertHasDeclaredFieldsHint(Class<?> beanType) {

0 commit comments

Comments
 (0)