FilteredIterableConfigurationPropertiesSourceTests Class — spring-boot Architecture
Architecture documentation for the FilteredIterableConfigurationPropertiesSourceTests class in FilteredIterableConfigurationPropertiesSourceTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSourceTests.java lines 36–125
class FilteredIterableConfigurationPropertiesSourceTests extends FilteredConfigurationPropertiesSourceTests {
@Test
void iteratorFiltersNames() {
MockConfigurationPropertySource source = (MockConfigurationPropertySource) createTestSource();
IterableConfigurationPropertySource filtered = source.filter(this::noBrackets);
assertThat(filtered.iterator()).toIterable()
.extracting(ConfigurationPropertyName::toString)
.containsExactly("a", "b", "c");
}
@Test
void containsDescendantOfUsesContents() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.bar.baz", "1");
source.put("foo.bar[0]", "1");
source.put("faf.bar[0]", "1");
IterableConfigurationPropertySource filtered = source.filter(this::noBrackets);
assertThat(filtered.containsDescendantOf(ConfigurationPropertyName.of("foo")))
.isEqualTo(ConfigurationPropertyState.PRESENT);
assertThat(filtered.containsDescendantOf(ConfigurationPropertyName.of("faf")))
.isEqualTo(ConfigurationPropertyState.ABSENT);
}
@Test
void iteratorWhenSpringPropertySourceFiltersNames() {
IterableConfigurationPropertySource testSource = (IterableConfigurationPropertySource) createTestSource();
Map<String, Object> map = new LinkedHashMap<>();
for (ConfigurationPropertyName name : testSource) {
ConfigurationProperty configurationProperty = testSource.getConfigurationProperty(name);
assertThat(configurationProperty).isNotNull();
map.put(name.toString(), configurationProperty.getValue());
}
PropertySource<?> propertySource = new OriginTrackedMapPropertySource("test", map, true);
SpringConfigurationPropertySource source = SpringConfigurationPropertySource.from(propertySource);
IterableConfigurationPropertySource filtered = (IterableConfigurationPropertySource) source
.filter(this::noBrackets);
assertThat(Extractors.byName("filteredNames").apply(filtered)).isNotNull();
assertThat(filtered.iterator()).toIterable()
.extracting(ConfigurationPropertyName::toString)
.containsExactly("a", "b", "c");
}
@Test
void iteratorWhenSpringPropertySourceAndAnotherFilterFiltersNames() {
IterableConfigurationPropertySource testSource = (IterableConfigurationPropertySource) createTestSource();
Map<String, Object> map = new LinkedHashMap<>();
for (ConfigurationPropertyName name : testSource) {
ConfigurationProperty configurationProperty = testSource.getConfigurationProperty(name);
assertThat(configurationProperty).isNotNull();
map.put(name.toString(), configurationProperty.getValue());
}
PropertySource<?> propertySource = new OriginTrackedMapPropertySource("test", map, true);
SpringConfigurationPropertySource source = SpringConfigurationPropertySource.from(propertySource);
IterableConfigurationPropertySource filtered = (IterableConfigurationPropertySource) source
.filter(this::noBrackets);
IterableConfigurationPropertySource secondFiltered = filtered.filter((name) -> !name.toString().contains("c"));
assertThat(Extractors.byName("filteredNames").apply(filtered)).isNotNull();
assertThat(secondFiltered.iterator()).toIterable()
.extracting(ConfigurationPropertyName::toString)
.containsExactly("a", "b");
}
@Test
void containsDescendantOfWhenSpringPropertySourceUsesContents() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("foo.bar.baz", "1");
map.put("foo.bar[0]", "1");
map.put("faf.bar[0]", "1");
PropertySource<?> propertySource = new OriginTrackedMapPropertySource("test", map, true);
SpringConfigurationPropertySource source = SpringConfigurationPropertySource.from(propertySource);
IterableConfigurationPropertySource filtered = (IterableConfigurationPropertySource) source
.filter(this::noBrackets);
assertThat(Extractors.byName("filteredNames").apply(filtered)).isNotNull();
assertThat(filtered.containsDescendantOf(ConfigurationPropertyName.of("foo")))
.isEqualTo(ConfigurationPropertyState.PRESENT);
assertThat(filtered.containsDescendantOf(ConfigurationPropertyName.of("faf")))
.isEqualTo(ConfigurationPropertyState.ABSENT);
}
@Override
protected ConfigurationPropertySource convertSource(MockConfigurationPropertySource source) {
return source;
}
private boolean noBrackets(ConfigurationPropertyName name) {
return !name.toString().contains("[");
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free