use of org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException in project spring-boot by spring-projects.
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 org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException in project spring-boot by spring-projects.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithKnownPropertyAndNoReason.
@Test
void analysisWithKnownPropertyAndNoReason() {
MapPropertySource source = new MapPropertySource("test", Collections.singletonMap("test.property", "invalid"));
this.environment.getPropertySources().addFirst(OriginCapablePropertySource.get(source));
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", null);
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getAction()).contains("Review the value of the property.");
assertThat(analysis.getDescription()).contains("No reason was provided.").doesNotContain("Additionally, this property is also set");
}
use of org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException in project spring-boot by spring-projects.
the class InvalidConfigurationPropertyValueFailureAnalyzerTests method analysisWithNullEnvironment.
@Test
void analysisWithNullEnvironment() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException("test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer().analyze(failure);
assertThat(analysis).isNull();
}
use of org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException in project spring-boot by spring-projects.
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 org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException in project spring-boot by spring-projects.
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();
}
Aggregations