Skip to content

Commit

Permalink
Perform analysis even when property is not in the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed May 10, 2024
1 parent 6c1962f commit a67c8e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,7 @@ class InvalidConfigurationPropertyValueFailureAnalyzer
protected FailureAnalysis analyze(Throwable rootFailure, InvalidConfigurationPropertyValueException cause) {
List<Descriptor> descriptors = getDescriptors(cause.getName());
if (descriptors.isEmpty()) {
return null;
descriptors = List.of(new Descriptor(null, cause.getValue(), null));
}
StringBuilder description = new StringBuilder();
appendDetails(description, cause, descriptors);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,8 @@ void analysisWithNullEnvironment() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException(
"test.property", "invalid", "This is not valid.");
FailureAnalysis analysis = new InvalidConfigurationPropertyValueFailureAnalyzer(null).analyze(failure);
assertThat(analysis).isNull();
assertThat(analysis.getDescription())
.contains("Invalid value 'invalid' for configuration property 'test.property'.");
}

@Test
Expand Down Expand Up @@ -98,7 +99,9 @@ void analysisWithKnownPropertyAndOtherCandidates() {
void analysisWithUnknownKey() {
InvalidConfigurationPropertyValueException failure = new InvalidConfigurationPropertyValueException(
"test.key.not.defined", "invalid", "This is not valid.");
assertThat(performAnalysis(failure)).isNull();
FailureAnalysis analysis = performAnalysis(failure);
assertThat(analysis.getDescription())
.contains("Invalid value 'invalid' for configuration property 'test.key.not.defined'.");
}

private void assertCommonParts(InvalidConfigurationPropertyValueException failure, FailureAnalysis analysis) {
Expand Down

0 comments on commit a67c8e4

Please sign in to comment.