use of org.springframework.boot.context.properties.bind.BinderTests.ExampleEnum in project spring-boot by spring-projects.
the class MapBinderTests method bindToMapWithPlaceholdersShouldBeGreedyForScalars.
@Test
void bindToMapWithPlaceholdersShouldBeGreedyForScalars() {
StandardEnvironment environment = new StandardEnvironment();
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, "foo=boo");
MockConfigurationPropertySource source = new MockConfigurationPropertySource("foo.aaa.bbb.ccc", "baz-${foo}");
this.sources.add(source);
this.binder = new Binder(this.sources, new PropertySourcesPlaceholdersResolver(environment));
Map<String, ExampleEnum> result = this.binder.bind("foo", Bindable.mapOf(String.class, ExampleEnum.class)).get();
assertThat(result).containsEntry("aaa.bbb.ccc", ExampleEnum.BAZ_BOO);
}
use of org.springframework.boot.context.properties.bind.BinderTests.ExampleEnum in project spring-boot by spring-projects.
the class MapBinderTests method bindToMapShouldBeGreedyForScalars.
@Test
void bindToMapShouldBeGreedyForScalars() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.aaa.bbb.ccc", "foo-bar");
source.put("foo.bbb.ccc.ddd", "BAR_BAZ");
source.put("foo.ccc.ddd.eee", "bazboo");
this.sources.add(source);
Map<String, ExampleEnum> result = this.binder.bind("foo", Bindable.mapOf(String.class, ExampleEnum.class)).get();
assertThat(result).hasSize(3);
assertThat(result).containsEntry("aaa.bbb.ccc", ExampleEnum.FOO_BAR);
assertThat(result).containsEntry("bbb.ccc.ddd", ExampleEnum.BAR_BAZ);
assertThat(result).containsEntry("ccc.ddd.eee", ExampleEnum.BAZ_BOO);
}
Aggregations