From c9e613075397fcda1c2d726f9ccda4d04c765c90 Mon Sep 17 00:00:00 2001 From: luneo7 Date: Thu, 5 Sep 2024 16:18:28 -0500 Subject: [PATCH] Fix Boolean serializer --- .../deployment/processor/JacksonCodeGenerator.java | 1 + .../reactive/jackson/deployment/test/Dog.java | 11 +++++++++++ .../jackson/deployment/test/SimpleJsonResource.java | 1 + .../jackson/deployment/test/SimpleJsonTest.java | 3 ++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonCodeGenerator.java b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonCodeGenerator.java index fc49caf53da99..141af26ef3032 100644 --- a/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonCodeGenerator.java +++ b/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonCodeGenerator.java @@ -357,6 +357,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 0595f346dc4f7..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 @@ -171,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 93717d4c53028..6dd69a65347ca 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 @@ -661,7 +661,7 @@ private static void testSecuredFieldOnAbstractClass(String catPath, String dogPa public void testEcho() { RestAssured .with() - .body("{\"publicName\":\"Leo\",\"veterinarian\":{\"name\":\"Dolittle\"},\"age\":5}") + .body("{\"publicName\":\"Leo\",\"veterinarian\":{\"name\":\"Dolittle\"},\"age\":5,\"vaccinated\":true}") .contentType("application/json; charset=utf-8") .post("/simple/dog-echo") .then() @@ -670,6 +670,7 @@ public void testEcho() { .body("publicName", Matchers.is("Leo")) .body("privateName", Matchers.nullValue()) .body("age", Matchers.is(5)) + .body("vaccinated", Matchers.is(true)) .body("veterinarian.name", Matchers.is("Dolittle")) .body("veterinarian.title", Matchers.nullValue()); }