2
2
3
3
import com .fasterxml .jackson .annotation .JsonIgnore ;
4
4
import com .fasterxml .jackson .annotation .JsonProperty ;
5
- import com . fasterxml . jackson . core . JsonProcessingException ;
5
+
6
6
import com .fasterxml .jackson .databind .json .JsonMapper ;
7
7
import com .fasterxml .jackson .databind .util .ClassUtil ;
8
8
9
- import java .io .IOException ;
10
9
import java .util .Collections ;
11
10
import java .util .LinkedHashMap ;
12
11
import java .util .Map ;
@@ -65,20 +64,20 @@ public void testRecordJavaType() {
65
64
/**********************************************************************
66
65
*/
67
66
68
- public void testSerializeSimpleRecord () throws JsonProcessingException {
67
+ public void testSerializeSimpleRecord () throws Exception {
69
68
SimpleRecord record = new SimpleRecord (123 , "Bob" );
70
69
71
70
String json = MAPPER .writeValueAsString (record );
72
71
final Object EXP = map ("id" , Integer .valueOf (123 ), "name" , "Bob" );
73
72
assertEquals (EXP , MAPPER .readValue (json , Object .class ));
74
73
}
75
74
76
- public void testDeserializeSimpleRecord () throws IOException {
75
+ public void testDeserializeSimpleRecord () throws Exception {
77
76
SimpleRecord value = MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" , SimpleRecord .class );
78
77
assertEquals (new SimpleRecord (123 , "Bob" ), value );
79
78
}
80
79
81
- public void testSerializeRecordOfRecord () throws JsonProcessingException {
80
+ public void testSerializeRecordOfRecord () throws Exception {
82
81
RecordOfRecord record = new RecordOfRecord (new SimpleRecord (123 , "Bob" ));
83
82
String json = MAPPER .writeValueAsString (record );
84
83
final Object EXP = Collections .singletonMap ("record" ,
@@ -92,7 +91,7 @@ public void testSerializeRecordOfRecord() throws JsonProcessingException {
92
91
/**********************************************************************
93
92
*/
94
93
95
- public void testSerializeSimpleRecord_DisableAnnotationIntrospector () throws JsonProcessingException {
94
+ public void testSerializeSimpleRecord_DisableAnnotationIntrospector () throws Exception {
96
95
SimpleRecord record = new SimpleRecord (123 , "Bob" );
97
96
98
97
JsonMapper mapper = JsonMapper .builder ()
@@ -103,7 +102,7 @@ public void testSerializeSimpleRecord_DisableAnnotationIntrospector() throws Jso
103
102
assertEquals ("{\" id\" :123,\" name\" :\" Bob\" }" , json );
104
103
}
105
104
106
- public void testDeserializeSimpleRecord_DisableAnnotationIntrospector () throws IOException {
105
+ public void testDeserializeSimpleRecord_DisableAnnotationIntrospector () throws Exception {
107
106
JsonMapper mapper = JsonMapper .builder ()
108
107
.configure (MapperFeature .USE_ANNOTATIONS , false )
109
108
.build ();
@@ -118,29 +117,29 @@ public void testDeserializeSimpleRecord_DisableAnnotationIntrospector() throws I
118
117
/**********************************************************************
119
118
*/
120
119
121
- public void testSerializeJsonIgnoreRecord () throws JsonProcessingException {
120
+ public void testSerializeJsonIgnoreRecord () throws Exception {
122
121
JsonIgnoreRecord record = new JsonIgnoreRecord (123 , "Bob" );
123
122
124
123
String json = MAPPER .writeValueAsString (record );
125
124
126
125
assertEquals ("{\" id\" :123}" , json );
127
126
}
128
127
129
- public void testDeserializeRecordWithConstructor () throws IOException {
128
+ public void testDeserializeRecordWithConstructor () throws Exception {
130
129
RecordWithConstructor value = MAPPER .readValue ("{\" id\" :123,\" name\" :\" Bob\" }" ,
131
130
RecordWithConstructor .class );
132
131
assertEquals (new RecordWithConstructor (123 , "Bob" ), value );
133
132
}
134
133
135
- public void testSerializeJsonRenameRecord () throws JsonProcessingException {
134
+ public void testSerializeJsonRenameRecord () throws Exception {
136
135
JsonPropertyRenameRecord record = new JsonPropertyRenameRecord (123 , "Bob" );
137
136
138
137
String json = MAPPER .writeValueAsString (record );
139
138
final Object EXP = map ("id" , Integer .valueOf (123 ), "rename" , "Bob" );
140
139
assertEquals (EXP , MAPPER .readValue (json , Object .class ));
141
140
}
142
141
143
- public void testDeserializeJsonRenameRecord () throws IOException {
142
+ public void testDeserializeJsonRenameRecord () throws Exception {
144
143
JsonPropertyRenameRecord value = MAPPER .readValue ("{\" id\" :123,\" rename\" :\" Bob\" }" ,
145
144
JsonPropertyRenameRecord .class );
146
145
assertEquals (new JsonPropertyRenameRecord (123 , "Bob" ), value );
0 commit comments