Author: matthieu
Date: Tue Jan 19 13:53:07 2016
New Revision: 1725521

URL: http://svn.apache.org/viewvc?rev=1725521&view=rev
Log:
JAMES-1659 Change default seperator to handle hyphens in username and 
mailboxpath

Added:
    
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
Modified:
    
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
    
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
    
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
    
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
    
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java

Modified: 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java?rev=1725521&r1=1725520&r2=1725521&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
 Tue Jan 19 13:53:07 2016
@@ -122,7 +122,7 @@ public abstract class GetMessageListMeth
             .asString();
         
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2");
+            .containsOnly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2");
     }
 
     @Ignore("ISSUE-53")
@@ -184,7 +184,7 @@ public abstract class GetMessageListMeth
             .asString();
         
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1");
+            .containsOnly("usern...@domain.tld|mailbox|1");
     }
 
     @Test
@@ -219,7 +219,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1");
+            .containsOnly("usern...@domain.tld|mailbox|1");
     }
 
     @Test
@@ -272,7 +272,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2");
+            .containsExactly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2");
     }
 
     @Test
@@ -300,7 +300,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("usern...@domain.tld-mailbox-2", 
"usern...@domain.tld-mailbox-1");
+            .containsExactly("usern...@domain.tld|mailbox|2", 
"usern...@domain.tld|mailbox|1");
     }
 
     @Test
@@ -328,7 +328,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2");
+            .containsExactly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2");
     }
 
     @Test
@@ -356,7 +356,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2");
+            .containsOnly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2");
     }
 
     @Test
@@ -384,7 +384,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-2");
+            .containsOnly("usern...@domain.tld|mailbox|2");
     }
 
     @Test
@@ -412,7 +412,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2");
+            .containsOnly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2");
     }
 
     @Test
@@ -440,7 +440,7 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1");
+            .containsOnly("usern...@domain.tld|mailbox|1");
     }
 
     @Test
@@ -472,6 +472,6 @@ public abstract class GetMessageListMeth
             .asString();
 
         
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("usern...@domain.tld-mailbox-1", 
"usern...@domain.tld-mailbox-2", "usern...@domain.tld-mailbox-3");
+            .containsOnly("usern...@domain.tld|mailbox|1", 
"usern...@domain.tld|mailbox|2", "usern...@domain.tld|mailbox|3");
     }
 }

Modified: 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java?rev=1725521&r1=1725520&r2=1725521&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
 Tue Jan 19 13:53:07 2016
@@ -161,7 +161,7 @@ public abstract class GetMessagesMethodT
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username-inbox-12\"]}, 
\"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|12\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -171,7 +171,7 @@ public abstract class GetMessagesMethodT
             .asString();
         
         
assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].notFound")).containsExactly("username-inbox-12");
+        
assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].notFound")).containsExactly("username|inbox|12");
     }
     
     @Test
@@ -186,7 +186,7 @@ public abstract class GetMessagesMethodT
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username-inbox-1\"]}, 
\"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -200,7 +200,7 @@ public abstract class GetMessagesMethodT
 
         
assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
         assertThat(JsonPath.parse(response).<Integer>read(firstResponsePath + 
".list.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld-inbox-1");
+        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld|inbox|1");
         assertThat(JsonPath.parse(response).<String>read(firstMessagePath + 
".subject")).isEqualTo("my test subject");
         assertThat(JsonPath.parse(response).<String>read(firstMessagePath + 
".textBody")).isEqualTo("testmail");
         assertThat(JsonPath.parse(response).<Boolean>read(firstMessagePath + 
".isUnread")).isTrue();
@@ -221,7 +221,7 @@ public abstract class GetMessagesMethodT
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username-inbox-1\"], 
\"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"], 
\"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -235,7 +235,7 @@ public abstract class GetMessagesMethodT
 
         
assertThat(jsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
         assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + 
".list.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld-inbox-1");
+        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld|inbox|1");
         assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".subject")).isEqualTo("my test subject");
         assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".textBody")).isNull();
         assertThat(jsonPath.parse(response).<Boolean>read(firstMessagePath + 
".isUnread")).isNull();
@@ -261,7 +261,7 @@ public abstract class GetMessagesMethodT
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username-inbox-1\"], 
\"properties\": [\"headers.from\", \"headers.heADER2\"]}, \"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"], 
\"properties\": [\"headers.from\", \"headers.heADER2\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -275,7 +275,7 @@ public abstract class GetMessagesMethodT
 
         
assertThat(jsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
         assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + 
".list.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld-inbox-1");
+        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".id")).isEqualTo("usern...@domain.tld|inbox|1");
         assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".subject")).isNull();
         assertThat(jsonPath.parse(response).<String>read(firstMessagePath + 
".textBody")).isNull();
         assertThat(jsonPath.parse(response).<Boolean>read(firstMessagePath + 
".isUnread")).isNull();

