|
5 | 5 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
6 | 6 | import com.fasterxml.jackson.datatype.joda.deser.DateTimeDeserializer;
|
7 | 7 | import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer;
|
| 8 | + |
8 | 9 | import org.joda.time.DateTime;
|
9 | 10 | import org.joda.time.DateTimeZone;
|
10 |
| -import org.junit.Test; |
11 |
| - |
12 |
| -import static org.junit.Assert.assertEquals; |
13 |
| - |
14 | 11 |
|
15 |
| -class AClass{ |
16 |
| - @JsonSerialize(using = DateTimeSerializer.class) |
17 |
| - @JsonDeserialize(using = DateTimeDeserializer.class) |
18 |
| - private DateTime createdOn = DateTime.now(DateTimeZone.UTC); |
| 12 | +public class AnnotationTest extends DateTimeTest |
| 13 | +{ |
| 14 | + static class AClass{ |
| 15 | + @JsonSerialize(using = DateTimeSerializer.class) |
| 16 | + @JsonDeserialize(using = DateTimeDeserializer.class) |
| 17 | + private DateTime createdOn = DateTime.now(DateTimeZone.UTC); |
19 | 18 |
|
20 |
| - public DateTime getCreatedOn() { |
21 |
| - return createdOn; |
22 |
| - } |
| 19 | + public DateTime getCreatedOn() { |
| 20 | + return createdOn; |
| 21 | + } |
23 | 22 |
|
24 |
| - public void setCreatedOn(DateTime createdOn) { |
25 |
| - this.createdOn = createdOn; |
| 23 | + public void setCreatedOn(DateTime createdOn) { |
| 24 | + this.createdOn = createdOn; |
| 25 | + } |
26 | 26 | }
|
27 |
| -} |
28 |
| - |
29 |
| -public class AnnotationTest { |
30 | 27 |
|
31 |
| - @Test |
32 |
| - public void testSomeMethod() throws Exception { |
| 28 | + public void testDateTimeViaAnnotation() throws Exception { |
33 | 29 | ObjectMapper objectMapper = new ObjectMapper();
|
34 | 30 | AClass initialObject = new AClass();
|
35 | 31 | String serializedObject = objectMapper.writeValueAsString(initialObject);
|
|
0 commit comments