Home / Class/ ErrorTests Class — spring-boot Architecture

ErrorTests Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot/src/test/java/org/springframework/boot/web/error/ErrorTests.java lines 36–66

class ErrorTests {

	@Test
	@SuppressWarnings("rawtypes")
	void wrapIfNecessaryDoesNotWrapFieldErrorOrObjectError() {
		List<MessageSourceResolvable> wrapped = Error.wrapIfNecessary(List.of(new ObjectError("name", "message"),
				new FieldError("name", "field", "message"), new CustomMessageSourceResolvable("code")));
		assertThat(wrapped).extracting((error) -> (Class) error.getClass())
			.containsExactly(ObjectError.class, FieldError.class, Error.class);
	}

	@Test
	void errorCauseDoesNotAppearInJson() {
		String json = new JsonMapper()
			.writeValueAsString(Error.wrapIfNecessary(List.of(new CustomMessageSourceResolvable("code"))));
		assertThat(json).doesNotContain("some detail");
	}

	public static class CustomMessageSourceResolvable extends DefaultMessageSourceResolvable {

		CustomMessageSourceResolvable(String code) {
			super(code);
		}

		public String getDetail() {
			return "some detail";
		}

	}

}

Analyze Your Own Codebase

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

Try Supermodel Free