Search in sources :

Example 71 with FailureAnalysis

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

the class InvalidConfigurationPropertyNameFailureAnalyzerTests method analysisWhenRootCauseIsBeanCreationFailureShouldContainBeanName.

@Test
void analysisWhenRootCauseIsBeanCreationFailureShouldContainBeanName() {
    BeanCreationException failure = createFailure(InvalidPrefixConfiguration.class);
    FailureAnalysis analysis = this.analyzer.analyze(failure);
    assertThat(analysis.getDescription()).contains(String.format("%n    Invalid characters: %s%n    Bean: %s%n    Reason: %s", "'F', 'P'", "invalidPrefixProperties", "Canonical names should be kebab-case ('-' separated), " + "lowercase alpha-numeric characters and must start with a letter"));
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) FailureAnalysis(org.springframework.boot.diagnostics.FailureAnalysis) Test(org.junit.jupiter.api.Test)

Example 72 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForXmlConsumer.

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

Example 73 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForFieldConsumer.

@Test
void failureAnalysisForFieldConsumer() {
    FailureAnalysis failureAnalysis = analyzeFailure(createFailure(FieldConsumer.class));
    assertThat(failureAnalysis.getDescription()).startsWith("Field testBean in " + FieldConsumer.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 74 with FailureAnalysis

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

the class NoUniqueBeanDefinitionFailureAnalyzerTests method failureAnalysisForObjectProviderConstructorConsumer.

@Test
void failureAnalysisForObjectProviderConstructorConsumer() {
    FailureAnalysis failureAnalysis = analyzeFailure(createFailure(ObjectProviderConstructorConsumer.class));
    assertThat(failureAnalysis.getDescription()).startsWith("Constructor in " + ObjectProviderConstructorConsumer.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 75 with FailureAnalysis

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

the class UnboundConfigurationPropertyFailureAnalyzerTests method bindExceptionDueToUnboundElements.

@Test
void bindExceptionDueToUnboundElements() {
    FailureAnalysis analysis = performAnalysis(UnboundElementsFailureConfiguration.class, "test.foo.listValue[0]=hello", "test.foo.listValue[2]=world");
    assertThat(analysis.getDescription()).contains(failure("test.foo.listvalue[2]", "world", "\"test.foo.listValue[2]\" from property source \"test\"", "The elements [test.foo.listvalue[2]] were left unbound."));
}
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