james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [3/8] james-project git commit: MAILBOX-285 Allow duplicates in mailboxId argument of CassandraMessageIdMapper
Date Wed, 18 Jan 2017 07:51:57 GMT
MAILBOX-285 Allow duplicates in mailboxId argument of CassandraMessageIdMapper


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

Branch: refs/heads/master
Commit: 040c1b52f87216a117f315ffcdc62f73f516f31c
Parents: 0944974
Author: Benoit Tellier <btellier@linagora.com>
Authored: Wed Jan 11 14:28:55 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Jan 17 10:44:40 2017 +0700

----------------------------------------------------------------------
 .../mail/CassandraMessageIdMapper.java          |  1 +
 .../store/mail/model/MessageIdMapperTest.java   | 23 ++++++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/040c1b52/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
index ea4c27d..b3a2e07 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
@@ -211,6 +211,7 @@ public class CassandraMessageIdMapper implements MessageIdMapper {
         CassandraMessageId cassandraMessageId = (CassandraMessageId) messageId;
 
         return mailboxIds.stream()
+            .distinct()
             .map(mailboxId -> (CassandraId) mailboxId)
             .flatMap(mailboxId -> imapUidDAO.retrieve(cassandraMessageId, Optional.of(mailboxId)).join())
             .map(composedMessageId -> flagsUpdateWithRetry(newState, updateMode, composedMessageId))

http://git-wip-us.apache.org/repos/asf/james-project/blob/040c1b52/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
index 55db651..09d3960 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java
@@ -572,6 +572,29 @@ public class MessageIdMapperTest<T extends MapperProvider> {
     }
 
     @ContractTest
+    public void setFlagsShouldWorkWhenCalledOnDuplicatedMailbox() throws Exception {
+        message1.setUid(mapperProvider.generateMessageUid());
+        message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
+        sut.save(message1);
+        message2.setUid(mapperProvider.generateMessageUid());
+        message2.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
+        sut.save(message2);
+        message3.setUid(mapperProvider.generateMessageUid());
+        message3.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
+        sut.save(message3);
+        message4.setUid(mapperProvider.generateMessageUid());
+        message4.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));
+        sut.save(message4);
+
+        MessageId messageId = message1.getMessageId();
+        sut.setFlags(messageId, ImmutableList.of(message1.getMailboxId(), message1.getMailboxId()),
new Flags(Flag.ANSWERED), FlagsUpdateMode.ADD);
+
+        List<MailboxMessage> messages = sut.find(ImmutableList.of(messageId), MessageMapper.FetchType.Body);
+        assertThat(messages).hasSize(1);
+        assertThat(messages.get(0).isAnswered()).isTrue();
+    }
+
+    @ContractTest
     public void countMessageShouldReturnWhenCreateNewMessage() throws Exception {
         message1.setUid(mapperProvider.generateMessageUid());
         message1.setModSeq(mapperProvider.generateModSeq(benwaInboxMailbox));


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