use of cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException in project today-infrastructure by TAKETODAY.
the class MutuallyExclusiveConfigurationPropertiesFailureAnalyzerTests method analyzeWhenAllConfiguredPropertiesAreInTheEnvironmentShouldReturnAnalysis.
@Test
void analyzeWhenAllConfiguredPropertiesAreInTheEnvironmentShouldReturnAnalysis() {
Map<String, Object> properties = new HashMap<>();
properties.put("com.example.a", "alpha");
properties.put("com.example.b", "bravo");
MapPropertySource source = new MapPropertySource("test", properties);
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
MutuallyExclusiveConfigurationPropertiesException failure = new MutuallyExclusiveConfigurationPropertiesException(new HashSet<>(Arrays.asList("com.example.a", "com.example.b")), new HashSet<>(Arrays.asList("com.example.a", "com.example.b")));
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getAction()).isEqualTo("Update your configuration so that only one of the mutually exclusive properties is configured.");
assertThat(analysis.getDescription()).contains(String.format("The following configuration properties are mutually exclusive:%n%n\tcom.example.a%n\tcom.example.b%n")).contains(String.format("However, more than one of those properties has been configured at the same time:%n%n" + "\tcom.example.a (originating from 'TestOrigin test')%n" + "\tcom.example.b (originating from 'TestOrigin test')%n"));
}
use of cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException in project today-infrastructure by TAKETODAY.
the class MutuallyExclusiveConfigurationPropertiesFailureAnalyzerTests method analyzeWhenPropertyIsInMultiplePropertySourcesShouldListEachSourceInAnalysis.
@Test
void analyzeWhenPropertyIsInMultiplePropertySourcesShouldListEachSourceInAnalysis() {
Map<String, Object> properties = new LinkedHashMap<>();
properties.put("com.example.a", "alpha");
properties.put("com.example.b", "bravo");
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(new MapPropertySource("test-one", properties)));
this.environment.getPropertySources().addLast(OriginCapablePropertySource.get(new MapPropertySource("test-two", properties)));
MutuallyExclusiveConfigurationPropertiesException failure = new MutuallyExclusiveConfigurationPropertiesException(new HashSet<>(Arrays.asList("com.example.a", "com.example.b")), new HashSet<>(Arrays.asList("com.example.a", "com.example.b")));
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getAction()).isEqualTo("Update your configuration so that only one of the mutually exclusive properties is configured.");
assertThat(analysis.getDescription()).contains(String.format("The following configuration properties are mutually exclusive:%n%n\tcom.example.a%n\tcom.example.b%n")).contains(String.format("However, more than one of those properties has been configured at the same time:%n%n" + "\tcom.example.a (originating from 'TestOrigin test-one')%n" + "\tcom.example.a (originating from 'TestOrigin test-two')%n" + "\tcom.example.b (originating from 'TestOrigin test-one')%n" + "\tcom.example.b (originating from 'TestOrigin test-two')%n"));
}
use of cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException in project today-framework by TAKETODAY.
the class MutuallyExclusiveConfigurationPropertiesFailureAnalyzerTests method analyzeWhenAllConfiguredPropertiesAreInTheEnvironmentShouldReturnAnalysis.
@Test
void analyzeWhenAllConfiguredPropertiesAreInTheEnvironmentShouldReturnAnalysis() {
Map<String, Object> properties = new HashMap<>();
properties.put("com.example.a", "alpha");
properties.put("com.example.b", "bravo");
MapPropertySource source = new MapPropertySource("test", properties);
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
MutuallyExclusiveConfigurationPropertiesException failure = new MutuallyExclusiveConfigurationPropertiesException(new HashSet<>(Arrays.asList("com.example.a", "com.example.b")), new HashSet<>(Arrays.asList("com.example.a", "com.example.b")));
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getAction()).isEqualTo("Update your configuration so that only one of the mutually exclusive properties is configured.");
assertThat(analysis.getDescription()).contains(String.format("The following configuration properties are mutually exclusive:%n%n\tcom.example.a%n\tcom.example.b%n")).contains(String.format("However, more than one of those properties has been configured at the same time:%n%n" + "\tcom.example.a (originating from 'TestOrigin test')%n" + "\tcom.example.b (originating from 'TestOrigin test')%n"));
}
use of cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException in project today-framework by TAKETODAY.
the class MutuallyExclusiveConfigurationPropertiesFailureAnalyzerTests method analyzeWhenNotAllPropertiesAreInTheEnvironmentShouldReturnNull.
@Test
void analyzeWhenNotAllPropertiesAreInTheEnvironmentShouldReturnNull() {
MapPropertySource source = new MapPropertySource("test", Collections.singletonMap("com.example.a", "alpha"));
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
MutuallyExclusiveConfigurationPropertiesException failure = new MutuallyExclusiveConfigurationPropertiesException(new HashSet<>(Arrays.asList("com.example.a", "com.example.b")), new HashSet<>(Arrays.asList("com.example.a", "com.example.b")));
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis).isNull();
}
use of cn.taketoday.context.properties.source.MutuallyExclusiveConfigurationPropertiesException in project today-framework by TAKETODAY.
the class MutuallyExclusiveConfigurationPropertiesFailureAnalyzerTests method analyzeWhenEnvironmentIsNullShouldReturnNull.
@Test
void analyzeWhenEnvironmentIsNullShouldReturnNull() {
MutuallyExclusiveConfigurationPropertiesException failure = new MutuallyExclusiveConfigurationPropertiesException(new HashSet<>(Arrays.asList("com.example.a", "com.example.b")), new HashSet<>(Arrays.asList("com.example.a", "com.example.b")));
FailureAnalysis failureAnalysis = new MutuallyExclusiveConfigurationPropertiesFailureAnalyzer(environment).analyze(failure);
assertThat(failureAnalysis).isNull();
}
Aggregations