aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'juick-core/src/test')
-rw-r--r--juick-core/src/test/java/com/juick/FormatterTest.java17
-rw-r--r--juick-core/src/test/java/com/juick/test/util/MockUtils.java4
2 files changed, 11 insertions, 10 deletions
diff --git a/juick-core/src/test/java/com/juick/FormatterTest.java b/juick-core/src/test/java/com/juick/FormatterTest.java
index d9324b8e..397c4b6c 100644
--- a/juick-core/src/test/java/com/juick/FormatterTest.java
+++ b/juick-core/src/test/java/com/juick/FormatterTest.java
@@ -21,6 +21,7 @@ import com.juick.util.DateFormattersHolder;
import org.apache.commons.lang3.RandomUtils;
import org.junit.Test;
+import java.time.Instant;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -36,15 +37,15 @@ public class FormatterTest {
@Test
public void forAnyDateFormatterShouldReturnNotEmptyString() throws Exception {
- Date date = new Date();
+ Instant ts = Instant.now();
- assertThat(DateFormattersHolder.getMessageFormatterInstance().format(date), not(isEmptyOrNullString()));
- assertThat(DateFormattersHolder.getRssFormatterInstance().format(date), not(isEmptyOrNullString()));
+ assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString()));
+ assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString()));
- date = new Date(RandomUtils.nextLong(1, Long.MAX_VALUE / 10000));
+ ts = Instant.ofEpochMilli(RandomUtils.nextLong(1, Long.MAX_VALUE / 10000));
- assertThat(DateFormattersHolder.getMessageFormatterInstance().format(date), not(isEmptyOrNullString()));
- assertThat(DateFormattersHolder.getRssFormatterInstance().format(date), not(isEmptyOrNullString()));
+ assertThat(DateFormattersHolder.getMessageFormatterInstance().format(ts), not(isEmptyOrNullString()));
+ assertThat(DateFormattersHolder.getRssFormatterInstance().format(ts), not(isEmptyOrNullString()));
}
@Test
@@ -56,7 +57,7 @@ public class FormatterTest {
Date date = calendar.getTime();
- assertThat(DateFormattersHolder.getMessageFormatterInstance().format(date), equalTo("2012-01-01 00:00:00"));
- assertThat(DateFormattersHolder.getRssFormatterInstance().format(date), equalTo("Sun, 1 Jan 2012 00:00:00"));
+ assertThat(DateFormattersHolder.getMessageFormatterInstance().format(date.toInstant()), equalTo("2012-01-01 00:00:00"));
+ assertThat(DateFormattersHolder.getRssFormatterInstance().format(date.toInstant()), equalTo("Sun, 1 Jan 2012 00:00:00"));
}
}
diff --git a/juick-core/src/test/java/com/juick/test/util/MockUtils.java b/juick-core/src/test/java/com/juick/test/util/MockUtils.java
index 8426cde8..017af4d1 100644
--- a/juick-core/src/test/java/com/juick/test/util/MockUtils.java
+++ b/juick-core/src/test/java/com/juick/test/util/MockUtils.java
@@ -21,7 +21,7 @@ import com.juick.Message;
import com.juick.User;
import org.apache.commons.text.RandomStringGenerator;
-import java.util.Date;
+import java.time.Instant;
/**
* Created by vitalyster on 12.01.2017.
@@ -34,7 +34,7 @@ public class MockUtils {
msg.setMid(mid);
msg.setUser(user);
msg.setText(messageText == null ? generator.generate(24) : messageText);
- msg.setDate(new Date());
+ msg.setTimestamp(Instant.now());
return msg;
}