|
|
@ -10,6 +10,7 @@ import org.springframework.core.ResolvableType
|
|
|
|
* Tests for `ConstructorParametersBinder`.
|
|
|
|
* Tests for `ConstructorParametersBinder`.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
|
|
|
|
* @author Scott Frederick
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class KotlinConstructorParametersBinderTests {
|
|
|
|
class KotlinConstructorParametersBinderTests {
|
|
|
|
|
|
|
|
|
|
|
@ -187,6 +188,15 @@ class KotlinConstructorParametersBinderTests {
|
|
|
|
assertThat(bean.value.get("bar")).isEqualTo("baz");
|
|
|
|
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?,
|
|
|
|
class ExampleValueBean(val intValue: Int?, val longValue: Long?,
|
|
|
|
val booleanValue: Boolean?, val stringValue: String?,
|
|
|
|
val booleanValue: Boolean?, val stringValue: String?,
|
|
|
|
val enumValue: ExampleEnum?)
|
|
|
|
val enumValue: ExampleEnum?)
|
|
|
@ -228,6 +238,8 @@ class KotlinConstructorParametersBinderTests {
|
|
|
|
val stringValue: String = "my data",
|
|
|
|
val stringValue: String = "my data",
|
|
|
|
val enumValue: ExampleEnum = ExampleEnum.BAR_BAZ)
|
|
|
|
val enumValue: ExampleEnum = ExampleEnum.BAR_BAZ)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data class ExampleNamedParameterBean(@Name("stringValue") val stringDataValue: String)
|
|
|
|
|
|
|
|
|
|
|
|
data class GenericValue<T>(
|
|
|
|
data class GenericValue<T>(
|
|
|
|
val value: T
|
|
|
|
val value: T
|
|
|
|
)
|
|
|
|
)
|
|
|
|