aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/juick/tests')
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java3
-rw-r--r--src/test/java/com/juick/tests/MessageTests.java10
2 files changed, 7 insertions, 6 deletions
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 7001d3f0..51641c1d 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -168,9 +168,6 @@ public class ApiTests {
int mid = messagesService.createMessage(user_id, "yo", null, new ArrayList<>());
Message msg = messagesService.getMessage(mid);
assertEquals("yo", msg.getText());
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(msg.getDate());
- assertEquals(2017, calendar.get(Calendar.YEAR));
User me = msg.getUser();
assertEquals("mmmme", me.getName());
assertEquals("mmmme", messagesService.getMessageAuthor(mid).getName());
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),