use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BinderTests method bindToJavaBeanShouldReturnPopulatedBean.
@Test
void bindToJavaBeanShouldReturnPopulatedBean() {
this.sources.add(new MockConfigurationPropertySource("foo.value", "bar"));
JavaBean result = this.binder.bind("foo", Bindable.of(JavaBean.class)).get();
assertThat(result.getValue()).isEqualTo("bar");
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class BinderTests method bindToJavaBeanWhenHasPropertyWithSameNameShouldStillBind.
@Test
void bindToJavaBeanWhenHasPropertyWithSameNameShouldStillBind() {
// gh-10945
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo", "boom");
source.put("foo.value", "bar");
this.sources.add(source);
JavaBean result = this.binder.bind("foo", Bindable.of(JavaBean.class)).get();
assertThat(result.getValue()).isEqualTo("bar");
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionShouldReturnPopulatedCollection.
@Test
void bindToCollectionShouldReturnPopulatedCollection() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo[0]", "1");
source.put("foo[1]", "2");
source.put("foo[2]", "3");
this.sources.add(source);
List<Integer> result = this.binder.bind("foo", INTEGER_LIST).get();
assertThat(result).containsExactly(1, 2, 3);
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWhenCommaListWithPlaceholdersShouldReturnPopulatedCollection.
@Test
void bindToCollectionWhenCommaListWithPlaceholdersShouldReturnPopulatedCollection() {
StandardEnvironment environment = new StandardEnvironment();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "bar=1,2,3");
this.binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment));
this.sources.add(new MockConfigurationPropertySource("foo", "${bar}"));
List<Integer> result = this.binder.bind("foo", INTEGER_LIST).get();
assertThat(result).containsExactly(1, 2, 3);
}
use of org.springframework.boot.context.properties.source.MockConfigurationPropertySource in project spring-boot by spring-projects.
the class CollectionBinderTests method bindToCollectionWhenItemContainsCommasShouldReturnPopulatedCollection.
@Test
void bindToCollectionWhenItemContainsCommasShouldReturnPopulatedCollection() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo[0]", "1,2");
source.put("foo[1]", "3");
this.sources.add(source);
List<String> result = this.binder.bind("foo", STRING_LIST).get();
assertThat(result).containsExactly("1,2", "3");
}
Aggregations