james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [05/10] james-project git commit: JAMES-1818 Use more MailboxId instead of String when possible
Date Mon, 05 Sep 2016 12:44:01 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxesRequestTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxesRequestTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxesRequestTest.java
index ca78fd8..52e663f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxesRequestTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxesRequestTest.java
@@ -22,6 +22,7 @@ package org.apache.james.jmap.model;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -50,10 +51,10 @@ public class GetMailboxesRequestTest {
     @Test
     public void idsShouldBePresentWhenListIsNotEmpty() {
         GetMailboxesRequest getMailboxesRequest = GetMailboxesRequest.builder()
-            .ids(ImmutableList.of("123"))
+            .ids(ImmutableList.of(InMemoryId.of(123)))
             .build();
         assertThat(getMailboxesRequest.getIds()).isPresent();
-        assertThat(getMailboxesRequest.getIds().get()).containsExactly("123");
+        assertThat(getMailboxesRequest.getIds().get()).containsExactly(InMemoryId.of(123));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
index 5a22883..d489272 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
@@ -32,10 +32,10 @@ import javax.mail.Flags.Flag;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.jmap.model.MessageFactory.MetaDataWithContent;
 import org.apache.james.jmap.utils.HtmlTextExtractor;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.AttachmentId;
 import org.apache.james.mailbox.model.Cid;
 import org.apache.james.mailbox.model.MessageAttachment;
-import org.apache.james.mailbox.store.TestId;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
 public class MessageFactoryTest {
-    private static final TestId MAILBOX_ID = TestId.of(18L);
+    private static final InMemoryId MAILBOX_ID = InMemoryId.of(18L);
     private static final ZoneId UTC_ZONE_ID = ZoneId.of("Z");
     private static final ZonedDateTime ZONED_DATE = ZonedDateTime.of(2015, 07, 14, 12, 30,
42, 0, UTC_ZONE_ID);
     private static final Date INTERNAL_DATE = Date.from(ZONED_DATE.toInstant());
@@ -145,7 +145,7 @@ public class MessageFactoryTest {
                 .id(MessageId.of("user|box|2"))
                 .blobId(BlobId.of("2"))
                 .threadId("user|box|2")
-                .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
+                .mailboxIds(ImmutableList.of(MAILBOX_ID))
                 .inReplyToMessageId("<SNT124-W2664003139C1E520CF4F6787D30@phx.gbl>")
                 .headers(headersMap)
                 .from(user)

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageTest.java
index 8953bc1..3ae8f28 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.time.ZonedDateTime;
 import java.util.Optional;
 
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -99,13 +100,13 @@ public class MessageTest {
     @Test
     public void buildShouldWorkWhenMandatoryFieldsArePresent() {
         ZonedDateTime currentDate = ZonedDateTime.now();
-        Message expected = new Message(MessageId.of("user|box|1"), BlobId.of("blobId"), "threadId",
ImmutableList.of("mailboxId"), Optional.empty(), false, false, false, false, false, ImmutableMap.of("key",
"value"), Optional.empty(),
+        Message expected = new Message(MessageId.of("user|box|1"), BlobId.of("blobId"), "threadId",
ImmutableList.of(InMemoryId.of(456)), Optional.empty(), false, false, false, false, false,
ImmutableMap.of("key", "value"), Optional.empty(),
                 ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(),
"subject", currentDate, 123, "preview", Optional.empty(), Optional.empty(), ImmutableList.of(),
ImmutableMap.of());
         Message tested = Message.builder()
                 .id(MessageId.of("user|box|1"))
                 .blobId(BlobId.of("blobId"))
                 .threadId("threadId")
-                .mailboxIds(ImmutableList.of("mailboxId"))
+                .mailboxIds(ImmutableList.of(InMemoryId.of(456)))
                 .headers(ImmutableMap.of("key", "value"))
                 .subject("subject")
                 .size(123)
@@ -129,7 +130,7 @@ public class MessageTest {
             .id(MessageId.of("user|box|1"))
             .blobId(BlobId.of("blobId"))
             .threadId("threadId")
-            .mailboxIds(ImmutableList.of("mailboxId"))
+            .mailboxIds(ImmutableList.of(InMemoryId.of(456)))
             .headers(ImmutableMap.of("key", "value"))
             .subject("subject")
             .size(123)
@@ -160,7 +161,7 @@ public class MessageTest {
                 MessageId.of("user|box|1"),
                 BlobId.of("blobId"),
                 "threadId",
-                ImmutableList.of("mailboxId"),
+                ImmutableList.of(InMemoryId.of(456)),
                 Optional.of("inReplyToMessageId"), 
                 true,
                 true,
@@ -185,7 +186,7 @@ public class MessageTest {
             .id(MessageId.of("user|box|1"))
             .blobId(BlobId.of("blobId"))
             .threadId("threadId")
-            .mailboxIds(ImmutableList.of("mailboxId"))
+            .mailboxIds(ImmutableList.of(InMemoryId.of(456)))
             .inReplyToMessageId("inReplyToMessageId")
             .isUnread(true)
             .isFlagged(true)
@@ -215,7 +216,7 @@ public class MessageTest {
             .id(MessageId.of("user|box|1"))
             .blobId(BlobId.of("blobId"))
             .threadId("threadId")
-            .mailboxIds(ImmutableList.of("mailboxId"))
+            .mailboxIds(ImmutableList.of(InMemoryId.of(456)))
             .headers(ImmutableMap.of("key", "value"))
             .subject("subject")
             .size(1)
@@ -235,7 +236,7 @@ public class MessageTest {
             .id(MessageId.of("user|box|1"))
             .blobId(BlobId.of("blobId"))
             .threadId("threadId")
-            .mailboxIds(ImmutableList.of("mailboxId"))
+            .mailboxIds(ImmutableList.of(InMemoryId.of(456)))
             .headers(ImmutableMap.of("key", "value"))
             .subject("subject")
             .size(1)

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesRequestTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesRequestTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesRequestTest.java
index 9a0d984..e2d884f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesRequestTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesRequestTest.java
@@ -24,6 +24,8 @@ import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.jmap.model.mailbox.MailboxCreateRequest;
 import org.apache.james.jmap.model.mailbox.MailboxUpdateRequest;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -45,11 +47,11 @@ public class SetMailboxesRequestTest {
     public void builderShouldWork() throws MailboxException {
         //Given
         MailboxCreationId creationId = MailboxCreationId.of("creationId");
-        String mailboxId = "mailboxId";
+        InMemoryId mailboxId = InMemoryId.of(123);
         MailboxCreateRequest mailboxRequest = MailboxCreateRequest.builder()
             .name("mailboxRequest")
             .build();
-        ImmutableList<String> destroy = ImmutableList.of("destroyId");
+        ImmutableList<MailboxId> destroy = ImmutableList.of(InMemoryId.of(456));
         MailboxUpdateRequest mailboxUpdateRequest = MailboxUpdateRequest.builder()
             .name("mailboxUpdateRequest")
             .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesResponseTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesResponseTest.java
index 959fce6..ec735f3 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesResponseTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMailboxesResponseTest.java
@@ -22,6 +22,8 @@ package org.apache.james.jmap.model;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.jmap.model.mailbox.Mailbox;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -33,14 +35,14 @@ public class SetMailboxesResponseTest {
     public void builderShouldWork() {
         ImmutableMap<MailboxCreationId, Mailbox> created = ImmutableMap.of(MailboxCreationId.of("1"),
             Mailbox.builder()
-                .id("1")
+                .id(InMemoryId.of(1))
                 .name("myBox")
                 .build());
-        ImmutableList<String> updated = ImmutableList.of("2");
-        ImmutableList<String> destroyed = ImmutableList.of("3");
+        ImmutableList<MailboxId> updated = ImmutableList.of(InMemoryId.of(2));
+        ImmutableList<MailboxId> destroyed = ImmutableList.of(InMemoryId.of(3));
         ImmutableMap<MailboxCreationId, SetError> notCreated = ImmutableMap.of(MailboxCreationId.of("dead-beef-defec8"),
SetError.builder().type("created").build());
-        ImmutableMap<String, SetError> notUpdated = ImmutableMap.of("4", SetError.builder().type("updated").build());
-        ImmutableMap<String, SetError> notDestroyed  = ImmutableMap.of("5", SetError.builder().type("destroyed").build());
+        ImmutableMap<MailboxId, SetError> notUpdated = ImmutableMap.of(InMemoryId.of(4),
SetError.builder().type("updated").build());
+        ImmutableMap<MailboxId, SetError> notDestroyed  = ImmutableMap.of(InMemoryId.of(5),
SetError.builder().type("destroyed").build());
         SetMailboxesResponse expected = new SetMailboxesResponse(created, updated, destroyed,
notCreated, notUpdated, notDestroyed);
 
         SetMailboxesResponse setMessagesResponse = SetMailboxesResponse.builder()
@@ -61,9 +63,9 @@ public class SetMailboxesResponseTest {
         SetMailboxesResponse.Builder emptyBuilder = SetMailboxesResponse.builder();
         SetMailboxesResponse testee = SetMailboxesResponse.builder()
                 .created(buildMailbox(MailboxCreationId.of("1")))
-                .destroyed("2")
+                .destroyed(InMemoryId.of(2))
                 .notCreated(ImmutableMap.of(MailboxCreationId.of("dead-beef-defec8"), SetError.builder().type("type").build()))
-                .notDestroyed(ImmutableMap.of("3", SetError.builder().type("type").build()))
+                .notDestroyed(ImmutableMap.of(InMemoryId.of(3), SetError.builder().type("type").build()))
                 .build();
 
         // When
@@ -74,7 +76,7 @@ public class SetMailboxesResponseTest {
 
     private ImmutableMap<MailboxCreationId, Mailbox> buildMailbox(MailboxCreationId
mailboxId) {
         return ImmutableMap.of(mailboxId, Mailbox.builder()
-                .id(mailboxId.getCreationId())
+                .id(InMemoryId.of(Long.valueOf(mailboxId.getCreationId())))
                 .name(mailboxId.getCreationId())
                 .build());
     }
@@ -100,10 +102,10 @@ public class SetMailboxesResponseTest {
     @Test
     public void mergeIntoShouldMergeDestroyedLists() {
         // Given
-        String buildersDestroyedMessageId = "1";
+        InMemoryId buildersDestroyedMessageId = InMemoryId.of(1);
         SetMailboxesResponse.Builder nonEmptyBuilder = SetMailboxesResponse.builder()
                 .destroyed(buildersDestroyedMessageId);
-        String destroyedMessageId = "2";
+        InMemoryId destroyedMessageId = InMemoryId.of(2);
         SetMailboxesResponse testee = SetMailboxesResponse.builder()
                 .destroyed(destroyedMessageId)
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesResponseTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesResponseTest.java
index 24402a9..e79a044 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesResponseTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesResponseTest.java
@@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.time.ZonedDateTime;
 
 import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
@@ -58,7 +59,7 @@ public class SetMessagesResponseTest {
                 .id(MessageId.of("user|created|1"))
                 .blobId(BlobId.of("blobId"))
                 .threadId("threadId")
-                .mailboxIds(ImmutableList.of("mailboxId"))
+                .mailboxIds(ImmutableList.of(InMemoryId.of(123)))
                 .headers(ImmutableMap.of("key", "value"))
                 .subject("subject")
                 .size(123)

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
index 760d890..1ac869f 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.junit.Test;
 
 public class MailboxTest {
@@ -45,36 +46,29 @@ public class MailboxTest {
     }
 
     @Test(expected=IllegalStateException.class)
-    public void buildShouldThrowWhenIdIsEmpty() {
-        Mailbox.builder()
-            .id("")
-            .build();
-    }
-
-    @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenNameIsNull() {
         Mailbox.builder()
-            .id("id")
+            .id(InMemoryId.of(1))
             .build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenNameIsEmpty() {
         Mailbox.builder()
-            .id("id")
+            .id(InMemoryId.of(1))
             .name("")
             .build();
     }
 
     @Test
     public void buildShouldWork() {
-        Mailbox expectedMailbox = new Mailbox("id", "name", Optional.of("parentId"), Optional.of(Role.DRAFTS),
SortOrder.of(123),
+        Mailbox expectedMailbox = new Mailbox(InMemoryId.of(1), "name", Optional.of(InMemoryId.of(0)),
Optional.of(Role.DRAFTS), SortOrder.of(123),
                 true, true, true, true, true, true, true, 456, 789, 741, 852);
 
         Mailbox mailbox = Mailbox.builder()
-            .id("id")
+            .id(InMemoryId.of(1))
             .name("name")
-            .parentId("parentId")
+            .parentId(InMemoryId.of(0))
             .role(Optional.of(Role.DRAFTS))
             .sortOrder(SortOrder.of(123))
             .mustBeOnlyMailbox(true)
@@ -96,7 +90,7 @@ public class MailboxTest {
     @Test
     public void parentIdDefaultValueIsEmpty() {
         Mailbox mailbox = Mailbox.builder()
-            .id("id")
+            .id(InMemoryId.of(0))
             .name("name")
             .build();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxUpdateRequestTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxUpdateRequestTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxUpdateRequestTest.java
index a2ec816..1623dd8 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxUpdateRequestTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxUpdateRequestTest.java
@@ -23,6 +23,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
 import org.junit.Test;
 
 public class MailboxUpdateRequestTest {
@@ -32,7 +34,7 @@ public class MailboxUpdateRequestTest {
         //Given
         MailboxUpdateRequest testee = MailboxUpdateRequest.builder().name("my box").build()
;
         //When
-        Optional<String> actual = testee.getParentId();
+        Optional<MailboxId> actual = testee.getParentId();
         //Then
         assertThat(actual).isEmpty();
     }
@@ -42,7 +44,7 @@ public class MailboxUpdateRequestTest {
         //Given
         MailboxUpdateRequest testee = MailboxUpdateRequest.builder().name("my box").parentId(null).build()
;
         //When
-        Optional<String> actual = testee.getParentId();
+        Optional<MailboxId> actual = testee.getParentId();
         //Then
         assertThat(actual).isNull();
     }
@@ -50,10 +52,10 @@ public class MailboxUpdateRequestTest {
     @Test
     public void getParentIdShouldReturnParentIdWhenParentIdGiven() throws Exception {
         //Given
-        String expected = "A";
+        InMemoryId expected = InMemoryId.of(123);
         MailboxUpdateRequest testee = MailboxUpdateRequest.builder().parentId(expected).name("my
box").build() ;
         //When
-        Optional<String> actual = testee.getParentId();
+        Optional<MailboxId> actual = testee.getParentId();
         //Then
         assertThat(actual).contains(expected);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
index eb97d96..e0a3099 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
@@ -36,7 +36,7 @@ import org.apache.james.jmap.utils.HtmlTextExtractor;
 import org.apache.james.jmap.utils.MailboxBasedHtmlTextExtractor;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.store.TestId;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -70,7 +70,7 @@ public class MailFactoryTest {
                 .internalDate(new Date())
                 .sharedContent(new SharedByteArrayInputStream(content.getBytes(Charsets.UTF_8)))
                 .attachments(ImmutableList.of())
-                .mailboxId(TestId.of(3))
+                .mailboxId(InMemoryId.of(3))
                 .messageId(MessageId.of("test|test|2"))
                 .build();
         HtmlTextExtractor htmlTextExtractor = new MailboxBasedHtmlTextExtractor(new DefaultTextExtractor());

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
index e233e9d..6c76622 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
@@ -26,6 +26,7 @@ import java.util.Optional;
 import org.apache.james.jmap.model.mailbox.Mailbox;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.MailboxId;
@@ -63,8 +64,6 @@ public class MailboxUtilsTest {
 
         Optional<Mailbox> optionalMailbox = sut.mailboxFromMailboxPath(mailboxPath,
mailboxSession);
         assertThat(optionalMailbox).isPresent();
-        Mailbox mailbox = optionalMailbox.get();
-        assertThat(mailbox.getId()).isNotEmpty();
     }
 
     @Test
@@ -111,7 +110,7 @@ public class MailboxUtilsTest {
             .findMailboxByPath(mailboxPath)
             .getMailboxId();
 
-        Optional<String> optionalName = sut.getMailboxNameFromId(mailboxId.serialize(),
mailboxSession);
+        Optional<String> optionalName = sut.getMailboxNameFromId(mailboxId, mailboxSession);
         assertThat(optionalName).isPresent();
         String name = optionalName.get();
         assertThat(name).isEqualTo(expected);
@@ -119,7 +118,7 @@ public class MailboxUtilsTest {
 
     @Test
     public void getMailboxNameFromIdShouldReturnEmptyWhenMailboxDoesntExist() throws Exception
{
-        Optional<String> optionalName = sut.getMailboxNameFromId("unknown", mailboxSession);
+        Optional<String> optionalName = sut.getMailboxNameFromId(InMemoryId.of(987),
mailboxSession);
         assertThat(optionalName).isEmpty();
     }
 
@@ -172,14 +171,14 @@ public class MailboxUtilsTest {
                 .findMailboxByPath(mailboxPath)
                 .getMailboxId();
 
-        Optional<Mailbox> mailbox = sut.mailboxFromMailboxId(mailboxId.serialize(),
mailboxSession);
+        Optional<Mailbox> mailbox = sut.mailboxFromMailboxId(mailboxId, mailboxSession);
         assertThat(mailbox).isPresent();
-        assertThat(mailbox.get().getId()).isEqualTo(mailboxId.serialize());
+        assertThat(mailbox.get().getId()).isEqualTo(mailboxId);
     }
 
     @Test
     public void mailboxFromMailboxIdShouldReturnAbsentWhenDoesntExist() throws Exception
{
-        Optional<Mailbox> mailbox = sut.mailboxFromMailboxId("123", mailboxSession);
+        Optional<Mailbox> mailbox = sut.mailboxFromMailboxId(InMemoryId.of(123), mailboxSession);
         assertThat(mailbox).isEmpty();
     }
 
@@ -191,14 +190,14 @@ public class MailboxUtilsTest {
                 .findMailboxByPath(mailboxPath)
                 .getMailboxId();
 
-        Optional<MailboxPath> actual = sut.mailboxPathFromMailboxId(mailboxId.serialize(),
mailboxSession);
+        Optional<MailboxPath> actual = sut.mailboxPathFromMailboxId(mailboxId, mailboxSession);
         assertThat(actual).isPresent();
         assertThat(actual.get()).isEqualTo(mailboxPath);
     }
 
     @Test
     public void mailboxPathFromMailboxIdShouldReturnAbsentWhenDoesntExist() throws Exception
{
-        Optional<MailboxPath> mailboxPath = sut.mailboxPathFromMailboxId("123", mailboxSession);
+        Optional<MailboxPath> mailboxPath = sut.mailboxPathFromMailboxId(InMemoryId.of(123),
mailboxSession);
         assertThat(mailboxPath).isEmpty();
     }
 
@@ -209,7 +208,7 @@ public class MailboxUtilsTest {
 
     @Test(expected = IllegalStateException.class)
     public void mailboxPathFromMailboxIdShouldThrowWhenNullMailboxSession() throws Exception
{
-        sut.mailboxPathFromMailboxId("A", null);
+        sut.mailboxPathFromMailboxId(InMemoryId.of(123), null);
     }
 
     @Test(expected = IllegalStateException.class)
@@ -217,11 +216,6 @@ public class MailboxUtilsTest {
         sut.mailboxPathFromMailboxId(null, null);
     }
 
-    @Test(expected = IllegalStateException.class)
-    public void mailboxPathFromMailboxIdShouldReturnAbsentWhenEmptyMailboxId() throws Exception
{
-        sut.mailboxPathFromMailboxId("", mailboxSession);
-    }
-
     @Test
     public void getMailboxPathShouldReturnThePathWhenRootMailbox() throws Exception {
         MailboxPath expected = new MailboxPath("#private", user, "myBox");
@@ -231,7 +225,7 @@ public class MailboxUtilsTest {
                 .getMailboxId();
 
         Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId.serialize())
+                .id(mailboxId)
                 .name("myBox")
                 .build();
 
@@ -254,9 +248,9 @@ public class MailboxUtilsTest {
                 .getMailboxId();
 
         Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId.serialize())
+                .id(mailboxId)
                 .name("myBox")
-                .parentId(parentId.serialize())
+                .parentId(parentId)
                 .build();
 
         MailboxPath mailboxPath = sut.getMailboxPath(mailbox, mailboxSession);
@@ -281,9 +275,9 @@ public class MailboxUtilsTest {
                 .getMailboxId();
 
         Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId.serialize())
+                .id(mailboxId)
                 .name("myBox")
-                .parentId(childId.serialize())
+                .parentId(childId)
                 .build();
 
         MailboxPath mailboxPath = sut.getMailboxPath(mailbox, mailboxSession);
@@ -298,7 +292,7 @@ public class MailboxUtilsTest {
                 .findMailboxByPath(mailboxPath)
                 .getMailboxId();
 
-        assertThat(sut.hasChildren(mailboxId.serialize(), mailboxSession)).isFalse();
+        assertThat(sut.hasChildren(mailboxId, mailboxSession)).isFalse();
     }
 
     @Test
@@ -312,6 +306,6 @@ public class MailboxUtilsTest {
         MailboxPath mailboxPath = new MailboxPath("#private", user, "inbox.myBox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
 
-        assertThat(sut.hasChildren(parentId.serialize(), mailboxSession)).isTrue();
+        assertThat(sut.hasChildren(parentId, mailboxSession)).isTrue();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortingHierarchicalCollectionsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortingHierarchicalCollectionsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortingHierarchicalCollectionsTest.java
index 1437f88..732b05c 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortingHierarchicalCollectionsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortingHierarchicalCollectionsTest.java
@@ -26,14 +26,22 @@ import java.util.stream.Collectors;
 
 import org.apache.james.jmap.model.mailbox.Mailbox;
 import org.apache.james.jmap.utils.DependencyGraph.CycleDetectedException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.model.MailboxId;
 import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
 
 public class SortingHierarchicalCollectionsTest {
+    private static final InMemoryId INBOX_ID = InMemoryId.of(0);
+    private static final InMemoryId A_ID = InMemoryId.of(1);
+    private static final InMemoryId B_ID = InMemoryId.of(2);
+    private static final InMemoryId C_ID = InMemoryId.of(3);
+    private static final InMemoryId D_ID = InMemoryId.of(4);
+    private static final InMemoryId E_ID = InMemoryId.of(5);
 
-    private SortingHierarchicalCollections<Mailbox, String> sut;
+    private SortingHierarchicalCollections<Mailbox, MailboxId> sut;
 
     @Before
     public void setup() {
@@ -43,12 +51,12 @@ public class SortingHierarchicalCollectionsTest {
     @Test
     public void sortFromRootToLeafShouldReturnOrderedMailbox() {
         // Given
-        Mailbox inbox = Mailbox.builder().name("INBOX").id("INBOX").build();
-        Mailbox a = Mailbox.builder().name("A").id("A").parentId("INBOX").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").parentId("INBOX").build();
-        Mailbox c = Mailbox.builder().name("C").id("C").parentId("B").build();
-        Mailbox d = Mailbox.builder().name("D").id("D").parentId("A").build();
-        Mailbox e = Mailbox.builder().name("E").id("E").parentId("C").build();
+        Mailbox inbox = Mailbox.builder().name("INBOX").id(INBOX_ID).build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).parentId(INBOX_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).parentId(INBOX_ID).build();
+        Mailbox c = Mailbox.builder().name("C").id(C_ID).parentId(B_ID).build();
+        Mailbox d = Mailbox.builder().name("D").id(D_ID).parentId(A_ID).build();
+        Mailbox e = Mailbox.builder().name("E").id(E_ID).parentId(C_ID).build();
         ImmutableList<Mailbox> input = ImmutableList.of(b, c, d, a, inbox, e);
 
         // When
@@ -67,9 +75,9 @@ public class SortingHierarchicalCollectionsTest {
 
     @Test
     public void sortFromRootToLeafOrphanMailboxesShouldReturnInput() {
-        Mailbox a = Mailbox.builder().name("A").id("A").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").build();
-        Mailbox c = Mailbox.builder().name("C").id("C").build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).build();
+        Mailbox c = Mailbox.builder().name("C").id(C_ID).build();
 
         ImmutableList<Mailbox> input = ImmutableList.of(a, b, c);
         List<String> result = sut.sortFromRootToLeaf(input).stream()
@@ -81,8 +89,8 @@ public class SortingHierarchicalCollectionsTest {
 
     @Test(expected=CycleDetectedException.class)
     public void sortFromRootToLeafWithLoopShouldThrow() {
-        Mailbox a = Mailbox.builder().name("A").id("A").parentId("B").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").parentId("A").build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).parentId(B_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).parentId(A_ID).build();
 
         ImmutableList<Mailbox> input = ImmutableList.of(a, b);
 
@@ -92,12 +100,12 @@ public class SortingHierarchicalCollectionsTest {
     @Test
     public void sortFromLeafToRootShouldReturnOrderedMailbox() {
         //Given
-        Mailbox inbox = Mailbox.builder().name("INBOX").id("INBOX").build();
-        Mailbox a = Mailbox.builder().name("A").id("A").parentId("INBOX").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").parentId("INBOX").build();
-        Mailbox c = Mailbox.builder().name("C").id("C").parentId("B").build();
-        Mailbox d = Mailbox.builder().name("D").id("D").parentId("A").build();
-        Mailbox e = Mailbox.builder().name("E").id("E").parentId("C").build();
+        Mailbox inbox = Mailbox.builder().name("INBOX").id(INBOX_ID).build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).parentId(INBOX_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).parentId(INBOX_ID).build();
+        Mailbox c = Mailbox.builder().name("C").id(C_ID).parentId(B_ID).build();
+        Mailbox d = Mailbox.builder().name("D").id(D_ID).parentId(A_ID).build();
+        Mailbox e = Mailbox.builder().name("E").id(E_ID).parentId(C_ID).build();
 
         ImmutableList<Mailbox> input = ImmutableList.of(b, c, d, a, inbox, e);
 
@@ -116,9 +124,9 @@ public class SortingHierarchicalCollectionsTest {
 
     @Test
     public void sortFromLeafToRootOrphanMailboxesShouldReturnInput() {
-        Mailbox a = Mailbox.builder().name("A").id("A").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").build();
-        Mailbox c = Mailbox.builder().name("C").id("C").build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).build();
+        Mailbox c = Mailbox.builder().name("C").id(C_ID).build();
 
         ImmutableList<Mailbox> input = ImmutableList.of(a, b, c);
         List<String> result = sut.sortFromLeafToRoot(input).stream()
@@ -130,8 +138,8 @@ public class SortingHierarchicalCollectionsTest {
 
     @Test(expected=CycleDetectedException.class)
     public void sortFromLeafToRootWithLoopShouldThrow() {
-        Mailbox a = Mailbox.builder().name("A").id("A").parentId("B").build();
-        Mailbox b = Mailbox.builder().name("B").id("B").parentId("A").build();
+        Mailbox a = Mailbox.builder().name("A").id(A_ID).parentId(B_ID).build();
+        Mailbox b = Mailbox.builder().name("B").id(B_ID).parentId(A_ID).build();
 
         ImmutableList<Mailbox> input = ImmutableList.of(a, b);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8ec9ab93/server/protocols/jmap/src/test/resources/json/message.json
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/resources/json/message.json b/server/protocols/jmap/src/test/resources/json/message.json
index 72d37bd..e246358 100644
--- a/server/protocols/jmap/src/test/resources/json/message.json
+++ b/server/protocols/jmap/src/test/resources/json/message.json
@@ -2,7 +2,7 @@
     "id": "username|mailbox|1",
     "blobId": "myBlobId",
     "threadId": "myThreadId",
-    "mailboxIds": ["mailboxId1", "mailboxId2"],
+    "mailboxIds": ["1", "2"],
     "inReplyToMessageId": "myInReplyToMessageId",
     "isUnread": true,
     "isFlagged": true,


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message