use of cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException in project today-infrastructure by TAKETODAY.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithUnknownKey.
@Test
void analysisWithUnknownKey() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.key.not.defined", "invalid", "This is not valid.");
assertThat(performAnalysis(failure)).isNull();
}
use of cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException in project today-infrastructure by TAKETODAY.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithNullEnvironment.
@Test
void analysisWithNullEnvironment() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer(environment).analyze(failure);
assertThat(analysis).isNull();
}
use of cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException in project today-infrastructure by TAKETODAY.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithKnownProperty.
@Test
void analysisWithKnownProperty() {
MapPropertySource source = new MapPropertySource("test", Collections.singletonMap("test.property", "invalid"));
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = performAnalysis(failure);
assertCommonParts(failure, analysis);
assertThat(analysis.getAction()).contains("Review the value of the property with the provided reason.");
assertThat(analysis.getDescription()).contains("Validation failed for the following reason").contains("This is not valid.").doesNotContain("Additionally, this property is also set");
}
use of cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException in project today-framework by TAKETODAY.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithKnownPropertyAndOtherCandidates.
@Test
void analysisWithKnownPropertyAndOtherCandidates() {
MapPropertySource source = new MapPropertySource("test", Collections.singletonMap("test.property", "invalid"));
MapPropertySource additional = new MapPropertySource("additional", Collections.singletonMap("test.property", "valid"));
MapPropertySource another = new MapPropertySource("another", Collections.singletonMap("test.property", "test"));
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
this.environment.getPropertySources().addLast(additional);
this.environment.getPropertySources().addLast(OriginCapablePropertySource.get(another));
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = performAnalysis(failure);
assertCommonParts(failure, analysis);
assertThat(analysis.getAction()).contains("Review the value of the property with the provided reason.");
assertThat(analysis.getDescription()).contains("Additionally, this property is also set in the following property sources:").contains("In 'additional' with the value 'valid'").contains("In 'another' with the value 'test' (originating from 'TestOrigin test.property')");
}
use of cn.taketoday.context.properties.source.InvalidConfigurationPropertyValueException in project today-framework by TAKETODAY.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithNullEnvironment.
@Test
void analysisWithNullEnvironment() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer(environment).analyze(failure);
assertThat(analysis).isNull();
}
Aggregations