aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/tests/MessageTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/tests/MessageTests.java')
-rw-r--r--src/test/java/com/juick/tests/MessageTests.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java
index 25a5115e..2cc8fed2 100644
--- a/src/test/java/com/juick/tests/MessageTests.java
+++ b/src/test/java/com/juick/tests/MessageTests.java
@@ -18,6 +18,8 @@
package com.juick.tests;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.juick.Message;
import com.juick.util.DateFormattersHolder;
import org.apache.commons.codec.CharEncoding;
@@ -38,7 +40,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.text.ParseException;
-import java.util.Date;
+import java.time.Instant;
import static org.junit.Assert.assertEquals;
@@ -51,9 +53,11 @@ public class MessageTests {
assertEquals("First tag must be", "test", msg.getTags().get(0).getName());
assertEquals("Third tag must be", "test3", msg.getTags().get(2).getName());
assertEquals("Count of tags must be", 3, msg.getTags().size());
- Date currentDate = new Date();
- msg.setDate(currentDate);
+ Instant currentDate = Instant.now();
+ msg.setTimestamp(currentDate);
ObjectMapper serializer = new ObjectMapper();
+ serializer.registerModule(new Jdk8Module());
+ serializer.registerModule(new JavaTimeModule());
String jsonMessage = serializer.writeValueAsString(msg);
JSONObject jsonObject = new JSONObject(jsonMessage);
assertEquals("date should be in timestamp field", DateFormattersHolder.getMessageFormatterInstance().format(currentDate),