|
|
|
|
@ -10,6 +10,7 @@ import org.springframework.core.ResolvableType
@@ -10,6 +10,7 @@ import org.springframework.core.ResolvableType
|
|
|
|
|
* Tests for `ConstructorParametersBinder`. |
|
|
|
|
* |
|
|
|
|
* @author Stephane Nicoll |
|
|
|
|
* @author Scott Frederick |
|
|
|
|
*/ |
|
|
|
|
class KotlinConstructorParametersBinderTests { |
|
|
|
|
|
|
|
|
|
@ -187,6 +188,15 @@ class KotlinConstructorParametersBinderTests {
@@ -187,6 +188,15 @@ class KotlinConstructorParametersBinderTests {
|
|
|
|
|
assertThat(bean.value.get("bar")).isEqualTo("baz"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `Bind to named constructor parameter`() { |
|
|
|
|
val source = MockConfigurationPropertySource() |
|
|
|
|
source.put("foo.string-value", "test") |
|
|
|
|
val binder = Binder(source) |
|
|
|
|
val bean = binder.bind("foo", Bindable.of(ExampleNamedParameterBean::class.java)).get() |
|
|
|
|
assertThat(bean.stringDataValue).isEqualTo("test") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class ExampleValueBean(val intValue: Int?, val longValue: Long?, |
|
|
|
|
val booleanValue: Boolean?, val stringValue: String?, |
|
|
|
|
val enumValue: ExampleEnum?) |
|
|
|
|
@ -228,6 +238,8 @@ class KotlinConstructorParametersBinderTests {
@@ -228,6 +238,8 @@ class KotlinConstructorParametersBinderTests {
|
|
|
|
|
val stringValue: String = "my data", |
|
|
|
|
val enumValue: ExampleEnum = ExampleEnum.BAR_BAZ) |
|
|
|
|
|
|
|
|
|
data class ExampleNamedParameterBean(@Name("stringValue") val stringDataValue: String) |
|
|
|
|
|
|
|
|
|
data class GenericValue<T>( |
|
|
|
|
val value: T |
|
|
|
|
) |
|
|
|
|
|