MapPropertySource extends BasePropertySource { @Override public Map<String, PropertyValue> getProperties() { return Collections.unmodifiableMap(this.props); } MapPropertySource(String name, Map<String, String> props);  MapPropertySource(String name, Properties props, String prefix);  MapPropertySource(String name, Map<String, String> props, String prefix); @Override Map<String, PropertyValue> getProperties(); static Map<String, String> getMap(Properties props); @Override ChangeSupport getChangeSupport(); String getPrefix(); void setPrefix(String prefix);  }
@Test public void sourceWillProperlyInitializedWithMapWithoutPrefix() throws Exception { MapPropertySource propertySource = new MapPropertySource("UT", sourceMap); assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.") .hasSize(2); assertThat(propertySource.get("a")).isNotNull(); assertThat(propertySource.get("b")).isNotNull(); }
@Test public void sourceWillProperlyInitializedWithMapWithPrefix() throws Exception { MapPropertySource propertySource = new MapPropertySource("UT", sourceMap, "pre-"); assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.") .hasSize(2); assertThat(propertySource.get("pre-a")).isNotNull(); assertThat(propertySource.get("pre-b")).isNotNull(); }
@Test public void sourceWillProperlyInitializedWithPropertiesWithPrefix() throws Exception { MapPropertySource propertySource = new MapPropertySource("UT", sourceProperties, "pre-"); assertThat(propertySource.getProperties()).describedAs("Should contain exactly 2 properties.") .hasSize(2); assertThat(propertySource.get("pre-a")).isNotNull(); assertThat(propertySource.get("pre-b")).isNotNull(); }