diff options
Diffstat (limited to 'src/test/java/com/juick')
-rw-r--r-- | src/test/java/com/juick/rss/LegacyRSS.java | 4 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/ApiTests.java | 3 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/MessageTests.java | 10 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/test/java/com/juick/rss/LegacyRSS.java b/src/test/java/com/juick/rss/LegacyRSS.java index 2ad276c7..3038e2d2 100644 --- a/src/test/java/com/juick/rss/LegacyRSS.java +++ b/src/test/java/com/juick/rss/LegacyRSS.java @@ -119,7 +119,7 @@ public class LegacyRSS { out.println("]]></title>"); out.println("<description><![CDATA[" + MessageUtils.formatMessage(msg.getText()) + "]]></description>"); - out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(msg.getDate()) + "</pubDate>"); + out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(msg.getTimestamp()) + "</pubDate>"); out.println("<comments>http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "</comments>"); if (!msg.getTags().isEmpty()) { @@ -190,7 +190,7 @@ public class LegacyRSS { out.println("<author>http://juick.com/" + r.uname + "/</author>"); out.println("<title>@" + r.uname + ":</title>"); out.println("<description><![CDATA[" + MessageUtils.formatMessage(r.description) + "]]></description>"); - out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(r.pubDate) + "</pubDate>"); + out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(r.pubDate.toInstant()) + "</pubDate>"); String attachment = r.attachmentType; if (attachment != null && !attachment.isEmpty()) { if (attachment.equals("jpg")) { 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), |