Skip to content

Commit 866f95f

Browse files
committed
Add test for #4715 in 2.15 (passing)
1 parent 0dfae66 commit 866f95f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fasterxml.jackson.databind.jdk17;
2+
3+
import java.util.Collections;
4+
5+
import com.fasterxml.jackson.databind.BaseMapTest;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
7+
8+
// for [databind#4175]
9+
public class RecordPrivate4175Test extends BaseMapTest
10+
{
11+
private static record PrivateTextRecord4175(String text) { }
12+
13+
private final ObjectMapper MAPPER = newJsonMapper();
14+
15+
// for [databind#4175]
16+
public void testSerializePrivateTextRecord() throws Exception {
17+
PrivateTextRecord4175 textRecord = new PrivateTextRecord4175("anything");
18+
String json = MAPPER.writeValueAsString(textRecord);
19+
final Object EXP = Collections.singletonMap("text", "anything");
20+
assertEquals(EXP, MAPPER.readValue(json, Object.class));
21+
}
22+
23+
public void testDeserializePrivateTextRecord() throws Exception {
24+
assertEquals(new PrivateTextRecord4175("anything"),
25+
MAPPER.readValue("{\"text\":\"anything\"}", PrivateTextRecord4175.class));
26+
}
27+
}

0 commit comments

Comments
 (0)