Skip to content

Commit

Permalink
Add failing test for #2992
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 2, 2022
1 parent 90aeb43 commit e6f871b
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit e6f871b

Please sign in to comment.