From 8846b471ebd3467342bd4b3f0d63156382cc0945 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 26 Dec 2019 20:21:11 -0800 Subject: [PATCH] Add (failing) test for #2527 --- .../failing/IsGetterRenaming2527Test.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/com/fasterxml/jackson/failing/IsGetterRenaming2527Test.java diff --git a/src/test/java/com/fasterxml/jackson/failing/IsGetterRenaming2527Test.java b/src/test/java/com/fasterxml/jackson/failing/IsGetterRenaming2527Test.java new file mode 100644 index 0000000000..fc7357db78 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/failing/IsGetterRenaming2527Test.java @@ -0,0 +1,37 @@ +package com.fasterxml.jackson.failing; + +import java.util.Collections; +import java.util.Map; + +import com.fasterxml.jackson.databind.*; + +// [databind#2527] Support Kotlin-style "is" properties +public class IsGetterRenaming2527Test extends BaseMapTest +{ + static class POJO2527 { + private boolean isEnabled; + + protected POJO2527() { } + public POJO2527(boolean b) { + isEnabled = b; + } + + public boolean getEnabled() { return isEnabled; } + public void setEnabled(boolean b) { isEnabled = b; } + } + + private final ObjectMapper MAPPER = newJsonMapper(); + + public void testIsProperties() throws Exception + { + POJO2527 input = new POJO2527(true); + final String json = MAPPER.writeValueAsString(input); + + Map props = MAPPER.readValue(json, Map.class); + assertEquals(Collections.singletonMap("isEnabled", Boolean.TRUE), + props); + + POJO2527 output = MAPPER.readValue(json, POJO2527.class); + assertEquals(input.isEnabled, output.isEnabled); + } +}