MapConfigurationPropertySourceTests Class — spring-boot Architecture
Architecture documentation for the MapConfigurationPropertySourceTests class in MapConfigurationPropertySourceTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java lines 34–112
class MapConfigurationPropertySourceTests {
@Test
@SuppressWarnings("NullAway") // Test null check
void createWhenMapIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new MapConfigurationPropertySource(null))
.withMessageContaining("'map' must not be null");
}
@Test
void createWhenMapHasEntriesShouldAdaptMap() {
Map<Object, Object> map = new LinkedHashMap<>();
map.put("foo.BAR", "spring");
map.put(ConfigurationPropertyName.of("foo.baz"), "boot");
MapConfigurationPropertySource source = new MapConfigurationPropertySource(map);
assertThat(getValue(source, "foo.bar")).isEqualTo("spring");
assertThat(getValue(source, "foo.baz")).isEqualTo("boot");
}
@Test
@SuppressWarnings("NullAway") // Test null check
void putAllWhenMapIsNullShouldThrowException() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
assertThatIllegalArgumentException().isThrownBy(() -> source.putAll(null))
.withMessageContaining("'map' must not be null");
}
@Test
void putAllShouldPutEntries() {
Map<Object, Object> map = new LinkedHashMap<>();
map.put("foo.BAR", "spring");
map.put("foo.baz", "boot");
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.putAll(map);
assertThat(getValue(source, "foo.bar")).isEqualTo("spring");
assertThat(getValue(source, "foo.baz")).isEqualTo("boot");
}
@Test
void putShouldPutEntry() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("foo.bar", "baz");
assertThat(getValue(source, "foo.bar")).isEqualTo("baz");
}
@Test
void getConfigurationPropertyShouldGetFromMemory() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("foo.bar", "baz");
assertThat(getValue(source, "foo.bar")).isEqualTo("baz");
source.put("foo.bar", "big");
assertThat(getValue(source, "foo.bar")).isEqualTo("big");
}
@Test
void iteratorShouldGetFromMemory() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("foo.BAR", "spring");
source.put("foo.baz", "boot");
assertThat(source.iterator()).toIterable()
.containsExactly(ConfigurationPropertyName.of("foo.bar"), ConfigurationPropertyName.of("foo.baz"));
}
@Test
void streamShouldGetFromMemory() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("foo.BAR", "spring");
source.put("foo.baz", "boot");
assertThat(source.stream()).containsExactly(ConfigurationPropertyName.of("foo.bar"),
ConfigurationPropertyName.of("foo.baz"));
}
private @Nullable Object getValue(ConfigurationPropertySource source, String name) {
ConfigurationProperty property = source.getConfigurationProperty(ConfigurationPropertyName.of(name));
return (property != null) ? property.getValue() : null;
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free