Search in sources :

Example 86 with FailureAnalysis

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

the class BindFailureAnalyzerTests method bindExceptionWithNestedFailureShouldDisplayNestedMessage.

@Test
void bindExceptionWithNestedFailureShouldDisplayNestedMessage() {
    FailureAnalysis analysis = performAnalysis(NestedFailureConfiguration.class, "test.foo.value=hello");
    assertThat(analysis.getDescription()).contains(failure("test.foo.value", "hello", "\"test.foo.value\" from property source \"test\"", "java.lang.RuntimeException: This is a failure"));
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 87 with FailureAnalysis

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

the class BindFailureAnalyzerTests method analysisForUnboundElementsIsNull.

@Test
void analysisForUnboundElementsIsNull() {
    FailureAnalysis analysis = performAnalysis(UnboundElementsFailureConfiguration.class, "test.foo.listValue[0]=hello", "test.foo.listValue[2]=world");
    assertThat(analysis).isNull();
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 88 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project bucket4j-spring-boot-starter by MarcGiffing.

the class Bucket4JAutoConfigFailureAnalyzer method analyze.

@Override
protected FailureAnalysis analyze(Throwable rootFailure, Bucket4jGeneralException cause) {
    String descriptionMessage = cause.getMessage();
    String actionMessage = cause.getMessage();
    if (cause instanceof JCacheNotFoundException) {
        JCacheNotFoundException ex = (JCacheNotFoundException) cause;
        descriptionMessage = "The cache name name defined in the property is not configured in the caching provider";
        actionMessage = "Cache name: " + ex.getCacheName() + newline + "Please configure your caching provider (ehcache, hazelcast, ...)";
    }
    if (cause instanceof MissingKeyFilterExpressionException) {
        descriptionMessage = "You've set the 'filter-key-type' to 'expression' but didn't set the property 'expression'";
        actionMessage = "Please set the property 'expression' in your configuration file with a valid expression (see Spring Expression Language)" + newline;
    }
    return new FailureAnalysis(descriptionMessage, actionMessage, cause);
}
Also used : MissingKeyFilterExpressionException(com.giffing.bucket4j.spring.boot.starter.exception.MissingKeyFilterExpressionException) JCacheNotFoundException(com.giffing.bucket4j.spring.boot.starter.exception.JCacheNotFoundException) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis)

Example 89 with FailureAnalysis

use of org.springframework.boot.diagnostics.FailureAnalysis in project spring-cloud-open-service-broker by spring-cloud.

the class ServiceBrokerAutoConfigurationTest method assertFailureAnalysis.

private void assertFailureAnalysis(Throwable t) {
    FailureAnalyzer analyzer = new RequiredCatalogBeanFailureAnalyzer();
    FailureAnalysis analysis = analyzer.analyze(t);
    assertThat(analysis).isNotNull();
    assertThat(analysis.getDescription()).isEqualTo(ANALYZER_DESCRIPTION);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) FailureAnalyzer(org.springframework.boot.diagnostics.FailureAnalyzer)

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