use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToNestedCollectionWhenEmptyStringShouldReturnEmptyCollection.
@Test
void bindToNestedCollectionWhenEmptyStringShouldReturnEmptyCollection() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.value", "one");
source.put("foo.foos", "");
this.sources.add(source);
Bindable<BeanWithNestedCollection> target = Bindable.of(BeanWithNestedCollection.class);
BeanWithNestedCollection foo = this.binder.bind("foo", target).get();
assertThat(foo.getValue()).isEqualTo("one");
assertThat(foo.getFoos()).isEmpty();
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWhenHasExistingCollectionButNoValueShouldReturnUnbound.
@Test
void bindToCollectionWhenHasExistingCollectionButNoValueShouldReturnUnbound() {
this.sources.add(new MockConfigurationPropertySource("faf[0]", "1"));
List<Integer> existing = new LinkedList<>();
existing.add(1000);
BindResult<List<Integer>> result = this.binder.bind("foo", INTEGER_LIST.withExistingValue(existing));
assertThat(result.isBound()).isFalse();
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BinderTests method bindToJavaBeanWhenHandlerOnStartReturnsNullShouldReturnUnbound.
@Test
void bindToJavaBeanWhenHandlerOnStartReturnsNullShouldReturnUnbound() {
// gh-18129
this.sources.add(new MockConfigurationPropertySource("foo.value", "bar"));
BindResult<JavaBean> result = this.binder.bind("foo", Bindable.of(JavaBean.class), new BindHandler() {
@Override
public <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) {
return null;
}
});
assertThat(result.isBound()).isFalse();
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BinderTests method bindToBeanWithCycle.
@Test
void bindToBeanWithCycle() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
this.sources.add(source.nonIterable());
Bindable<CycleBean1> target = Bindable.of(CycleBean1.class);
this.binder.bind("foo", target);
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BinderTests method bindToJavaBeanWithPublicConstructor.
private JavaBeanWithPublicConstructor bindToJavaBeanWithPublicConstructor(Bindable<JavaBeanWithPublicConstructor> bindable) {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo", "constructor");
source.put("foo.value", "setter");
this.sources.add(source);
return this.binder.bindOrCreate("foo", bindable);
}
Aggregations