From e6f871b62e41e38b1d50ba490bff795a896f8d19 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 1 Oct 2022 19:22:34 -0700 Subject: [PATCH] Add failing test for #2992 --- .../records/RecordNamingStrategy2992Test.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test-jdk14/java/com/fasterxml/jackson/databind/records/RecordNamingStrategy2992Test.java diff --git a/src/test-jdk14/java/com/fasterxml/jackson/databind/records/RecordNamingStrategy2992Test.java b/src/test-jdk14/java/com/fasterxml/jackson/databind/records/RecordNamingStrategy2992Test.java new file mode 100644 index 0000000000..bf4d34990b --- /dev/null +++ b/src/test-jdk14/java/com/fasterxml/jackson/databind/records/RecordNamingStrategy2992Test.java @@ -0,0 +1,25 @@ +package com.fasterxml.jackson.databind.records; + +import com.fasterxml.jackson.databind.BaseMapTest; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +public class RecordNamingStrategy2992Test extends BaseMapTest +{ + @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) + record Record2992(String myId, String myValue) {} + + private final ObjectMapper MAPPER = newJsonMapper(); + + // [databind#2992] + public void testRecordRenaming2992() throws Exception + { + Record2992 src = new Record2992("id", "value"); + String json = MAPPER.writeValueAsString(src); + assertEquals(a2q("{'my_id':'id','my_value':'value'}"), json); + Record2992 after = MAPPER.readValue(json, Record2992.class); + assertEquals(src.myId(), after.myId()); + assertEquals(src.myValue(), after.myValue()); + } +}