Home / Class/ AbstractFailureAnalyzerTests Class — spring-boot Architecture

AbstractFailureAnalyzerTests Class — spring-boot Architecture

Architecture documentation for the AbstractFailureAnalyzerTests class in AbstractFailureAnalyzerTests.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzerTests.java lines 32–97

class AbstractFailureAnalyzerTests {

	private final TestFailureAnalyzer failureAnalyzer = new TestFailureAnalyzer();

	@Test
	void findCauseWithNullException() {
		assertThat(this.failureAnalyzer.findCause(null, Throwable.class)).isNull();
	}

	@Test
	void findCauseWithDirectExactMatch() {
		TestException ex = new TestException();
		assertThat(this.failureAnalyzer.findCause(ex, TestException.class)).isEqualTo(ex);
	}

	@Test
	void findCauseWithDirectSubClass() {
		SpecificTestException ex = new SpecificTestException();
		assertThat(this.failureAnalyzer.findCause(ex, TestException.class)).isEqualTo(ex);
	}

	@Test
	void findCauseWitNestedAndExactMatch() {
		TestException ex = new TestException();
		assertThat(this.failureAnalyzer.findCause(new IllegalArgumentException(new IllegalStateException(ex)),
				TestException.class))
			.isEqualTo(ex);
	}

	@Test
	void findCauseWitNestedAndSubClass() {
		SpecificTestException ex = new SpecificTestException();
		assertThat(this.failureAnalyzer.findCause(new IOException(new IllegalStateException(ex)), TestException.class))
			.isEqualTo(ex);
	}

	@Test
	void findCauseWithUnrelatedException() {
		IOException ex = new IOException();
		assertThat(this.failureAnalyzer.findCause(ex, TestException.class)).isNull();
	}

	@Test
	void findCauseWithMoreSpecificException() {
		TestException ex = new TestException();
		assertThat(this.failureAnalyzer.findCause(ex, SpecificTestException.class)).isNull();
	}

	static class TestFailureAnalyzer extends AbstractFailureAnalyzer<Throwable> {

		@Override
		protected @Nullable FailureAnalysis analyze(Throwable rootFailure, Throwable cause) {
			return null;
		}

	}

	static class TestException extends Exception {

	}

	static class SpecificTestException extends TestException {

	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free