@@ -193,7 +193,6 @@ public void testDeserializationAsInt01() throws Exception
193
193
{
194
194
Duration value = READER .with (DeserializationFeature .READ_DATE_TIMESTAMPS_AS_NANOSECONDS )
195
195
.readValue ("60" );
196
- assertNotNull ("The value should not be null." , value );
197
196
assertEquals ("The value is not correct." , Duration .ofSeconds (60L , 0 ), value );
198
197
}
199
198
@@ -202,8 +201,6 @@ public void testDeserializationAsInt02() throws Exception
202
201
{
203
202
Duration value = READER .without (DeserializationFeature .READ_DATE_TIMESTAMPS_AS_NANOSECONDS )
204
203
.readValue ("60000" );
205
-
206
- assertNotNull ("The value should not be null." , value );
207
204
assertEquals ("The value is not correct." , Duration .ofSeconds (60L , 0 ), value );
208
205
}
209
206
@@ -212,8 +209,6 @@ public void testDeserializationAsInt03() throws Exception
212
209
{
213
210
Duration value = READER .with (DeserializationFeature .READ_DATE_TIMESTAMPS_AS_NANOSECONDS )
214
211
.readValue ("13498" );
215
-
216
- assertNotNull ("The value should not be null." , value );
217
212
assertEquals ("The value is not correct." , Duration .ofSeconds (13498L , 0 ), value );
218
213
}
219
214
@@ -222,8 +217,6 @@ public void testDeserializationAsInt04() throws Exception
222
217
{
223
218
Duration value = READER .without (DeserializationFeature .READ_DATE_TIMESTAMPS_AS_NANOSECONDS )
224
219
.readValue ("13498000" );
225
-
226
- assertNotNull ("The value should not be null." , value );
227
220
assertEquals ("The value is not correct." , Duration .ofSeconds (13498L , 0 ), value );
228
221
}
229
222
@@ -232,8 +225,6 @@ public void testDeserializationAsString01() throws Exception
232
225
{
233
226
Duration exp = Duration .ofSeconds (60L , 0 );
234
227
Duration value = READER .readValue ('"' + exp .toString () + '"' );
235
-
236
- assertNotNull ("The value should not be null." , value );
237
228
assertEquals ("The value is not correct." , exp , value );
238
229
}
239
230
@@ -242,16 +233,13 @@ public void testDeserializationAsString02() throws Exception
242
233
{
243
234
Duration exp = Duration .ofSeconds (13498L , 8374 );
244
235
Duration value = READER .readValue ('"' + exp .toString () + '"' );
245
-
246
- assertNotNull ("The value should not be null." , value );
247
236
assertEquals ("The value is not correct." , exp , value );
248
237
}
249
238
250
239
@ Test
251
240
public void testDeserializationAsString03 () throws Exception
252
241
{
253
- Duration value = READER .readValue ("\" \" " );
254
- assertNull ("The value should be null." , value );
242
+ assertNull ("The value should be null." , READER .readValue ("\" \" " ));
255
243
}
256
244
257
245
@ Test
@@ -336,11 +324,11 @@ public void testDeserializationAsEmptyArrayDisabled() throws Throwable
336
324
READER .readValue ("[]" );
337
325
fail ("expected MismatchedInputException" );
338
326
} catch (MismatchedInputException e ) {
339
- verifyException (e , "Cannot deserialize instance of `java.time.Duration` out of START_ARRAY" );
327
+ // 17-Aug-2019, tatu: Message differs between 2.10 and 3.0...
328
+ verifyException (e , "Cannot deserialize value of type `java.time.Duration` out of START_ARRAY" );
340
329
}
341
330
try {
342
- newMapper ().readerFor (Duration .class )
343
- .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS )
331
+ READER .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS )
344
332
.readValue (aposToQuotes ("[]" ));
345
333
fail ("expected MismatchedInputException" );
346
334
} catch (MismatchedInputException e ) {
@@ -350,23 +338,20 @@ public void testDeserializationAsEmptyArrayDisabled() throws Throwable
350
338
351
339
@ Test
352
340
public void testDeserializationAsArrayEnabled () throws Exception {
353
- Duration exp = Duration .ofSeconds (13498L , 8374 );
354
- Duration value = newMapper ().readerFor (Duration .class )
355
- .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS )
356
- .readValue ("[\" " + exp .toString () + "\" ]" );
357
-
358
- assertNotNull ("The value should not be null." , value );
359
- assertEquals ("The value is not correct." , exp , value );
341
+ Duration exp = Duration .ofSeconds (13498L , 8374 );
342
+ Duration value = newMapper ().readerFor (Duration .class )
343
+ .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS )
344
+ .readValue ("[\" " + exp .toString () + "\" ]" );
345
+ assertEquals ("The value is not correct." , exp , value );
360
346
}
361
347
362
348
@ Test
363
349
public void testDeserializationAsEmptyArrayEnabled () throws Throwable
364
350
{
365
- String json ="[]" ;
366
- Duration value = newMapper ().readerFor (Duration .class )
367
- .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS ,
368
- DeserializationFeature .ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT )
369
- .readValue (aposToQuotes (json ));
370
- assertNull (value );
351
+ Duration value = newMapper ().readerFor (Duration .class )
352
+ .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS ,
353
+ DeserializationFeature .ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT )
354
+ .readValue ("[]" );
355
+ assertNull (value );
371
356
}
372
357
}
0 commit comments