1
1
package com .fasterxml .jackson .datatype .joda .deser ;
2
2
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import org .joda .time .*;
6
+
3
7
import com .fasterxml .jackson .databind .ObjectMapper ;
4
8
import com .fasterxml .jackson .datatype .joda .JodaTestBase ;
5
- import org .joda .time .Days ;
6
- import org .joda .time .Hours ;
7
- import org .joda .time .Minutes ;
8
- import org .joda .time .Months ;
9
- import org .joda .time .ReadablePeriod ;
10
- import org .joda .time .Seconds ;
11
- import org .joda .time .Weeks ;
12
- import org .joda .time .Years ;
13
-
14
- import org .junit .jupiter .api .Test ;
15
9
16
10
import static org .junit .jupiter .api .Assertions .*;
17
11
18
12
public class ReadablePeriodDeserializerTest extends JodaTestBase
19
13
{
14
+ private final ObjectMapper MAPPER = jodaMapper ();
20
15
21
- public void testDeserializeSeconds () throws Exception
22
- {
23
- ObjectMapper objectMapper = jodaMapper ();
24
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" seconds\" },\" seconds\" :12,\" periodType\" :{\" name\" :\" Seconds\" }}" , ReadablePeriod .class );
25
- assertNotNull ( readablePeriod );
26
- assertEquals ( Seconds .seconds ( 12 ), readablePeriod );
27
- }
16
+ @ Test
17
+ public void testDeserializeSeconds () throws Exception
18
+ {
19
+ ReadablePeriod readablePeriod = MAPPER .readValue (
20
+ "{\" fieldType\" :{\" name\" :\" seconds\" },\" seconds\" :12,\" periodType\" :{\" name\" :\" Seconds\" }}" ,
21
+ ReadablePeriod .class );
22
+ assertEquals ( Seconds .seconds ( 12 ), readablePeriod );
23
+ }
28
24
29
- public void testDeserializeMinutes () throws Exception
30
- {
31
- ObjectMapper objectMapper = jodaMapper ();
32
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" minutes\" },\" minutes\" :1,\" periodType\" :{\" name\" :\" Minutes\" }}" , ReadablePeriod .class );
33
- assertNotNull ( readablePeriod );
34
- assertEquals ( Minutes .minutes ( 1 ), readablePeriod );
35
- }
25
+ @ Test
26
+ public void testDeserializeMinutes () throws Exception
27
+ {
28
+ ReadablePeriod readablePeriod = MAPPER .readValue (
29
+ "{\" fieldType\" :{\" name\" :\" minutes\" },\" minutes\" :1,\" periodType\" :{\" name\" :\" Minutes\" }}" ,
30
+ ReadablePeriod .class );
31
+ assertEquals ( Minutes .minutes ( 1 ), readablePeriod );
32
+ }
36
33
37
- public void testDeserializeHours () throws Exception
38
- {
39
- ObjectMapper objectMapper = jodaMapper ();
40
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" hours\" },\" hours\" :2,\" periodType\" :{\" name\" :\" Hours\" }}" , ReadablePeriod .class );
41
- assertNotNull ( readablePeriod );
42
- assertEquals ( Hours .hours ( 2 ), readablePeriod );
43
- }
34
+ @ Test
35
+ public void testDeserializeHours () throws Exception
36
+ {
37
+ ReadablePeriod readablePeriod = MAPPER .readValue (
38
+ "{\" fieldType\" :{\" name\" :\" hours\" },\" hours\" :2,\" periodType\" :{\" name\" :\" Hours\" }}" ,
39
+ ReadablePeriod .class );
40
+ assertEquals ( Hours .hours ( 2 ), readablePeriod );
41
+ }
44
42
45
- public void testDeserializeDays () throws Exception
46
- {
47
- ObjectMapper objectMapper = jodaMapper ();
48
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" days\" },\" days\" :2,\" periodType\" :{\" name\" :\" Days\" }}" , ReadablePeriod .class );
49
- assertNotNull ( readablePeriod );
50
- assertEquals ( Days .days ( 2 ), readablePeriod );
51
- }
43
+ @ Test
44
+ public void testDeserializeDays () throws Exception
45
+ {
46
+ ReadablePeriod readablePeriod = MAPPER .readValue (
47
+ "{\" fieldType\" :{\" name\" :\" days\" },\" days\" :2,\" periodType\" :{\" name\" :\" Days\" }}" ,
48
+ ReadablePeriod .class );
49
+ assertEquals ( Days .days ( 2 ), readablePeriod );
50
+ }
52
51
53
- public void testDeserializeWeeks () throws Exception
54
- {
55
- ObjectMapper objectMapper = jodaMapper ();
56
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" weeks\" },\" weeks\" :2,\" periodType\" :{\" name\" :\" Weeks\" }}" , ReadablePeriod .class );
57
- assertNotNull ( readablePeriod );
58
- assertEquals ( Weeks .weeks ( 2 ), readablePeriod );
59
- }
52
+ @ Test
53
+ public void testDeserializeWeeks () throws Exception
54
+ {
55
+ ReadablePeriod readablePeriod = MAPPER .readValue (
56
+ "{\" fieldType\" :{\" name\" :\" weeks\" },\" weeks\" :2,\" periodType\" :{\" name\" :\" Weeks\" }}" ,
57
+ ReadablePeriod .class );
58
+ assertEquals ( Weeks .weeks ( 2 ), readablePeriod );
59
+ }
60
60
61
- public void testDeserializeMonths () throws Exception
62
- {
63
- ObjectMapper objectMapper = jodaMapper ();
64
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" months\" },\" months\" :2,\" periodType\" :{\" name\" :\" Months\" }}" , ReadablePeriod .class );
65
- assertNotNull ( readablePeriod );
66
- assertEquals ( Months .months ( 2 ), readablePeriod );
67
- }
61
+ @ Test
62
+ public void testDeserializeMonths () throws Exception
63
+ {
64
+ ReadablePeriod readablePeriod = MAPPER .readValue (
65
+ "{\" fieldType\" :{\" name\" :\" months\" },\" months\" :2,\" periodType\" :{\" name\" :\" Months\" }}" ,
66
+ ReadablePeriod .class );
67
+ assertEquals ( Months .months ( 2 ), readablePeriod );
68
+ }
68
69
69
- public void testDeserializeYears () throws Exception
70
- {
71
- ObjectMapper objectMapper = jodaMapper ();
72
- ReadablePeriod readablePeriod = objectMapper .readValue ( "{\" fieldType\" :{\" name\" :\" years\" },\" years\" :2,\" periodType\" :{\" name\" :\" Years\" }}" , ReadablePeriod .class );
73
- assertNotNull ( readablePeriod );
74
- assertEquals ( Years .years ( 2 ), readablePeriod );
75
- }
76
- }
70
+ @ Test
71
+ public void testDeserializeYears () throws Exception
72
+ {
73
+ ReadablePeriod readablePeriod = MAPPER .readValue (
74
+ "{\" fieldType\" :{\" name\" :\" years\" },\" years\" :2,\" periodType\" :{\" name\" :\" Years\" }}" ,
75
+ ReadablePeriod .class );
76
+ assertEquals ( Years .years ( 2 ), readablePeriod );
77
+ }
78
+ }
0 commit comments