diff --git a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/HttpMessageNotReadableProblemResolver.java b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/HttpMessageNotReadableProblemResolver.java index 5fa0378d..834eb11e 100644 --- a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/HttpMessageNotReadableProblemResolver.java +++ b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/HttpMessageNotReadableProblemResolver.java @@ -48,7 +48,7 @@ */ public class HttpMessageNotReadableProblemResolver extends AbstractProblemResolver { - private final TypeNameMapper typeNameMapper; + private final JacksonErrorHelper jacksonErrorHelper; /** Creates a new {@link HttpMessageNotReadableProblemResolver} with default problem format. */ public HttpMessageNotReadableProblemResolver() { @@ -74,7 +74,7 @@ public HttpMessageNotReadableProblemResolver(ProblemFormat problemFormat) { public HttpMessageNotReadableProblemResolver( ProblemFormat problemFormat, TypeNameMapper typeNameMapper) { super(HttpMessageNotReadableException.class, problemFormat); - this.typeNameMapper = typeNameMapper; + this.jacksonErrorHelper = new JacksonErrorHelper(problemFormat, typeNameMapper); } /** @@ -92,7 +92,7 @@ public HttpMessageNotReadableProblemResolver( public ProblemBuilder resolveBuilder( ProblemContext context, Exception ex, HttpHeaders headers, HttpStatusCode status) { if (ex.getCause() instanceof MismatchedInputException e) { - return JacksonErrorHelper.resolveMismatchedInput(e, typeNameMapper); + return jacksonErrorHelper.resolveMismatchedInput(e); } return Problem.builder().status(HttpStatus.BAD_REQUEST.value()); } diff --git a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/JacksonErrorHelper.java b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/JacksonErrorHelper.java index 0099e62a..f48c078a 100644 --- a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/JacksonErrorHelper.java +++ b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/JacksonErrorHelper.java @@ -29,16 +29,28 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException; import io.github.problem4j.core.Problem; import io.github.problem4j.core.ProblemBuilder; +import io.github.problem4j.spring.web.ProblemFormat; import io.github.problem4j.spring.web.TypeNameMapper; import java.util.Optional; import java.util.stream.Collectors; import org.springframework.http.HttpStatus; import org.springframework.util.StringUtils; +/** + * Utility for Jackson exceptions used in situations where these exceptions are the {@code cause} of + * the exception that is being resolved. + */ final class JacksonErrorHelper { - static ProblemBuilder resolveMismatchedInput( - MismatchedInputException e, TypeNameMapper typeNameMapper) { + private final ProblemFormat problemFormat; + private final TypeNameMapper typeNameMapper; + + JacksonErrorHelper(ProblemFormat problemFormat, TypeNameMapper typeNameMapper) { + this.problemFormat = problemFormat; + this.typeNameMapper = typeNameMapper; + } + + ProblemBuilder resolveMismatchedInput(MismatchedInputException e) { Optional optionalProperty = resolvePropertyPath(e); ProblemBuilder builder = Problem.builder().status(HttpStatus.BAD_REQUEST.value()); @@ -47,7 +59,7 @@ static ProblemBuilder resolveMismatchedInput( property -> { String kind = typeNameMapper.map(e.getTargetType()).orElse(null); - builder.detail(TYPE_MISMATCH_DETAIL); + builder.detail(problemFormat.formatDetail(TYPE_MISMATCH_DETAIL)); builder.extension(PROPERTY_EXTENSION, property); builder.extension(KIND_EXTENSION, kind); }); @@ -55,7 +67,7 @@ static ProblemBuilder resolveMismatchedInput( return builder; } - private static Optional resolvePropertyPath(MismatchedInputException e) { + private Optional resolvePropertyPath(MismatchedInputException e) { String property = e.getPath().stream() .map(JsonMappingException.Reference::getFieldName) @@ -64,6 +76,4 @@ private static Optional resolvePropertyPath(MismatchedInputException e) return StringUtils.hasLength(property) ? Optional.of(property) : Optional.empty(); } - - private JacksonErrorHelper() {} } diff --git a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/ServerWebInputProblemResolver.java b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/ServerWebInputProblemResolver.java index 54863550..756efb8f 100644 --- a/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/ServerWebInputProblemResolver.java +++ b/problem4j-spring-web/src/main/java/io/github/problem4j/spring/web/resolver/ServerWebInputProblemResolver.java @@ -56,7 +56,7 @@ public class ServerWebInputProblemResolver extends AbstractProblemResolver { private final TypeMismatchProblemResolver typeMismatchProblemResolver; private final MethodParameterSupport methodParameterSupport; - private final TypeNameMapper typeNameMapper; + private final JacksonErrorHelper jacksonErrorHelper; /** Creates a new {@link ServerWebInputProblemResolver} with default problem format. */ public ServerWebInputProblemResolver() { @@ -105,7 +105,7 @@ public ServerWebInputProblemResolver( super(ServerWebInputException.class, problemFormat); this.typeMismatchProblemResolver = typeMismatchProblemResolver; this.methodParameterSupport = methodParameterSupport; - this.typeNameMapper = typeNameMapper; + jacksonErrorHelper = new JacksonErrorHelper(problemFormat, typeNameMapper); } /** @@ -161,7 +161,7 @@ private ProblemBuilder tryAppendingPropertyFromMethodParameter( private ProblemBuilder resolveDecodingException(DecodingException ex) { if (ex.getCause() instanceof MismatchedInputException e) { - return JacksonErrorHelper.resolveMismatchedInput(e, typeNameMapper); + return jacksonErrorHelper.resolveMismatchedInput(e); } return Problem.builder().status(HttpStatus.BAD_REQUEST.value()); } diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/BindingPrimitiveWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/BindingPrimitiveWebFluxTest.java index adbff332..17bb9fbf 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/BindingPrimitiveWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/BindingPrimitiveWebFluxTest.java @@ -40,7 +40,10 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = {"spring.jackson.deserialization.fail-on-null-for-primitives=true"}) + properties = { + "problem4j.detail-format=lowercase", + "spring.jackson.deserialization.fail-on-null-for-primitives=true" + }) class BindingPrimitiveWebFluxTest { @Autowired private WebTestClient webTestClient; @@ -136,7 +139,7 @@ void givenMalformedPrimitive_whenPost_thenReturnProblem(String path, String json Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, expectedKind) .build(); @@ -239,7 +242,7 @@ void givenMalformedNested_whenPost_thenReturnProblem(String path, String json) { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "nested.value") .extension(KIND_EXTENSION, expectedKind) .build()); @@ -285,7 +288,7 @@ void givenEmptyStringPrimitive_whenPost_thenReturnProblem(String path, String js .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, expectedKind) .build()); @@ -318,7 +321,7 @@ void givenOverflowPrimitive_whenPost_thenReturnProblem(String path, String json) Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, "integer") .build(); @@ -347,7 +350,7 @@ void givenNullPrimitive_whenPost_thenReturnProblem() { Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, "integer") .build(); @@ -411,7 +414,7 @@ void givenMalformedComplexObject_whenPost_thenReturnProblemWithFirstInvalidField .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, expectedProperty) .extension(KIND_EXTENSION, expectedKind) .build())); diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorResponseWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorResponseWebFluxTest.java index 11d2a85d..166d53ba 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorResponseWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorResponseWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ErrorResponseWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorWebExceptionHandlerWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorWebExceptionHandlerWebFluxTest.java index 236ad60f..4e8ccae2 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorWebExceptionHandlerWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ErrorWebExceptionHandlerWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ErrorWebExceptionHandlerWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MalformedMultipartWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MalformedMultipartWebFluxTest.java index 74388c80..55043105 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MalformedMultipartWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MalformedMultipartWebFluxTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class MalformedMultipartWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MaxUploadSizeExceededWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MaxUploadSizeExceededWebFluxTest.java index d018e795..6a375536 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MaxUploadSizeExceededWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MaxUploadSizeExceededWebFluxTest.java @@ -36,7 +36,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class MaxUploadSizeExceededWebFluxTest { @@ -57,7 +58,7 @@ void givenMaxUploadSizeExceeded_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.PAYLOAD_TOO_LARGE.value()) - .detail(MAX_UPLOAD_SIZE_EXCEEDED_DETAIL) + .detail(MAX_UPLOAD_SIZE_EXCEEDED_DETAIL.toLowerCase()) .extension(MAX_EXTENSION, 1) .build()); } diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MethodNotAllowedWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MethodNotAllowedWebFluxTest.java index cf5b1381..59d09170 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MethodNotAllowedWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MethodNotAllowedWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class MethodNotAllowedWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MissingParameterWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MissingParameterWebFluxTest.java index aa57beca..deb70de0 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MissingParameterWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/MissingParameterWebFluxTest.java @@ -52,7 +52,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class MissingParameterWebFluxTest { @@ -76,7 +77,7 @@ void givenRequestWithoutPathVariable_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_PATH_VARIABLE_DETAIL) + .detail(MISSING_PATH_VARIABLE_DETAIL.toLowerCase()) .extension(NAME_EXTENSION, "var") .build()); }); @@ -112,7 +113,7 @@ void givenRequestWithoutRequestParam_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_PARAM_DETAIL) + .detail(MISSING_REQUEST_PARAM_DETAIL.toLowerCase()) .extension(PARAM_EXTENSION, "param") .extension(KIND_EXTENSION, "string") .build()); @@ -154,7 +155,7 @@ void givenRequestWithoutRequestPart_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_PART_DETAIL) + .detail(MISSING_REQUEST_PART_DETAIL.toLowerCase()) .extension(PARAM_EXTENSION, "file") .build()); }); @@ -202,7 +203,7 @@ void givenRequestWithoutRequestHeader_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_HEADER_DETAIL) + .detail(MISSING_HEADER_DETAIL.toLowerCase()) .extension(HEADER_EXTENSION, "X-Custom-Header") .build()); }); @@ -239,7 +240,7 @@ void givenRequestWithoutCookieValue_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_COOKIE_DETAIL) + .detail(MISSING_COOKIE_DETAIL.toLowerCase()) .extension(COOKIE_EXTENSION, "x_session") .build()); }); @@ -276,7 +277,7 @@ void givenRequestWithoutRequestAttribute_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_ATTRIBUTE_DETAIL) + .detail(MISSING_REQUEST_ATTRIBUTE_DETAIL.toLowerCase()) .extension(ATTRIBUTE_EXTENSION, "attr") .build()); }); @@ -297,7 +298,7 @@ void givenRequestWithoutSessionAttribute_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_SESSION_ATTRIBUTE_DETAIL) + .detail(MISSING_SESSION_ATTRIBUTE_DETAIL.toLowerCase()) .extension(ATTRIBUTE_EXTENSION, "attr") .build()); } diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotAcceptableWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotAcceptableWebFluxTest.java index 8f240b40..1e9c426b 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotAcceptableWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotAcceptableWebFluxTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class NotAcceptableWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoHandlerFoundWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoHandlerFoundWebFluxTest.java index d0d0e911..a8468bfd 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoHandlerFoundWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoHandlerFoundWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class NotFoundNoHandlerFoundWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoResourceFoundWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoResourceFoundWebFluxTest.java index 6d02d174..560e2da5 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoResourceFoundWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/NotFoundNoResourceFoundWebFluxTest.java @@ -36,7 +36,8 @@ classes = {WebFluxTestApp.class}, properties = { "spring.webflux.static-path-pattern=/**", - "spring.web.resources.static-locations=classpath:/static/" + "spring.web.resources.static-locations=classpath:/static/", + "problem4j.detail-format=lowercase" }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureWebTestClient diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemAdviceWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemAdviceWebFluxTest.java index 2e1f3eea..1bf10cd1 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemAdviceWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemAdviceWebFluxTest.java @@ -37,7 +37,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ProblemAdviceWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemOverrideWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemOverrideWebFluxTest.java index 4e35feee..280ada18 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemOverrideWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ProblemOverrideWebFluxTest.java @@ -40,7 +40,8 @@ properties = { "problem4j.type-override=https://example.org/type/{problem.type}", "problem4j.instance-override=https://example.org/trace/{context.traceId}", - "problem4j.tracing-header-name=X-Trace-Id" + "problem4j.tracing-header-name=X-Trace-Id", + "problem4j.detail-format=lowercase" }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureWebTestClient diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusAnnotatedExceptionWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusAnnotatedExceptionWebFluxTest.java index c4e516be..70c5a499 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusAnnotatedExceptionWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusAnnotatedExceptionWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ResponseStatusAnnotatedExceptionWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusExceptionWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusExceptionWebFluxTest.java index 9c07a179..51c11340 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusExceptionWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ResponseStatusExceptionWebFluxTest.java @@ -34,7 +34,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ResponseStatusExceptionWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/TypeMismatchWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/TypeMismatchWebFluxTest.java index 35727dde..b7e193e7 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/TypeMismatchWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/TypeMismatchWebFluxTest.java @@ -37,7 +37,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class TypeMismatchWebFluxTest { @@ -58,7 +59,7 @@ void givenRequestWithInvalidPathVariable_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -94,7 +95,7 @@ void givenRequestWithInvalidParameterType_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -131,7 +132,7 @@ void givenRequestWithInvalidRequestHeader_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "X-Id") .extension(KIND_EXTENSION, "integer") .build()); @@ -167,7 +168,7 @@ void givenRequestWithInvalidCookieValue_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -206,7 +207,7 @@ void givenRequestWithInvalidEnumInRequestBody_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "status") .extension(KIND_EXTENSION, "enum") .build()); diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/UnsupportedMediaTypeWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/UnsupportedMediaTypeWebFluxTest.java index cf37f19c..bf81007f 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/UnsupportedMediaTypeWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/UnsupportedMediaTypeWebFluxTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class UnsupportedMediaTypeWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWebFluxTest.java index 9cf2f606..44c439a7 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWebFluxTest.java @@ -44,7 +44,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ValidateMethodArgumentFailingWebFluxTest { @@ -70,7 +71,7 @@ void givenTooShortPathVariable_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "idVar", "error", VIOLATION_ERROR))) .build()); @@ -99,7 +100,7 @@ void givenTooShortRequestParam_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "queryParam", "error", VIOLATION_ERROR))) @@ -125,7 +126,7 @@ void givenTooShortRequestHeader_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "xCustomHeader", "error", VIOLATION_ERROR))) @@ -152,7 +153,7 @@ void givenTooShortCookieValue_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "xSession", "error", VIOLATION_ERROR))) diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWithAdaptingWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWithAdaptingWebFluxTest.java index 7c97ea94..935c977a 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWithAdaptingWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentFailingWithAdaptingWebFluxTest.java @@ -42,7 +42,10 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - properties = {"spring.validation.method.adapt-constraint-violations=true"}, + properties = { + "spring.validation.method.adapt-constraint-violations=true", + "problem4j.detail-format=lowercase" + }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureWebTestClient class ValidateMethodArgumentFailingWithAdaptingWebFluxTest { @@ -71,7 +74,7 @@ void givenTooShortPathVariable_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "id", "error", VIOLATION_ERROR))) @@ -103,7 +106,7 @@ void givenTooShortRequestParam_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "query", "error", VIOLATION_ERROR))) @@ -131,7 +134,7 @@ void givenTooShortRequestHeader_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of( @@ -160,7 +163,7 @@ void givenTooShortCookieValue_shouldReturnValidationProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "x_session", "error", VIOLATION_ERROR))) diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentPassingWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentPassingWebFluxTest.java index f7a20ba6..d7963a44 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentPassingWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateMethodArgumentPassingWebFluxTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ValidateMethodArgumentPassingWebFluxTest { diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateRequestBodyWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateRequestBodyWebFluxTest.java index bd769468..dbd3f7dc 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateRequestBodyWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/ValidateRequestBodyWebFluxTest.java @@ -45,7 +45,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class ValidateRequestBodyWebFluxTest { @@ -70,7 +71,7 @@ void givenInvalidRequestBody_shouldReturnProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "name", "error", "must not be blank"))) @@ -99,7 +100,7 @@ void givenGlobalValidationViolation_shouldReturnProblemWithoutFieldName() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension(ERRORS_EXTENSION, List.of(error)) .build()); }); diff --git a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/WebExchangeBindExceptionWebFluxTest.java b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/WebExchangeBindExceptionWebFluxTest.java index bd11a590..c420e37b 100644 --- a/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/WebExchangeBindExceptionWebFluxTest.java +++ b/problem4j-spring-webflux/src/test/java/io/github/problem4j/spring/webflux/integration/WebExchangeBindExceptionWebFluxTest.java @@ -38,7 +38,8 @@ @SpringBootTest( classes = {WebFluxTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) @AutoConfigureWebTestClient class WebExchangeBindExceptionWebFluxTest { @@ -60,7 +61,7 @@ void givenModelAttributeTypeMismatch_shouldReturnBadRequestProblem() { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "number", "error", "is not valid"))) .build()); diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/BindingPrimitiveWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/BindingPrimitiveWebMvcTest.java index 3af2d8e5..2358baea 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/BindingPrimitiveWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/BindingPrimitiveWebMvcTest.java @@ -45,7 +45,10 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = {"spring.jackson.deserialization.fail-on-null-for-primitives=true"}) + properties = { + "spring.jackson.deserialization.fail-on-null-for-primitives=true", + "problem4j.detail-format=lowercase" + }) class BindingPrimitiveWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -139,7 +142,7 @@ void givenMalformedPrimitive_whenPost_thenReturnProblem(String path, String json Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, expectedKind) .build(); @@ -238,7 +241,7 @@ void givenMalformedNested_whenPost_thenReturnProblem(String path, String json) .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "nested.value") .extension(KIND_EXTENSION, expectedKind) .build()); @@ -282,7 +285,7 @@ void givenEmptyStringPrimitive_whenPost_thenReturnProblem(String path, String js .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, expectedKind) .build()); @@ -313,7 +316,7 @@ void givenOverflowPrimitive_whenPost_thenReturnProblem(String path, String json) Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, "integer") .build(); @@ -342,7 +345,7 @@ void givenNullPrimitive_whenPost_thenReturnProblem() throws JsonProcessingExcept Problem expected = Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "value") .extension(KIND_EXTENSION, "integer") .build(); @@ -402,7 +405,7 @@ void givenMalformedComplexObject_whenPost_thenReturnProblemWithFirstInvalidField .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, expectedProperty) .extension(KIND_EXTENSION, expectedKind) .build()); diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorControllerWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorControllerWebMvcTest.java index ee0865a3..b5f10bc1 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorControllerWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorControllerWebMvcTest.java @@ -36,7 +36,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ErrorControllerWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorResponseWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorResponseWebMvcTest.java index 7998c6ee..a8f9f587 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorResponseWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ErrorResponseWebMvcTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ErrorResponseWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MalformedMultipartWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MalformedMultipartWebMvcTest.java index 5b958829..5b880ab9 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MalformedMultipartWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MalformedMultipartWebMvcTest.java @@ -42,7 +42,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class MalformedMultipartWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -68,7 +69,7 @@ void givenRequestWithMalformedRequestPart_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_PART_DETAIL) + .detail(MISSING_REQUEST_PART_DETAIL.toLowerCase()) .extension(PARAM_EXTENSION, "file") .build()); } diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MaxUploadSizeExceededWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MaxUploadSizeExceededWebMvcTest.java index 33352884..8597a0aa 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MaxUploadSizeExceededWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MaxUploadSizeExceededWebMvcTest.java @@ -45,7 +45,8 @@ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.servlet.multipart.max-file-size=1KB", - "spring.servlet.multipart.max-request-size=1KB" + "spring.servlet.multipart.max-request-size=1KB", + "problem4j.detail-format=lowercase" }) class MaxUploadSizeExceededWebMvcTest { @@ -72,7 +73,7 @@ void givenMaxUploadSizeExceeded_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.PAYLOAD_TOO_LARGE.value()) - .detail(MAX_UPLOAD_SIZE_EXCEEDED_DETAIL) + .detail(MAX_UPLOAD_SIZE_EXCEEDED_DETAIL.toLowerCase()) .build()); } diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodArgumentNotValidWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodArgumentNotValidWebMvcTest.java index 8757cd6b..ded5623a 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodArgumentNotValidWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodArgumentNotValidWebMvcTest.java @@ -40,7 +40,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class MethodArgumentNotValidWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -60,7 +61,7 @@ void givenModelAttributeTypeMismatch_shouldReturnBadRequestProblem() throws Exce .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "number", "error", IS_NOT_VALID_ERROR))) diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodNotAllowedWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodNotAllowedWebMvcTest.java index ece06d71..aace82be 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodNotAllowedWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MethodNotAllowedWebMvcTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class MethodNotAllowedWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MissingParameterWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MissingParameterWebMvcTest.java index 61c427c6..20bbf29a 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MissingParameterWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/MissingParameterWebMvcTest.java @@ -55,7 +55,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class MissingParameterWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -75,7 +76,7 @@ void givenRequestWithoutPathVariable_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_PATH_VARIABLE_DETAIL) + .detail(MISSING_PATH_VARIABLE_DETAIL.toLowerCase()) .extension(NAME_EXTENSION, "var") .build()); } @@ -103,7 +104,7 @@ void givenRequestWithoutRequestParam_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_PARAM_DETAIL) + .detail(MISSING_REQUEST_PARAM_DETAIL.toLowerCase()) .extension(PARAM_EXTENSION, "param") .extension(KIND_EXTENSION, "string") .build()); @@ -138,7 +139,7 @@ void givenRequestWithoutRequestPartParam_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_PART_DETAIL) + .detail(MISSING_REQUEST_PART_DETAIL.toLowerCase()) .extension(PARAM_EXTENSION, "file") .build()); } @@ -193,7 +194,7 @@ void givenRequestWithoutRequestHeader_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_HEADER_DETAIL) + .detail(MISSING_HEADER_DETAIL.toLowerCase()) .extension(HEADER_EXTENSION, "X-Custom-Header") .build()); } @@ -221,7 +222,7 @@ void givenRequestWithoutCookieValue_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_COOKIE_DETAIL) + .detail(MISSING_COOKIE_DETAIL.toLowerCase()) .extension(COOKIE_EXTENSION, "x_session") .build()); } @@ -249,7 +250,7 @@ void givenRequestWithoutRequestAttribute_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_REQUEST_ATTRIBUTE_DETAIL) + .detail(MISSING_REQUEST_ATTRIBUTE_DETAIL.toLowerCase()) .extension(ATTRIBUTE_EXTENSION, "attr") .build()); } @@ -265,7 +266,7 @@ void givenRequestWithoutSessionAttribute_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(MISSING_SESSION_ATTRIBUTE_DETAIL) + .detail(MISSING_SESSION_ATTRIBUTE_DETAIL.toLowerCase()) .extension(ATTRIBUTE_EXTENSION, "attr") .build()); } diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotAcceptableWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotAcceptableWebMvcTest.java index 4f20df5b..758ef8cf 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotAcceptableWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotAcceptableWebMvcTest.java @@ -40,7 +40,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class NotAcceptableWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoHandlerFoundWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoHandlerFoundWebMvcTest.java index e6174911..66e921b4 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoHandlerFoundWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoHandlerFoundWebMvcTest.java @@ -38,7 +38,8 @@ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.mvc.throw-exception-if-no-handler-found=true", - "spring.web.resources.add-mappings=false" + "spring.web.resources.add-mappings=false", + "problem4j.detail-format=lowercase" }) class NotFoundNoHandlerFoundWebMvcTest { diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoResourceFoundWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoResourceFoundWebMvcTest.java index 76fc67da..15aa5e45 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoResourceFoundWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/NotFoundNoResourceFoundWebMvcTest.java @@ -36,7 +36,7 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = {"spring.web.resources.add-mappings=true"}) + properties = {"spring.web.resources.add-mappings=true", "problem4j.detail-format=lowercase"}) class NotFoundNoResourceFoundWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemAdviceWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemAdviceWebMvcTest.java index 06e1046e..29375fd6 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemAdviceWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemAdviceWebMvcTest.java @@ -38,7 +38,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ProblemAdviceWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemOverrideWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemOverrideWebMvcTest.java index e6888b8c..1506c2ca 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemOverrideWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ProblemOverrideWebMvcTest.java @@ -43,7 +43,8 @@ properties = { "problem4j.type-override=https://example.org/type/{problem.type}", "problem4j.instance-override=https://example.org/trace/{context.traceId}", - "problem4j.tracing-header-name=X-Trace-Id" + "problem4j.tracing-header-name=X-Trace-Id", + "problem4j.detail-format=lowercase" }) class ProblemOverrideWebMvcTest { diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusAnnotatedExceptionWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusAnnotatedExceptionWebMvcTest.java index 75c38483..bc46e2fd 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusAnnotatedExceptionWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusAnnotatedExceptionWebMvcTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ResponseStatusAnnotatedExceptionWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusExceptionWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusExceptionWebMvcTest.java index 6959d4d5..b11c4d82 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusExceptionWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ResponseStatusExceptionWebMvcTest.java @@ -35,7 +35,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ResponseStatusExceptionWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/TypeMismatchWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/TypeMismatchWebMvcTest.java index d0033cd0..c512eea8 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/TypeMismatchWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/TypeMismatchWebMvcTest.java @@ -43,7 +43,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class TypeMismatchWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -63,7 +64,7 @@ void givenRequestWithInvalidPathVariable_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -92,7 +93,7 @@ void givenRequestWithInvalidParameterType_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -127,7 +128,7 @@ void givenRequestWithInvalidRequestHeader_shouldReturnProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "X-Id") .extension(KIND_EXTENSION, "integer") .build()); @@ -167,7 +168,7 @@ void givenRequestWithInvalidCookieValue_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "id") .extension(KIND_EXTENSION, "integer") .build()); @@ -208,7 +209,7 @@ void givenRequestWithInvalidEnumInRequestBody_shouldReturnProblem() .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(TYPE_MISMATCH_DETAIL) + .detail(TYPE_MISMATCH_DETAIL.toLowerCase()) .extension(PROPERTY_EXTENSION, "status") .extension(KIND_EXTENSION, "enum") .build()); diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/UnsupportedMediaTypeWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/UnsupportedMediaTypeWebMvcTest.java index a9244d58..68a1472a 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/UnsupportedMediaTypeWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/UnsupportedMediaTypeWebMvcTest.java @@ -38,7 +38,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class UnsupportedMediaTypeWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWebMvcTest.java index 9174091f..4be3128a 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWebMvcTest.java @@ -46,7 +46,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ValidateMethodArgumentFailingWebMvcTest { private static final String VIOLATION_ERROR = "size must be between 5 and " + Integer.MAX_VALUE; @@ -68,7 +69,7 @@ void givenTooShortPathVariable_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "idVar", "error", VIOLATION_ERROR))) .build()); @@ -88,7 +89,7 @@ void givenTooShortRequestParam_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "queryParam", "error", VIOLATION_ERROR))) @@ -116,7 +117,7 @@ void givenTooShortRequestHeader_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "xCustomHeader", "error", VIOLATION_ERROR))) @@ -144,7 +145,7 @@ void givenTooShortCookieValue_shouldReturnValidationProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "xSession", "error", VIOLATION_ERROR))) diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWithAdaptionWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWithAdaptionWebMvcTest.java index 493bd863..db92b055 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWithAdaptionWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentFailingWithAdaptionWebMvcTest.java @@ -46,7 +46,10 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = {"spring.validation.method.adapt-constraint-violations=true"}) + properties = { + "spring.validation.method.adapt-constraint-violations=true", + "problem4j.detail-format=lowercase" + }) class ValidateMethodArgumentFailingWithAdaptionWebMvcTest { private static final String VIOLATION_ERROR = "size must be between 5 and " + Integer.MAX_VALUE; @@ -67,7 +70,7 @@ void givenTooShortPathVariable_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "id", "error", VIOLATION_ERROR))) .build()); @@ -87,7 +90,7 @@ void givenTooShortRequestParam_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "query", "error", VIOLATION_ERROR))) .build()); @@ -114,7 +117,7 @@ void givenTooShortRequestHeader_shouldReturnValidationProblem() throws Exception .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "X-Custom-Header", "error", VIOLATION_ERROR))) @@ -142,7 +145,7 @@ void givenTooShortCookieValue_shouldReturnValidationProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "x_session", "error", VIOLATION_ERROR))) diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentPassingWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentPassingWebMvcTest.java index 0b5ab11d..e8fd33f2 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentPassingWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateMethodArgumentPassingWebMvcTest.java @@ -38,7 +38,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ValidateMethodArgumentPassingWebMvcTest { @Autowired private TestRestTemplate restTemplate; diff --git a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateRequestBodyWebMvcTest.java b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateRequestBodyWebMvcTest.java index cb7fa013..0b49f82f 100644 --- a/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateRequestBodyWebMvcTest.java +++ b/problem4j-spring-webmvc/src/test/java/io/github/problem4j/spring/webmvc/integration/ValidateRequestBodyWebMvcTest.java @@ -49,7 +49,8 @@ @SpringBootTest( classes = {WebMvcTestApp.class}, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = {"problem4j.detail-format=lowercase"}) class ValidateRequestBodyWebMvcTest { @Autowired private TestRestTemplate restTemplate; @@ -71,7 +72,7 @@ void givenInvalidRequestBody_shouldReturnProblem() throws Exception { .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension( ERRORS_EXTENSION, List.of(Map.of("field", "name", "error", "must not be blank"))) @@ -96,7 +97,7 @@ void givenGlobalValidationViolation_shouldReturnProblemWithoutFieldName() throws .isEqualTo( Problem.builder() .status(HttpStatus.BAD_REQUEST.value()) - .detail(VALIDATION_FAILED_DETAIL) + .detail(VALIDATION_FAILED_DETAIL.toLowerCase()) .extension(ERRORS_EXTENSION, List.of(error)) .build()); }