Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.springframework.boot.context.config;

import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
import org.springframework.boot.diagnostics.FailureAnalysis;

/**
*
* An implementation of {@link AbstractFailureAnalyzer} to analyze failures caused by
* {@link ConfigDataLocationNotFoundException}.
*
* @author Michal Mlak
*/
public class ConfigDataLocationNotFoundExceptionFailureAnalyzer
extends AbstractFailureAnalyzer<ConfigDataLocationNotFoundException> {

@Override
protected FailureAnalysis analyze(Throwable rootFailure, ConfigDataLocationNotFoundException cause) {
return new FailureAnalysis(cause.getMessage(), null, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyNameFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyValueFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.PatternParseFailureAnalyzer,\
org.springframework.boot.liquibase.LiquibaseChangelogMissingFailureAnalyzer
org.springframework.boot.liquibase.LiquibaseChangelogMissingFailureAnalyzer,\
org.springframework.boot.context.config.ConfigDataLocationNotFoundExceptionFailureAnalyzer

# Failure Analysis Reporters
org.springframework.boot.diagnostics.FailureAnalysisReporter=\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.springframework.boot.context.config;

import org.junit.jupiter.api.Test;
import org.springframework.boot.diagnostics.FailureAnalysis;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

/**
*
* Tests for {@link ConfigDataLocationNotFoundExceptionFailureAnalyzer}
*
* @author Michal Mlak
*/
class ConfigDataLocationNotFoundExceptionFailureAnalyzerTests {

private final ConfigDataLocationNotFoundExceptionFailureAnalyzer analyzer = new ConfigDataLocationNotFoundExceptionFailureAnalyzer();

@Test
void failureAnalysisForConfigDataLocationNotFound() {
ConfigDataLocation location = mock(ConfigDataLocation.class);
ConfigDataLocationNotFoundException exception = new ConfigDataLocationNotFoundException(location);

FailureAnalysis result = analyzer.analyze(exception);

assertThat(result.getDescription()).isEqualTo("Config data location '" + location + "' does not exist");
assertThat(result.getAction()).isNull();
}

}