Search in sources :

Example 36 with FailureAnalysis

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

the class NoSuchMethodFailureAnalyzerTests method whenAMethodOnAClassIsMissingThenNoSuchMethodErrorIsAnalyzed.

@Test
void whenAMethodOnAClassIsMissingThenNoSuchMethodErrorIsAnalyzed() {
    Throwable failure = createFailureForMissingMethod();
    assertThat(failure).isNotNull();
    failure.printStackTrace();
    FailureAnalysis analysis = new NoSuchMethodFailureAnalyzer().analyze(failure);
    assertThat(analysis).isNotNull();
    assertThat(analysis.getDescription()).contains(NoSuchMethodFailureAnalyzerTests.class.getName() + ".createFailureForMissingMethod(").contains("isMoreSpecific(").contains("calling method's class, " + NoSuchMethodFailureAnalyzerTests.class.getName() + ",").contains("called method's class, org.springframework.util.MimeType,");
    assertThat(analysis.getAction()).contains(NoSuchMethodFailureAnalyzerTests.class.getName()).contains("org.springframework.util.MimeType");
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 37 with FailureAnalysis

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

the class NoSuchMethodFailureAnalyzerTests method whenAnInheritedMethodIsMissingThenNoSuchMethodErrorIsAnalyzed.

@Test
void whenAnInheritedMethodIsMissingThenNoSuchMethodErrorIsAnalyzed() {
    Throwable failure = createFailureForMissingInheritedMethod();
    assertThat(failure).isNotNull();
    FailureAnalysis analysis = new NoSuchMethodFailureAnalyzer().analyze(failure);
    assertThat(analysis).isNotNull();
    assertThat(analysis.getDescription()).contains(R2dbcMappingContext.class.getName() + ".<init>(").contains(R2dbcMappingContext.class.getName() + ".setForceQuote(").contains("calling method's class, org.springframework.data.r2dbc.mapping.R2dbcMappingContext,").contains("called method's class, org.springframework.data.r2dbc.mapping.R2dbcMappingContext,").contains("    org.springframework.data.r2dbc.mapping.R2dbcMappingContext").contains("    org.springframework.data.relational.core.mapping.RelationalMappingContext").contains("    org.springframework.data.mapping.context.AbstractMappingContext");
    assertThat(analysis.getAction()).contains("org.springframework.data.r2dbc.mapping.R2dbcMappingContext");
}
Also used : R2dbcMappingContext(org.springframework.data.r2dbc.mapping.R2dbcMappingContext) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 38 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForObjectProviderMethodConsumer.

@Test
void failureAnalysisForObjectProviderMethodConsumer() {
    FailureAnalysis failureAnalysis = analyzeFailure(createFailure(ObjectProviderMethodConsumer.class));
    assertThat(failureAnalysis.getDescription()).startsWith("Method consumer in " + ObjectProviderMethodConsumer.class.getName() + " required a single bean, but 6 were found:");
    assertFoundBeans(failureAnalysis);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 39 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForMethodConsumer.

@Test
void failureAnalysisForMethodConsumer() {
    FailureAnalysis failureAnalysis = analyzeFailure(createFailure(MethodConsumer.class));
    assertThat(failureAnalysis.getDescription()).startsWith("Parameter 0 of method consumer in " + MethodConsumer.class.getName() + " required a single bean, but 6 were found:");
    assertFoundBeans(failureAnalysis);
}
Also used : FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 40 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForConstructorConsumer.

@Test
void failureAnalysisForConstructorConsumer() {
    FailureAnalysis failureAnalysis = analyzeFailure(createFailure(ConstructorConsumer.class));
    assertThat(failureAnalysis.getDescription()).startsWith("Parameter 0 of constructor in " + ConstructorConsumer.class.getName() + " required a single bean, but 6 were found:");
    assertFoundBeans(failureAnalysis);
}
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