james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1688116 - in /james/mailbox/trunk/store/src: main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java
Date Mon, 29 Jun 2015 08:25:30 GMT
Author: btellier
Date: Mon Jun 29 08:25:29 2015
New Revision: 1688116

URL: http://svn.apache.org/r1688116
Log:
MAILBOX-234 Add user flags support in SimpleMessage

Modified:
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java?rev=1688116&r1=1688115&r2=1688116&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
Mon Jun 29 08:25:29 2015
@@ -48,6 +48,7 @@ public class SimpleMessage<Id extends Ma
     private boolean flagged;
     private boolean recent;
     private boolean seen;
+    private String[] userFlags;
     private Date internalDate;
     private final String subType;
     private List<Property> properties;
@@ -71,6 +72,7 @@ public class SimpleMessage<Id extends Ma
         this.properties = propertyBuilder.toProperties();
         this.mediaType = propertyBuilder.getMediaType();
         this.subType = propertyBuilder.getSubType();
+        this.userFlags = flags.getUserFlags();
     }
 
     public SimpleMessage(Mailbox<Id> mailbox, Message<Id> original)
@@ -100,6 +102,11 @@ public class SimpleMessage<Id extends Ma
         }
     }
 
+    @Override
+    protected String[] createUserFlags() {
+        return userFlags.clone();
+    }
+
     public Date getInternalDate() {
         return internalDate;
     }
@@ -143,6 +150,7 @@ public class SimpleMessage<Id extends Ma
         flagged = flags.contains(Flags.Flag.FLAGGED);
         recent = flags.contains(Flags.Flag.RECENT);
         seen = flags.contains(Flags.Flag.SEEN);
+        userFlags = flags.getUserFlags();
     }
 
     public InputStream getBodyContent() throws IOException {

Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java?rev=1688116&r1=1688115&r2=1688116&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java
(original)
+++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java
Mon Jun 29 08:25:29 2015
@@ -20,6 +20,7 @@ package org.apache.james.mailbox.store.m
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -31,14 +32,22 @@ import javax.mail.util.SharedByteArrayIn
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.store.TestId;
+import org.apache.james.mailbox.FlagsBuilder;
+import org.junit.Before;
 import org.junit.Test;
 
 public class SimpleMessageTest {
     private static final Charset MESSAGE_CHARSET = Charset.forName("UTF-8");
     private static final String MESSAGE_CONTENT = "Simple message content without special
characters";
     private static final String MESSAGE_CONTENT_SPECIAL_CHAR = "Simple message content with
special characters: \"'(§è!çà$*`";
-    private static final SimpleMessage<TestId> MESSAGE = buildMessage(MESSAGE_CONTENT);
-    private static final SimpleMessage<TestId> MESSAGE_SPECIAL_CHAR = buildMessage(MESSAGE_CONTENT_SPECIAL_CHAR);
+    private SimpleMessage<TestId> MESSAGE;
+    private SimpleMessage<TestId> MESSAGE_SPECIAL_CHAR;
+
+    @Before
+    public void setUp() {
+        MESSAGE = buildMessage(MESSAGE_CONTENT);
+        MESSAGE_SPECIAL_CHAR = buildMessage(MESSAGE_CONTENT_SPECIAL_CHAR);
+    }
 
     @Test
     public void testSize() {
@@ -75,8 +84,14 @@ public class SimpleMessageTest {
                 new String(IOUtils.toByteArray(MESSAGE_SPECIAL_CHAR.getFullContent()),MESSAGE_CHARSET));
     }
 
-    private static SimpleMessage<TestId> buildMessage(String content) {
-        return new SimpleMessage<TestId>(Calendar.getInstance().getTime(),
+    @Test
+    public void simpleMessageShouldReturnTheSameUserFlagsThatThoseProvided() {
+        MESSAGE.setFlags(new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.SEEN).add("mozzarela",
"parmesan", "coppa", "limonchello").build());
+        assertThat(MESSAGE.createUserFlags()).containsOnly("mozzarela", "parmesan", "coppa",
"limonchello");
+    }
+
+        private static SimpleMessage<TestId> buildMessage(String content) {
+            return new SimpleMessage<TestId>(Calendar.getInstance().getTime(),
                 content.length(), 0, new SharedByteArrayInputStream(
                         content.getBytes(MESSAGE_CHARSET)), new Flags(),
                 new PropertyBuilder(), TestId.of(1L));



---------------------------------------------------------------------
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