From 3c8e4e3ad1dd2d7651c7078046b35d8d1d4cacc3 Mon Sep 17 00:00:00 2001 From: luneo7 Date: Fri, 6 Sep 2024 09:13:01 -0500 Subject: [PATCH] Fix Boolean serializer --- .../processor/JacksonSerializerFactory.java | 1 + .../reactive/jackson/deployment/test/Dog.java | 11 +++++++++++ .../deployment/test/SimpleJsonResource.java | 8 ++++++++ .../jackson/deployment/test/SimpleJsonTest.java | 17 +++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializerFactory.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializerFactory.java index 691d102c35ddf..39b9c10e3fe8e 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializerFactory.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializerFactory.java @@ -619,6 +619,7 @@ String writtenType() { case "java.lang.Long" -> "long"; case "java.lang.Double" -> "double"; case "java.lang.Float" -> "float"; + case "java.lang.Boolean" -> "boolean"; default -> fieldType.name().toString(); }; } diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Dog.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Dog.java index 20a4d3e2166b4..ebea3f8df9d03 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Dog.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Dog.java @@ -7,6 +7,9 @@ public class Dog extends AbstractNamedPet { @JsonProperty("age") private int publicAge; + @JsonProperty("vaccinated") + private Boolean publicVaccinated; + public int getPublicAge() { return publicAge; } @@ -14,4 +17,12 @@ public int getPublicAge() { public void setPublicAge(int publicAge) { this.publicAge = publicAge; } + + public Boolean getPublicVaccinated() { + return publicVaccinated; + } + + public void setPublicVaccinated(Boolean publicVaccinated) { + this.publicVaccinated = publicVaccinated; + } } diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java index 6a48584164760..05235155aad78 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java @@ -109,6 +109,13 @@ public Dog getDog() { return createDog(); } + @POST + @Path("/dog-echo") + @Consumes(MediaType.APPLICATION_JSON) + public Dog echoDog(Dog dog) { + return dog; + } + @EnableSecureSerialization @GET @Path("/abstract-cat") @@ -164,6 +171,7 @@ private static Dog createDog() { dog.setPrivateName("Jack"); dog.setPublicName("Leo"); dog.setVeterinarian(createVeterinarian()); + dog.setPublicVaccinated(true); return dog; } diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java index 3db48396587fa..b7b48b1d4b670 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java @@ -656,4 +656,21 @@ private static void testSecuredFieldOnAbstractClass(String catPath, String dogPa .body("veterinarian.name", Matchers.is("Dolittle")) .body("veterinarian.title", Matchers.is("VMD")); } + + @Test + public void testEcho() { + RestAssured + .with() + .body("{\"publicName\":\"Leo\",\"veterinarian\":{\"name\":\"Dolittle\"},\"age\":5,\"vaccinated\":true}") + .contentType("application/json; charset=utf-8") + .post("/simple/dog-echo") + .then() + .statusCode(200) + .contentType("application/json") + .body("publicName", Matchers.is("Leo")) + .body("privateName", Matchers.nullValue()) + .body("age", Matchers.is(5)) + .body("veterinarian.name", Matchers.is("Dolittle")) + .body("veterinarian.title", Matchers.nullValue()); + } }