Search in sources :

Example 26 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingBeanName.

@Test
public void failureAnalysisForMissingBeanName() {
    FailureAnalysis analysis = analyzeFailure(createFailure(StringMissingBeanNameConfiguration.class));
    assertThat(analysis.getDescription()).startsWith(String.format("Constructor in %s required a bean named '%s' that could not be found", StringNameHandler.class.getName(), "test-string"));
    assertBeanMethodDisabled(analysis, "@ConditionalOnBean (types: java.lang.Integer; SearchStrategy: all) did not find any beans", TestMissingBeanAutoConfiguration.class, "string");
    assertActionMissingName(analysis, "test-string");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 27 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingClassOnAutoConfigurationType.

@Test
public void failureAnalysisForMissingClassOnAutoConfigurationType() {
    FailureAnalysis analysis = analyzeFailure(createFailure(MissingClassOnAutoConfigurationConfiguration.class));
    assertDescriptionConstructorMissingType(analysis, StringHandler.class, 0, String.class);
    assertClassDisabled(analysis, "did not find required class 'com.example.FooBar'", "string");
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 28 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMultipleBeans.

@Test
public void failureAnalysisForMultipleBeans() {
    FailureAnalysis analysis = analyzeFailure(new NoUniqueBeanDefinitionException(String.class, 2, "Test"));
    assertThat(analysis).isNull();
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) NoUniqueBeanDefinitionException(org.springframework.beans.factory.NoUniqueBeanDefinitionException) Test(org.junit.Test)

Example 29 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForNoMatchName.

@Test
public void failureAnalysisForNoMatchName() {
    FailureAnalysis analysis = analyzeFailure(createFailure(StringNameHandler.class));
    assertThat(analysis.getDescription()).startsWith(String.format("Constructor in %s required a bean named '%s' that could not be found", StringNameHandler.class.getName(), "test-string"));
    assertThat(analysis.getDescription().contains("No matching auto-configuration has been found for this bean name."));
    assertThat(analysis.getAction()).startsWith(String.format("Consider defining a bean named '%s' in your configuration.", "test-string"));
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Example 30 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-boot by spring-projects.

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingCollectionType.

@Test
public void failureAnalysisForMissingCollectionType() throws Exception {
    FailureAnalysis analysis = analyzeFailure(createFailure(StringCollectionConfiguration.class));
    assertDescriptionConstructorMissingType(analysis, StringCollectionHandler.class, 0, String.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.string.enabled'", TestPropertyAutoConfiguration.class, "string");
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.Test)

Aggregations

FailureAnalysis (org.springframework.boot.diagnostics.FailureAnalysis)33 Test (org.junit.Test)27 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 ArrayList (java.util.ArrayList)1 ErrorMessage (org.modelmapper.spi.ErrorMessage)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 InjectionPoint (org.springframework.beans.factory.InjectionPoint)1 NoUniqueBeanDefinitionException (org.springframework.beans.factory.NoUniqueBeanDefinitionException)1 TestBeanConsumer (org.springframework.boot.diagnostics.analyzer.nounique.TestBeanConsumer)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 FieldError (org.springframework.validation.FieldError)1 ObjectError (org.springframework.validation.ObjectError)1