use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method performAnalysis.
private FailureAnalysis performAnalysis(Class<?> configuration, boolean allowCircularReferences) {
FailureAnalysis analysis = this.analyzer.analyze(createFailure(configuration, allowCircularReferences));
assertThat(analysis).isNotNull();
return analysis;
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleReferencedViaOtherBeans.
@Test
void cycleReferencedViaOtherBeans() throws IOException {
FailureAnalysis analysis = performAnalysis(CycleReferencedViaOtherBeansConfiguration.class);
List<String> lines = readDescriptionLines(analysis);
assertThat(lines).hasSize(12);
assertThat(lines.get(0)).isEqualTo("The dependencies of some of the beans in the application context form a cycle:");
assertThat(lines.get(1)).isEqualTo("");
assertThat(lines.get(2)).contains("refererOne (field " + RefererTwo.class.getName());
assertThat(lines.get(3)).isEqualTo(" ↓");
assertThat(lines.get(4)).contains("refererTwo (field " + BeanOne.class.getName());
assertThat(lines.get(5)).isEqualTo("┌─────┐");
assertThat(lines.get(6)).startsWith("| one defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
assertThat(lines.get(7)).isEqualTo("↑ ↓");
assertThat(lines.get(8)).startsWith("| two defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
assertThat(lines.get(9)).isEqualTo("↑ ↓");
assertThat(lines.get(10)).startsWith("| three defined in " + CycleReferencedViaOtherBeansConfiguration.class.getName());
assertThat(lines.get(11)).isEqualTo("└─────┘");
assertThat(analysis.getAction()).isNotNull();
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BeanCurrentlyInCreationFailureAnalyzerTests method cycleWithAutowiredFields.
@Test
void cycleWithAutowiredFields() throws IOException {
FailureAnalysis analysis = performAnalysis(CycleWithAutowiredFields.class);
assertThat(analysis.getDescription()).startsWith("The dependencies of some of the beans in the application context form a cycle:");
List<String> lines = readDescriptionLines(analysis);
assertThat(lines).hasSize(9);
assertThat(lines.get(0)).isEqualTo("The dependencies of some of the beans in the application context form a cycle:");
assertThat(lines.get(1)).isEqualTo("");
assertThat(lines.get(2)).isEqualTo("┌─────┐");
assertThat(lines.get(3)).startsWith("| three defined in " + BeanThreeConfiguration.class.getName());
assertThat(lines.get(4)).isEqualTo("↑ ↓");
assertThat(lines.get(5)).startsWith("| one defined in " + CycleWithAutowiredFields.class.getName());
assertThat(lines.get(6)).isEqualTo("↑ ↓");
assertThat(lines.get(7)).startsWith("| " + BeanTwoConfiguration.class.getName() + " (field private " + BeanThree.class.getName());
assertThat(lines.get(8)).isEqualTo("└─────┘");
assertThat(analysis.getAction()).isNotNull();
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BindValidationFailureAnalyzerTests method otherBindExceptionShouldReturnAnalysis.
@Test
void otherBindExceptionShouldReturnAnalysis() {
BindException cause = new BindException(new FieldValidationFailureProperties(), "fieldValidationFailureProperties");
cause.addError(new FieldError("test", "value", "must not be null"));
BeanCreationException rootFailure = new BeanCreationException("bean creation failure", cause);
FailureAnalysis analysis = new BindValidationFailureAnalyzer().analyze(rootFailure, rootFailure);
assertThat(analysis.getDescription()).contains(failure("test.value", "null", "must not be null"));
}
use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.
the class BindValidationFailureAnalyzerTests method bindExceptionWithOriginDueToValidationFailure.
@Test
void bindExceptionWithOriginDueToValidationFailure() {
FailureAnalysis analysis = performAnalysis(FieldValidationFailureConfiguration.class, "test.foo.value=4");
assertThat(analysis.getDescription()).contains("Origin: \"test.foo.value\" from property source \"test\"");
}
Aggregations