Skip to content

Commit

Permalink
Fix Boolean serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
luneo7 committed Sep 5, 2024
1 parent af853db commit c9e6130
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ public class Dog extends AbstractNamedPet {
@JsonProperty("age")
private int publicAge;

@JsonProperty("vaccinated")
private Boolean publicVaccinated;

public int getPublicAge() {
return publicAge;
}

public void setPublicAge(int publicAge) {
this.publicAge = publicAge;
}

public Boolean getPublicVaccinated() {
return publicVaccinated;
}

public void setPublicVaccinated(Boolean publicVaccinated) {
this.publicVaccinated = publicVaccinated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private static Dog createDog() {
dog.setPrivateName("Jack");
dog.setPublicName("Leo");
dog.setVeterinarian(createVeterinarian());
dog.setPublicVaccinated(true);
return dog;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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());
}
Expand Down

0 comments on commit c9e6130

Please sign in to comment.