Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
Closes gh-21655
  • Loading branch information
philwebb committed Jun 2, 2020
2 parents f0bc8ee + 09a47c9 commit 2589f98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Expand Up @@ -104,7 +104,7 @@ public ConfigurationPropertyState containsDescendantOf(ConfigurationPropertyName
}

private static ConfigurationPropertyState containsDescendantOfForRandom(ConfigurationPropertyName name) {
if (name.isAncestorOf(RANDOM) || name.equals(RANDOM)) {
if (RANDOM.isAncestorOf(name) || name.equals(RANDOM)) {
return ConfigurationPropertyState.PRESENT;
}
return ConfigurationPropertyState.ABSENT;
Expand Down
Expand Up @@ -21,6 +21,7 @@

import org.junit.jupiter.api.Test;

import org.springframework.boot.env.RandomValuePropertySource;
import org.springframework.boot.origin.Origin;
import org.springframework.boot.origin.OriginLookup;
import org.springframework.core.env.MapPropertySource;
Expand Down Expand Up @@ -141,6 +142,30 @@ void getWhenEnumerableShouldBeIterable() {
.isInstanceOf(IterableConfigurationPropertySource.class);
}

@Test
void containsDescendantOfWhenRandomSourceAndRandomPropertyReturnsPresent() {
SpringConfigurationPropertySource source = SpringConfigurationPropertySource
.from(new RandomValuePropertySource());
assertThat(source.containsDescendantOf(ConfigurationPropertyName.of("random")))
.isEqualTo(ConfigurationPropertyState.PRESENT);
}

@Test
void containsDescendantOfWhenRandomSourceAndRandomPrefixedPropertyReturnsPresent() {
SpringConfigurationPropertySource source = SpringConfigurationPropertySource
.from(new RandomValuePropertySource());
assertThat(source.containsDescendantOf(ConfigurationPropertyName.of("random.something")))
.isEqualTo(ConfigurationPropertyState.PRESENT);
}

@Test
void containsDescendantOfWhenRandomSourceAndNonRandomPropertyReturnsAbsent() {
SpringConfigurationPropertySource source = SpringConfigurationPropertySource
.from(new RandomValuePropertySource());
assertThat(source.containsDescendantOf(ConfigurationPropertyName.of("abandon.something")))
.isEqualTo(ConfigurationPropertyState.ABSENT);
}

/**
* Test {@link PropertySource} that's also an {@link OriginLookup}.
*
Expand Down

0 comments on commit 2589f98

Please sign in to comment.