Search in sources :

Example 51 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project microservices by pwillhan.

the class ModelMapConfigurationFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, ConfigurationException cause) {
    StringBuilder description = new StringBuilder();
    description.append("ModelMapper configuration failed:\n");
    for (ErrorMessage message : cause.getErrorMessages()) {
        description.append(message.getMessage());
    }
    return new FailureAnalysis(description.toString(), "Fix ModelMapper configuration", cause);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) ErrorMessage(org.modelmapper.spi.ErrorMessage)

Example 52 with FailureAnalysis

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

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForSeveralConditionsType.

@Test
void failureAnalysisForSeveralConditionsType() {
    FailureAnalysis analysis = analyzeFailure(createFailure(SeveralAutoConfigurationTypeConfiguration.class));
    assertDescriptionConstructorMissingType(analysis, StringHandler.class, 0, String.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.string.enabled'", TestPropertyAutoConfiguration.class, "string");
    assertClassDisabled(analysis, "did not find required class 'com.example.FooBar'", "string", ClassUtils.getShortName(TestPropertyAutoConfiguration.class));
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 53 with FailureAnalysis

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

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingClassOnAutoConfigurationType.

@Test
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", ClassUtils.getShortName(TestTypeClassAutoConfiguration.class));
    assertActionMissingType(analysis, String.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 54 with FailureAnalysis

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

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingBeanName.

@Test
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.jupiter.api.Test)

Example 55 with FailureAnalysis

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

the class NoSuchBeanDefinitionFailureAnalyzerTests method failureAnalysisForMissingPropertySubType.

@Test
void failureAnalysisForMissingPropertySubType() {
    FailureAnalysis analysis = analyzeFailure(createFailure(IntegerPropertyTypeConfiguration.class));
    assertThat(analysis).isNotNull();
    assertDescriptionConstructorMissingType(analysis, NumberHandler.class, 0, Number.class);
    assertBeanMethodDisabled(analysis, "did not find property 'spring.integer.enabled'", TestPropertyAutoConfiguration.class, "integer");
    assertActionMissingType(analysis, Number.class);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Aggregations

FailureAnalysis (org.springframework.boot.diagnostics.FailureAnalysis)89 Test (org.junit.jupiter.api.Test)69 Test (org.junit.Test)6 MapPropertySource (org.springframework.core.env.MapPropertySource)6 InvalidConfigurationPropertyValueException (org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException)4 MutuallyExclusiveConfigurationPropertiesException (org.springframework.boot.context.properties.source.MutuallyExclusiveConfigurationPropertiesException)4 BeanCreationException (org.springframework.beans.factory.BeanCreationException)3 InjectionPoint (org.springframework.beans.factory.InjectionPoint)3 LinkedHashMap (java.util.LinkedHashMap)2 FailureAnalyzer (org.springframework.boot.diagnostics.FailureAnalyzer)2 FieldError (org.springframework.validation.FieldError)2 JCacheNotFoundException (com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException)1 MissingKeyFilterExpressionException (com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ErrorMessage (org.modelmapper.spi.ErrorMessage)1 FatalBeanException (org.springframework.beans.FatalBeanException)1 NoUniqueBeanDefinitionException (org.springframework.beans.factory.NoUniqueBeanDefinitionException)1 LoggingFailureAnalysisReporter (org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter)1