JAMES-1894 Correct getMessageList integration test

The number of days since 1970 was considered as number of ms. ElasticSearch can 
not index MS, failing the sort...


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/98d84096
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/98d84096
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/98d84096

Branch: refs/heads/master
Commit: 98d84096982933aecaac58752e7781c23470ce80
Parents: b52f3da
Author: Benoit Tellier <[email protected]>
Authored: Fri Dec 23 11:47:10 2016 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Mon Jan 9 21:58:31 2017 +0700

----------------------------------------------------------------------
 .../integration/GetMessageListMethodTest.java   | 44 +++++++++++---------
 1 file changed, 25 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/98d84096/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index 3cb3184..b3ac263 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -31,6 +31,7 @@ import static org.hamcrest.Matchers.hasSize;
 
 import java.io.ByteArrayInputStream;
 import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.Date;
 import java.util.List;
 
@@ -56,6 +57,7 @@ import com.jayway.restassured.http.ContentType;
 public abstract class GetMessageListMethodTest {
     private static final String NAME = "[0][0]";
     private static final String ARGUMENTS = "[0][1]";
+    private static final ZoneId ZONE_ID = ZoneId.of("Europe/Paris");
 
     protected abstract JmapJamesServer createJmapServer();
 
@@ -387,9 +389,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -409,9 +411,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -431,9 +433,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -477,9 +479,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -499,9 +501,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -545,9 +547,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -567,9 +569,9 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -589,13 +591,13 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message1 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         ComposedMessageId message2 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         ComposedMessageId message3 = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test3\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test3\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test4\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
+                new ByteArrayInputStream("Subject: 
test4\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags());
         await();
 
         given()
@@ -615,7 +617,7 @@ public abstract class GetMessageListMethodTest {
 
         LocalDate date = LocalDate.now();
         ComposedMessageId message = 
jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
-                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
+                new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new 
Flags());
         await();
 
         given()
@@ -632,4 +634,8 @@ public abstract class GetMessageListMethodTest {
             .body("[1][1].list", hasSize(1))
             .body("[1][1].list[0].id", 
equalTo(message.getMessageId().serialize()));
     }
+
+    private Date convertToDate(LocalDate localDate) {
+        return Date.from(localDate.atStartOfDay(ZONE_ID).toInstant());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to