@@ -30,6 +30,9 @@ record JsonIgnoreRecord(int id, @JsonIgnore String name) {
30
30
record JsonPropertyRenameRecord (int id , @ JsonProperty ("rename" )String name ) {
31
31
}
32
32
33
+ record EmptyRecord () {
34
+ }
35
+
33
36
private final ObjectMapper MAPPER = newJsonMapper ();
34
37
35
38
/*
@@ -65,16 +68,23 @@ public void testRecordJavaType() {
65
68
*/
66
69
67
70
public void testSerializeSimpleRecord () throws Exception {
68
- SimpleRecord record = new SimpleRecord (123 , "Bob" );
69
-
70
- String json = MAPPER .writeValueAsString (record );
71
+ String json = MAPPER .writeValueAsString (new SimpleRecord (123 , "Bob" ));
71
72
final Object EXP = map ("id" , Integer .valueOf (123 ), "name" , "Bob" );
72
73
assertEquals (EXP , MAPPER .readValue (json , Object .class ));
73
74
}
74
75
75
76
public void testDeserializeSimpleRecord () throws Exception {
76
- SimpleRecord value = MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" , SimpleRecord .class );
77
- assertEquals (new SimpleRecord (123 , "Bob" ), value );
77
+ assertEquals (new SimpleRecord (123 , "Bob" ),
78
+ MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" , SimpleRecord .class ));
79
+ }
80
+
81
+ public void testSerializeEmptyRecord () throws Exception {
82
+ assertEquals ("{}" , MAPPER .writeValueAsString (new EmptyRecord ()));
83
+ }
84
+
85
+ public void testDeserializeEmptyRecord () throws Exception {
86
+ assertEquals (new EmptyRecord (),
87
+ MAPPER .readValue ("{}" , EmptyRecord .class ));
78
88
}
79
89
80
90
public void testSerializeRecordOfRecord () throws Exception {
0 commit comments