From 3744f17d661247a9becc3a76121456608b182f33 Mon Sep 17 00:00:00 2001 From: Andriy Dmytruk <80816836+andriy-dmytruk@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:21:35 -0400 Subject: [PATCH] Improve the ControllerConstraintHandlerTest to accept more HttpRequest body types (#10909) --- .../constraintshandler/ControllerConstraintHandlerTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http-server-tck/src/main/java/io/micronaut/http/server/tck/tests/constraintshandler/ControllerConstraintHandlerTest.java b/http-server-tck/src/main/java/io/micronaut/http/server/tck/tests/constraintshandler/ControllerConstraintHandlerTest.java index d2d978a2545..390d0818032 100644 --- a/http-server-tck/src/main/java/io/micronaut/http/server/tck/tests/constraintshandler/ControllerConstraintHandlerTest.java +++ b/http-server-tck/src/main/java/io/micronaut/http/server/tck/tests/constraintshandler/ControllerConstraintHandlerTest.java @@ -19,6 +19,7 @@ import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.NonNull; import io.micronaut.core.annotation.Nullable; +import io.micronaut.core.convert.value.ConvertibleValues; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpRequest; import io.micronaut.http.HttpStatus; @@ -191,6 +192,10 @@ Optional constraintsEx(ConstraintViolationException e, HttpRequest reque password = credentials.getPassword(); } else if (obj instanceof CredentialsWithNonNull credentials) { password = credentials.getPassword(); + } else if (obj instanceof Map map) { + password = map.get("password") == null ? null : map.get("password").toString(); + } else if (obj instanceof ConvertibleValues values) { + password = values.get("password", String.class).orElse(null); } return password != null ? Optional.of(Map.of("password", password)) : Optional.empty(); }