use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BoundPropertiesTrackingBindHandlerTests method handlerShouldCallRecordBindingIfConfigurationPropertyIsNotNull.
@Test
void handlerShouldCallRecordBindingIfConfigurationPropertyIsNotNull() {
this.sources.add(new MockConfigurationPropertySource("foo.age", 4));
this.binder.bind("foo", Bindable.of(ExampleBean.class), this.handler);
then(this.consumer).should().accept(any(ConfigurationProperty.class));
then(this.consumer).should(never()).accept(null);
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWithNoDefaultConstructor.
@Test
void bindToCollectionWithNoDefaultConstructor() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.items", "a,b,c,c");
this.sources.add(source);
ExampleCustomNoDefaultConstructorBean result = this.binder.bind("foo", ExampleCustomNoDefaultConstructorBean.class).get();
assertThat(result.getItems()).hasSize(4);
assertThat(result.getItems()).containsExactly("a", "b", "c", "c");
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWithDefaultConstructor.
@Test
void bindToCollectionWithDefaultConstructor() {
// gh-12322
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.items", "a,b,c,c");
this.sources.add(source);
ExampleCustomWithDefaultConstructorBean result = this.binder.bind("foo", ExampleCustomWithDefaultConstructorBean.class).get();
assertThat(result.getItems()).hasSize(4);
assertThat(result.getItems()).containsExactly("a", "b", "c", "c");
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWhenMultipleSourceShouldOnlyUseFirst.
@Test
void bindToCollectionWhenMultipleSourceShouldOnlyUseFirst() {
MockConfigurationPropertySource source1 = new MockConfigurationPropertySource();
source1.put("bar", "baz");
this.sources.add(source1);
MockConfigurationPropertySource source2 = new MockConfigurationPropertySource();
source2.put("foo[0]", "1");
source2.put("foo[1]", "2");
this.sources.add(source2);
MockConfigurationPropertySource source3 = new MockConfigurationPropertySource();
source3.put("foo[0]", "7");
source3.put("foo[1]", "8");
source3.put("foo[2]", "9");
this.sources.add(source3);
List<Integer> result = this.binder.bind("foo", INTEGER_LIST).get();
assertThat(result).containsExactly(1, 2);
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToBeanWithNestedCollectionAndNonIterableSourceShouldNotFail.
@Test
void bindToBeanWithNestedCollectionAndNonIterableSourceShouldNotFail() {
// gh-10702
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
this.sources.add(source.nonIterable());
Bindable<BeanWithNestedCollection> target = Bindable.of(BeanWithNestedCollection.class);
this.binder.bind("foo", target);
}
Aggregations