Modified: 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java?rev=1725521&r1=1725520&r2=1725521&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
 Tue Jan 19 13:53:07 2016
@@ -27,12 +27,13 @@ import org.javatuples.Triplet;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonValue;
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Joiner;
 import com.google.common.base.Splitter;
 
 public class MessageId {
 
-    private static final String SEPARATOR = "-";
+    private static final String SEPARATOR = "|";
 
     @JsonCreator
     public static MessageId of(String id) {
@@ -50,7 +51,8 @@ public class MessageId {
         this.uid = uid;
     }
     
-    private MessageId(String username, String mailboxPath, long uid) {
+    @VisibleForTesting
+    MessageId(String username, String mailboxPath, long uid) {
         this.username = username;
         this.mailboxPath = mailboxPath;
         this.uid = uid;

Modified: 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java?rev=1725521&r1=1725520&r2=1725521&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
 Tue Jan 19 13:53:07 2016
@@ -29,7 +29,7 @@ public class GetMessagesRequestTest {
 
     @Test
     public void shouldAllowOptionalAccountId() {
-        GetMessagesRequest result = 
GetMessagesRequest.builder().ids(MessageId.of("user-inbox-1")).properties(MessageProperty.id).build();
+        GetMessagesRequest result = 
GetMessagesRequest.builder().ids(MessageId.of("user|inbox|1")).properties(MessageProperty.id).build();
         assertThat(result).isNotNull();
         assertThat(result.getAccountId()).isEmpty();
     }

Modified: 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java?rev=1725521&r1=1725520&r2=1725521&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MailboxMessageTest.java
 Tue Jan 19 13:53:07 2016
@@ -54,76 +54,76 @@ public class MailboxMessageTest {
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenBlobIdIsNull() {
-        Message.builder().id(MessageId.of("user-box-1")).build();
+        Message.builder().id(MessageId.of("user|box|1")).build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenBlobIdIsEmpty() {
-        Message.builder().id(MessageId.of("user-box-1")).blobId("").build();
+        Message.builder().id(MessageId.of("user|box|1")).blobId("").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenThreadIdIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").build();
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenThreadIdIsEmpty() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("").build();
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenMailboxIdsIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").build();
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenHeadersIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).build();
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenSubjectIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of()).build();
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of()).build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenSubjectIsEmpty() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
             .subject("").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenSizeIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
             .subject("subject").build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenDateIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
             .subject("subject").size(123).build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenPreviewIsNull() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
             .subject("subject").size(123).date(ZonedDateTime.now()).build();
     }
 
     @Test(expected=IllegalStateException.class)
     public void buildShouldThrowWhenPreviewIsEmpty() {
-        
Message.builder().id(MessageId.of("user-box-1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
+        
Message.builder().id(MessageId.of("user|box|1")).blobId("blobId").threadId("threadId").mailboxIds(ImmutableList.of()).headers(ImmutableMap.of())
             
.subject("subject").size(123).date(ZonedDateTime.now()).preview("").build();
     }
 
     @Test
     public void buildShouldWorkWhenMandatoryFieldsArePresent() {
         ZonedDateTime currentDate = ZonedDateTime.now();
-        Message expected = new Message(MessageId.of("user-box-1"), "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", 
"threadId", ImmutableList.of("mailboxId"), 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"))
+                .id(MessageId.of("user|box|1"))
                 .blobId("blobId")
                 .threadId("threadId")
                 .mailboxIds(ImmutableList.of("mailboxId"))
@@ -147,7 +147,7 @@ public class MailboxMessageTest {
                 .build();
         ImmutableMap<String, SubMessage> attachedMessages = 
ImmutableMap.of("differentBlobId", simpleMessage);
         Message.builder()
-            .id(MessageId.of("user-box-1"))
+            .id(MessageId.of("user|box|1"))
             .blobId("blobId")
             .threadId("threadId")
             .mailboxIds(ImmutableList.of("mailboxId"))
@@ -178,7 +178,7 @@ public class MailboxMessageTest {
                 .build();
         ImmutableMap<String, SubMessage> attachedMessages = 
ImmutableMap.of("blobId", simpleMessage);
         Message expected = new Message(
-                MessageId.of("user-box-1"),
+                MessageId.of("user|box|1"),
                 "blobId",
                 "threadId",
                 ImmutableList.of("mailboxId"),
@@ -203,7 +203,7 @@ public class MailboxMessageTest {
                 attachments,
                 attachedMessages);
         Message tested = Message.builder()
-            .id(MessageId.of("user-box-1"))
+            .id(MessageId.of("user|box|1"))
             .blobId("blobId")
             .threadId("threadId")
             .mailboxIds(ImmutableList.of("mailboxId"))
@@ -243,9 +243,9 @@ public class MailboxMessageTest {
                 MAILBOX_ID);
         testMail.setModSeq(MOD_SEQ);
         
-        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user-box-" + x));
+        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user|box|" + x));
         Message expected = Message.builder()
-                .id(MessageId.of("user-box-0"))
+                .id(MessageId.of("user|box|0"))
                 .blobId("0")
                 .threadId("0")
                 .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
@@ -274,9 +274,9 @@ public class MailboxMessageTest {
                 MAILBOX_ID);
         testMail.setModSeq(MOD_SEQ);
         
-        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user-box-" + x));
+        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user|box|" + x));
         Message expected = Message.builder()
-                .id(MessageId.of("user-box-0"))
+                .id(MessageId.of("user|box|0"))
                 .blobId("0")
                 .threadId("0")
                 .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
@@ -329,9 +329,9 @@ public class MailboxMessageTest {
                 .put("in-reply-to", 
"<snt124-w2664003139c1e520cf4f6787...@phx.gbl>")
                 .put("other-header", "other header value")
                 .build();
-        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user-box-" + x));
+        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user|box|" + x));
         Message expected = Message.builder()
-                .id(MessageId.of("user-box-0"))
+                .id(MessageId.of("user|box|0"))
                 .blobId("0")
                 .threadId("0")
                 .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
@@ -365,9 +365,9 @@ public class MailboxMessageTest {
                 MAILBOX_ID);
         testMail.setModSeq(MOD_SEQ);
         
-        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user-box-" + x));
+        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user|box|" + x));
         Message expected = Message.builder()
-                .id(MessageId.of("user-box-0"))
+                .id(MessageId.of("user|box|0"))
                 .blobId("0")
                 .threadId("0")
                 .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
@@ -425,9 +425,9 @@ public class MailboxMessageTest {
                 MAILBOX_ID);
         testMail.setModSeq(MOD_SEQ);
         
-        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user-box-" + x));
+        Message testee = Message.fromMailboxMessage(testMail, x -> 
MessageId.of("user|box|" + x));
         Message expected = Message.builder()
-                .id(MessageId.of("user-box-0"))
+                .id(MessageId.of("user|box|0"))
                 .blobId("0")
                 .threadId("0")
                 .mailboxIds(ImmutableList.of(MAILBOX_ID.serialize()))
@@ -453,6 +453,6 @@ public class MailboxMessageTest {
                 MAILBOX_ID);
         testMail.setModSeq(MOD_SEQ);
         
-        Message.fromMailboxMessage(testMail, x -> MessageId.of("user-box-" + 
x));
+        Message.fromMailboxMessage(testMail, x -> MessageId.of("user|box|" + 
x));
     }
 }

Added: 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java?rev=1725521&view=auto
==============================================================================
--- 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
 (added)
+++ 
james/project/trunk/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
 Tue Jan 19 13:53:07 2016
@@ -0,0 +1,86 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.jmap.model;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class MessageIdTest {
+    @Test(expected=NullPointerException.class)
+    public void ofShouldThrowWhenNull() {
+        String messageId = null;
+        MessageId.of(messageId);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void ofShouldThrowWhenEmpty() {
+        String messageId = "";
+        MessageId.of(messageId);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void ofShouldThrowWhenTwoPartsMissing() {
+        String messageId = "username";
+        MessageId.of(messageId);
+    }
+
+    @Test(expected=IllegalArgumentException.class)
+    public void ofShouldThrowWhenOnePartMissing() {
+        String messageId = "username|mailboxpath";
+        MessageId.of(messageId);
+    }
+
+    @Test(expected=NumberFormatException.class)
+    public void ofShouldWorkWhenThirdPartIsNotANumber() {
+        String messageId = "username|mailboxpath|thirdPart";
+        MessageId.of(messageId);
+    }
+
+    @Test
+    public void ofShouldWorkWhenMessageIdIsWellFormated() {
+        String messageId = "username|mailboxpath|321";
+        MessageId expected = new MessageId("username", "mailboxpath", 321);
+        
+        MessageId actual = MessageId.of(messageId);
+        
+        assertThat(actual).isEqualTo(expected);
+    }
+
+    @Test
+    public void ofShouldWorkWhenOnePartContainsAHyphen() {
+        String messageId = "user-name|mailboxpath|321";
+        MessageId expected = new MessageId("user-name", "mailboxpath", 321);
+        
+        MessageId actual = MessageId.of(messageId);
+        
+        assertThat(actual).isEqualTo(expected);
+    }
+
+    @Test
+    public void ofShouldWorkWhenSecondPartContainsAHyphen() {
+        String messageId = "username|mailbox-path|321";
+        MessageId expected = new MessageId("username", "mailbox-path", 321);
+        
+        MessageId actual = MessageId.of(messageId);
+        
+        assertThat(actual).isEqualTo(expected);
+    }
+
+}



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

Reply via email to