Polish
This commit is contained in:
@@ -28,7 +28,6 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import javax.lang.model.element.Modifier;
|
import javax.lang.model.element.Modifier;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
@@ -311,7 +310,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
assertThat(actual.getPropertyValues().contains("myService")).isTrue();
|
assertThat(actual.getPropertyValues().contains("myService")).isTrue();
|
||||||
assertThat(actual.getPropertyValues().get("myService"))
|
assertThat(actual.getPropertyValues().get("myService"))
|
||||||
.isInstanceOfSatisfying(RuntimeBeanReference.class,
|
.isInstanceOfSatisfying(RuntimeBeanReference.class,
|
||||||
beanReference -> assertThat(beanReference.getBeanName()).isEqualTo("test"));
|
beanReference -> assertThat(beanReference.getBeanName()).isEqualTo("test"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +360,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
assertThat(actual.getPropertyValues().get("prefix")).isEqualTo("Hello");
|
assertThat(actual.getPropertyValues().get("prefix")).isEqualTo("Hello");
|
||||||
assertThat(actual.getPropertyValues().get("name")).isEqualTo("World");
|
assertThat(actual.getPropertyValues().get("name")).isEqualTo("World");
|
||||||
});
|
});
|
||||||
assertHasMethodInvokeHints(PropertyValuesFactoryBean.class, "setPrefix", "setName" );
|
assertHasMethodInvokeHints(PropertyValuesFactoryBean.class, "setPrefix", "setName");
|
||||||
assertHasDeclaredFieldsHint(PropertyValuesFactoryBean.class);
|
assertHasDeclaredFieldsHint(PropertyValuesFactoryBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,21 +439,19 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
@Nested
|
@Nested
|
||||||
class InitDestroyMethodTests {
|
class InitDestroyMethodTests {
|
||||||
|
|
||||||
private final String privateInitMethod = InitDestroyBean.class.getName() + ".privateInit";
|
private static final String privateInitMethod = InitDestroyBean.class.getName() + ".privateInit";
|
||||||
private final String privateDestroyMethod = InitDestroyBean.class.getName() + ".privateDestroy";
|
|
||||||
|
|
||||||
@BeforeEach
|
private static final String privateDestroyMethod = InitDestroyBean.class.getName() + ".privateDestroy";
|
||||||
void setTargetType() {
|
|
||||||
beanDefinition.setTargetType(InitDestroyBean.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void noInitMethod() {
|
void noInitMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).isNull());
|
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void singleInitMethod() {
|
void singleInitMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setInitMethodName("init");
|
beanDefinition.setInitMethodName("init");
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init"));
|
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init"));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "init");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "init");
|
||||||
@@ -462,6 +459,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void privateInitMethod() {
|
void privateInitMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setInitMethodName(privateInitMethod);
|
beanDefinition.setInitMethodName(privateInitMethod);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly(privateInitMethod));
|
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly(privateInitMethod));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "privateInit");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "privateInit");
|
||||||
@@ -469,6 +467,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void multipleInitMethods() {
|
void multipleInitMethods() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setInitMethodNames("init", privateInitMethod);
|
beanDefinition.setInitMethodNames("init", privateInitMethod);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init", privateInitMethod));
|
compile((beanDef, compiled) -> assertThat(beanDef.getInitMethodNames()).containsExactly("init", privateInitMethod));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "init", "privateInit");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "init", "privateInit");
|
||||||
@@ -476,12 +475,14 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void noDestroyMethod() {
|
void noDestroyMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).isNull());
|
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).isNull());
|
||||||
assertReflectionOnPublisher();
|
assertReflectionOnPublisher();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void singleDestroyMethod() {
|
void singleDestroyMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setDestroyMethodName("destroy");
|
beanDefinition.setDestroyMethodName("destroy");
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy"));
|
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy"));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy");
|
||||||
@@ -490,6 +491,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void privateDestroyMethod() {
|
void privateDestroyMethod() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setDestroyMethodName(privateDestroyMethod);
|
beanDefinition.setDestroyMethodName(privateDestroyMethod);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly(privateDestroyMethod));
|
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly(privateDestroyMethod));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "privateDestroy");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "privateDestroy");
|
||||||
@@ -498,6 +500,7 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void multipleDestroyMethods() {
|
void multipleDestroyMethods() {
|
||||||
|
beanDefinition.setTargetType(InitDestroyBean.class);
|
||||||
beanDefinition.setDestroyMethodNames("destroy", privateDestroyMethod);
|
beanDefinition.setDestroyMethodNames("destroy", privateDestroyMethod);
|
||||||
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy", privateDestroyMethod));
|
compile((beanDef, compiled) -> assertThat(beanDef.getDestroyMethodNames()).containsExactly("destroy", privateDestroyMethod));
|
||||||
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy", "privateDestroy");
|
assertHasMethodInvokeHints(InitDestroyBean.class, "destroy", "privateDestroy");
|
||||||
@@ -512,8 +515,8 @@ class BeanDefinitionPropertiesCodeGeneratorTests {
|
|||||||
|
|
||||||
private void assertHasMethodInvokeHints(Class<?> beanType, String... methodNames) {
|
private void assertHasMethodInvokeHints(Class<?> beanType, String... methodNames) {
|
||||||
assertThat(methodNames).allMatch(methodName -> RuntimeHintsPredicates.reflection()
|
assertThat(methodNames).allMatch(methodName -> RuntimeHintsPredicates.reflection()
|
||||||
.onMethod(beanType, methodName).invoke()
|
.onMethod(beanType, methodName).invoke()
|
||||||
.test(this.generationContext.getRuntimeHints()));
|
.test(this.generationContext.getRuntimeHints()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertHasDeclaredFieldsHint(Class<?> beanType) {
|
private void assertHasDeclaredFieldsHint(Class<?> beanType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user