|
|
@ -15,6 +15,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package org.springframework.boot.context.properties.bind;
|
|
|
|
package org.springframework.boot.context.properties.bind;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +24,7 @@ import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
|
|
|
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
|
|
|
import org.springframework.boot.context.properties.source.MockConfigurationPropertySource;
|
|
|
|
import org.springframework.boot.context.properties.source.MockConfigurationPropertySource;
|
|
|
|
|
|
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +139,16 @@ class ConstructorParametersBinderTests {
|
|
|
|
assertThat(bean.getCustomList()).containsOnly("x,y,z");
|
|
|
|
assertThat(bean.getCustomList()).containsOnly("x,y,z");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void bindWithAnnotations() {
|
|
|
|
|
|
|
|
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
|
|
|
|
|
|
|
source.put("foo.date", "2014-04-01");
|
|
|
|
|
|
|
|
this.sources.add(source);
|
|
|
|
|
|
|
|
ConverterAnnotatedExampleBean bean = this.binder.bind("foo", Bindable.of(ConverterAnnotatedExampleBean.class))
|
|
|
|
|
|
|
|
.get();
|
|
|
|
|
|
|
|
assertThat(bean.getDate().toString()).isEqualTo("2014-04-01");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class ExampleValueBean {
|
|
|
|
public static class ExampleValueBean {
|
|
|
|
|
|
|
|
|
|
|
|
private final int intValue;
|
|
|
|
private final int intValue;
|
|
|
@ -265,4 +277,18 @@ class ConstructorParametersBinderTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class ConverterAnnotatedExampleBean {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final LocalDate date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConverterAnnotatedExampleBean(@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
|
|
|
|
|
|
|
|
this.date = date;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LocalDate getDate() {
|
|
|
|
|
|
|
|
return this.date;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|