|
|
@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.function.ThrowingConsumer;
|
|
|
|
import org.junit.jupiter.api.function.ThrowingConsumer;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationPropertiesBean.BindMethod;
|
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.bind.BindConstructorProvider;
|
|
|
|
import org.springframework.boot.context.properties.bind.BindConstructorProvider;
|
|
|
|
|
|
|
|
import org.springframework.boot.context.properties.bind.BindMethod;
|
|
|
|
import org.springframework.boot.context.properties.bind.Bindable;
|
|
|
|
import org.springframework.boot.context.properties.bind.Bindable;
|
|
|
|
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
|
|
|
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
@ -64,19 +64,19 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(component.getInstance()).isInstanceOf(AnnotatedComponent.class);
|
|
|
|
assertThat(component.getInstance()).isInstanceOf(AnnotatedComponent.class);
|
|
|
|
assertThat(component.getAnnotation()).isNotNull();
|
|
|
|
assertThat(component.getAnnotation()).isNotNull();
|
|
|
|
assertThat(component.getType()).isEqualTo(AnnotatedComponent.class);
|
|
|
|
assertThat(component.getType()).isEqualTo(AnnotatedComponent.class);
|
|
|
|
assertThat(component.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(component.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
ConfigurationPropertiesBean bean = all.get("annotatedBean");
|
|
|
|
ConfigurationPropertiesBean bean = all.get("annotatedBean");
|
|
|
|
assertThat(bean.getName()).isEqualTo("annotatedBean");
|
|
|
|
assertThat(bean.getName()).isEqualTo("annotatedBean");
|
|
|
|
assertThat(bean.getInstance()).isInstanceOf(AnnotatedBean.class);
|
|
|
|
assertThat(bean.getInstance()).isInstanceOf(AnnotatedBean.class);
|
|
|
|
assertThat(bean.getType()).isEqualTo(AnnotatedBean.class);
|
|
|
|
assertThat(bean.getType()).isEqualTo(AnnotatedBean.class);
|
|
|
|
assertThat(bean.getAnnotation()).isNotNull();
|
|
|
|
assertThat(bean.getAnnotation()).isNotNull();
|
|
|
|
assertThat(bean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
ConfigurationPropertiesBean valueObject = all.get(ValueObject.class.getName());
|
|
|
|
ConfigurationPropertiesBean valueObject = all.get(ValueObject.class.getName());
|
|
|
|
assertThat(valueObject.getName()).isEqualTo(ValueObject.class.getName());
|
|
|
|
assertThat(valueObject.getName()).isEqualTo(ValueObject.class.getName());
|
|
|
|
assertThat(valueObject.getInstance()).isInstanceOf(ValueObject.class);
|
|
|
|
assertThat(valueObject.getInstance()).isInstanceOf(ValueObject.class);
|
|
|
|
assertThat(valueObject.getType()).isEqualTo(ValueObject.class);
|
|
|
|
assertThat(valueObject.getType()).isEqualTo(ValueObject.class);
|
|
|
|
assertThat(valueObject.getAnnotation()).isNotNull();
|
|
|
|
assertThat(valueObject.getAnnotation()).isNotNull();
|
|
|
|
assertThat(valueObject.getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(valueObject.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -113,7 +113,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(AnnotatedComponent.class);
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(AnnotatedComponent.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedComponent.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedComponent.class);
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -125,7 +125,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +138,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -150,7 +150,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getInstance()).isInstanceOf(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedBean.class);
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getAnnotation().prefix()).isEqualTo("prefix");
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -158,7 +158,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
void getWhenHasFactoryMethodBindsUsingMethodReturnType() throws Throwable {
|
|
|
|
void getWhenHasFactoryMethodBindsUsingMethodReturnType() throws Throwable {
|
|
|
|
get(NonAnnotatedGenericBeanConfiguration.class, "nonAnnotatedGenericBean", (propertiesBean) -> {
|
|
|
|
get(NonAnnotatedGenericBeanConfiguration.class, "nonAnnotatedGenericBean", (propertiesBean) -> {
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedGenericBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(NonAnnotatedGenericBean.class);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
assertThat(type.resolve()).isEqualTo(NonAnnotatedGenericBean.class);
|
|
|
|
assertThat(type.resolve()).isEqualTo(NonAnnotatedGenericBean.class);
|
|
|
|
assertThat(type.resolveGeneric(0)).isEqualTo(String.class);
|
|
|
|
assertThat(type.resolveGeneric(0)).isEqualTo(String.class);
|
|
|
@ -169,7 +169,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
void getWhenHasFactoryMethodWithoutAnnotationBindsUsingMethodType() throws Throwable {
|
|
|
|
void getWhenHasFactoryMethodWithoutAnnotationBindsUsingMethodType() throws Throwable {
|
|
|
|
get(AnnotatedGenericBeanConfiguration.class, "annotatedGenericBean", (propertiesBean) -> {
|
|
|
|
get(AnnotatedGenericBeanConfiguration.class, "annotatedGenericBean", (propertiesBean) -> {
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedGenericBean.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedGenericBean.class);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
assertThat(type.resolve()).isEqualTo(AnnotatedGenericBean.class);
|
|
|
|
assertThat(type.resolve()).isEqualTo(AnnotatedGenericBean.class);
|
|
|
|
assertThat(type.resolveGeneric(0)).isEqualTo(String.class);
|
|
|
|
assertThat(type.resolveGeneric(0)).isEqualTo(String.class);
|
|
|
@ -180,7 +180,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
void getWhenHasNoFactoryMethodBindsUsingObjectType() throws Throwable {
|
|
|
|
void getWhenHasNoFactoryMethodBindsUsingObjectType() throws Throwable {
|
|
|
|
get(AnnotatedGenericComponent.class, "annotatedGenericComponent", (propertiesBean) -> {
|
|
|
|
get(AnnotatedGenericComponent.class, "annotatedGenericComponent", (propertiesBean) -> {
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedGenericComponent.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(AnnotatedGenericComponent.class);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
ResolvableType type = propertiesBean.asBindTarget().getType();
|
|
|
|
assertThat(type.resolve()).isEqualTo(AnnotatedGenericComponent.class);
|
|
|
|
assertThat(type.resolve()).isEqualTo(AnnotatedGenericComponent.class);
|
|
|
|
assertThat(type.getGeneric(0).resolve()).isNull();
|
|
|
|
assertThat(type.getGeneric(0).resolve()).isNull();
|
|
|
@ -224,7 +224,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean");
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean");
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(ConstructorBindingOnConstructor.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(ConstructorBindingOnConstructor.class);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
assertThat(target.getType()).isEqualTo(ResolvableType.forClass(ConstructorBindingOnConstructor.class));
|
|
|
|
assertThat(target.getType()).isEqualTo(ResolvableType.forClass(ConstructorBindingOnConstructor.class));
|
|
|
@ -234,14 +234,13 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Deprecated(since = "3.0.0", forRemoval = true)
|
|
|
|
|
|
|
|
void forValueObjectWithDeprecatedConstructorBindingAnnotatedClassReturnsBean() {
|
|
|
|
void forValueObjectWithDeprecatedConstructorBindingAnnotatedClassReturnsBean() {
|
|
|
|
ConfigurationPropertiesBean propertiesBean = ConfigurationPropertiesBean
|
|
|
|
ConfigurationPropertiesBean propertiesBean = ConfigurationPropertiesBean
|
|
|
|
.forValueObject(DeprecatedConstructorBindingOnConstructor.class, "valueObjectBean");
|
|
|
|
.forValueObject(DeprecatedConstructorBindingOnConstructor.class, "valueObjectBean");
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean");
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("valueObjectBean");
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(DeprecatedConstructorBindingOnConstructor.class);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(DeprecatedConstructorBindingOnConstructor.class);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
assertThat(target.getType())
|
|
|
|
assertThat(target.getType())
|
|
|
@ -269,7 +268,7 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("implicitBindingRecord");
|
|
|
|
assertThat(propertiesBean.getName()).isEqualTo("implicitBindingRecord");
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getInstance()).isNull();
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(implicitConstructorBinding);
|
|
|
|
assertThat(propertiesBean.getType()).isEqualTo(implicitConstructorBinding);
|
|
|
|
assertThat(propertiesBean.getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.asBindTarget().getBindMethod()).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
assertThat(propertiesBean.getAnnotation()).isNotNull();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
Bindable<?> target = propertiesBean.asBindTarget();
|
|
|
|
assertThat(target.getType()).isEqualTo(ResolvableType.forClass(implicitConstructorBinding));
|
|
|
|
assertThat(target.getType()).isEqualTo(ResolvableType.forClass(implicitConstructorBinding));
|
|
|
@ -292,64 +291,66 @@ class ConfigurationPropertiesBeanTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWhenNoConstructorBindingReturnsJavaBean() {
|
|
|
|
void deduceBindMethodWhenNoConstructorBindingReturnsJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(NoConstructorBinding.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(NoConstructorBinding.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWhenConstructorBindingOnConstructorReturnsValueObject() {
|
|
|
|
void deduceBindMethodWhenConstructorBindingOnConstructorReturnsValueObject() {
|
|
|
|
BindMethod bindType = BindMethod.get(ConstructorBindingOnConstructor.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(ConstructorBindingOnConstructor.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWhenNoConstructorBindingAnnotationOnSingleParameterizedConstructorReturnsValueObject() {
|
|
|
|
void deduceBindMethodWhenNoConstructorBindingAnnotationOnSingleParameterizedConstructorReturnsValueObject() {
|
|
|
|
BindMethod bindType = BindMethod.get(ConstructorBindingNoAnnotation.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(ConstructorBindingNoAnnotation.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.VALUE_OBJECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWhenConstructorBindingOnMultipleConstructorsThrowsException() {
|
|
|
|
void deduceBindMethodWhenConstructorBindingOnMultipleConstructorsThrowsException() {
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
.isThrownBy(() -> BindMethod.get(ConstructorBindingOnMultipleConstructors.class))
|
|
|
|
.isThrownBy(
|
|
|
|
|
|
|
|
() -> ConfigurationPropertiesBean.deduceBindMethod(ConstructorBindingOnMultipleConstructors.class))
|
|
|
|
.withMessage(ConstructorBindingOnMultipleConstructors.class.getName()
|
|
|
|
.withMessage(ConstructorBindingOnMultipleConstructors.class.getName()
|
|
|
|
+ " has more than one @ConstructorBinding constructor");
|
|
|
|
+ " has more than one @ConstructorBinding constructor");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWithMultipleConstructorsReturnJavaBean() {
|
|
|
|
void deduceBindMethodWithMultipleConstructorsReturnJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(NoConstructorBindingOnMultipleConstructors.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean
|
|
|
|
|
|
|
|
.deduceBindMethod(NoConstructorBindingOnMultipleConstructors.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWithNoArgConstructorReturnsJavaBean() {
|
|
|
|
void deduceBindMethodWithNoArgConstructorReturnsJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(JavaBeanWithNoArgConstructor.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(JavaBeanWithNoArgConstructor.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void bindMethodGetWithSingleArgAutowiredConstructorReturnsJavaBean() {
|
|
|
|
void deduceBindMethodWithSingleArgAutowiredConstructorReturnsJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(JavaBeanWithAutowiredConstructor.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(JavaBeanWithAutowiredConstructor.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void constructorBindingAndAutowiredConstructorsShouldThrowException() {
|
|
|
|
void constructorBindingAndAutowiredConstructorsShouldThrowException() {
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
assertThatIllegalStateException().isThrownBy(
|
|
|
|
.isThrownBy(() -> BindMethod.get(ConstructorBindingAndAutowiredConstructors.class));
|
|
|
|
() -> ConfigurationPropertiesBean.deduceBindMethod(ConstructorBindingAndAutowiredConstructors.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void innerClassWithSyntheticFieldShouldReturnJavaBean() {
|
|
|
|
void innerClassWithSyntheticFieldShouldReturnJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(Inner.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(Inner.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void innerClassWithParameterizedConstructorShouldReturnJavaBean() {
|
|
|
|
void innerClassWithParameterizedConstructorShouldReturnJavaBean() {
|
|
|
|
BindMethod bindType = BindMethod.get(ParameterizedConstructorInner.class);
|
|
|
|
BindMethod bindType = ConfigurationPropertiesBean.deduceBindMethod(ParameterizedConstructorInner.class);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
assertThat(bindType).isEqualTo(BindMethod.JAVA_BEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|