Skip to content

Commit

Permalink
add more record serialization tests (#4618)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Jul 9, 2024
1 parent 475ebbf commit bed9064
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ record NestedRecordTwo(String id, String passport) {}

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

record JsonPropertyRecord(@JsonProperty("aa") int a, int b) {}

record JsonPropertyRecord2(int a, @JsonProperty("bb") int b) {}

private final ObjectMapper MAPPER = newJsonMapper();

/*
Expand All @@ -45,6 +49,22 @@ public void testSerializationOrder() throws Exception {
assertEquals(expected, output);
}

@Test
public void testBasicSerializationOrderWithJsonProperty() throws Exception {
JsonPropertyRecord jsonPropertyRecord = new JsonPropertyRecord(1, 2);
final String output = MAPPER.writeValueAsString(jsonPropertyRecord);
final String expected = "{\"aa\":1,\"b\":2}";
assertEquals(expected, output);
}

@Test
public void testBasicSerializationOrderWithJsonProperty2() throws Exception {
JsonPropertyRecord2 jsonPropertyRecord = new JsonPropertyRecord2(1, 2);
final String output = MAPPER.writeValueAsString(jsonPropertyRecord);
final String expected = "{\"a\":1,\"bb\":2}";
assertEquals(expected, output);
}

@Test
public void testSerializationOrderWithJsonProperty() throws Exception {
NestedRecordTwo nestedRecordTwo = new NestedRecordTwo("2", "111110");
Expand Down

0 comments on commit bed9064

Please sign in to comment.