mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-27 04:19:03 +00:00
Merge branch 'main' into 4.0.x
This commit is contained in:
+3
@@ -41,6 +41,9 @@ class FilteredIterableConfigurationPropertiesSource extends FilteredConfiguratio
|
||||
this.filteredNames = new ConfigurationPropertyName[filterableNames.length];
|
||||
this.numerOfFilteredNames = 0;
|
||||
for (ConfigurationPropertyName name : filterableNames) {
|
||||
if (name == null) {
|
||||
break;
|
||||
}
|
||||
if (filter.test(name)) {
|
||||
this.filteredNames[this.numerOfFilteredNames++] = name;
|
||||
}
|
||||
|
||||
+18
@@ -74,6 +74,24 @@ class FilteredIterableConfigurationPropertiesSourceTests extends FilteredConfigu
|
||||
.containsExactly("a", "b", "c");
|
||||
}
|
||||
|
||||
@Test
|
||||
void iteratorWhenSpringPropertySourceAndAnotherFilterFiltersNames() {
|
||||
IterableConfigurationPropertySource testSource = (IterableConfigurationPropertySource) createTestSource();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
for (ConfigurationPropertyName name : testSource) {
|
||||
map.put(name.toString(), testSource.getConfigurationProperty(name).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<>();
|
||||
|
||||
Reference in New Issue
Block a user