Skip to content

Commit bed9064

Browse files
authored
add more record serialization tests (#4618)
1 parent 475ebbf commit bed9064

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordSerializationOrderTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ record NestedRecordTwo(String id, String passport) {}
2828

2929
record CABRecord(String c, String a, String b) {}
3030

31+
record JsonPropertyRecord(@JsonProperty("aa") int a, int b) {}
32+
33+
record JsonPropertyRecord2(int a, @JsonProperty("bb") int b) {}
34+
3135
private final ObjectMapper MAPPER = newJsonMapper();
3236

3337
/*
@@ -45,6 +49,22 @@ public void testSerializationOrder() throws Exception {
4549
assertEquals(expected, output);
4650
}
4751

52+
@Test
53+
public void testBasicSerializationOrderWithJsonProperty() throws Exception {
54+
JsonPropertyRecord jsonPropertyRecord = new JsonPropertyRecord(1, 2);
55+
final String output = MAPPER.writeValueAsString(jsonPropertyRecord);
56+
final String expected = "{\"aa\":1,\"b\":2}";
57+
assertEquals(expected, output);
58+
}
59+
60+
@Test
61+
public void testBasicSerializationOrderWithJsonProperty2() throws Exception {
62+
JsonPropertyRecord2 jsonPropertyRecord = new JsonPropertyRecord2(1, 2);
63+
final String output = MAPPER.writeValueAsString(jsonPropertyRecord);
64+
final String expected = "{\"a\":1,\"bb\":2}";
65+
assertEquals(expected, output);
66+
}
67+
4868
@Test
4969
public void testSerializationOrderWithJsonProperty() throws Exception {
5070
NestedRecordTwo nestedRecordTwo = new NestedRecordTwo("2", "111110");

0 commit comments

Comments
 (0)