You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/03/30 01:21:53 UTC
[3/3] james-project git commit: JAMES-1981 Don't fire event when no
uid on expunge or flags update
JAMES-1981 Don't fire event when no uid on expunge or flags update
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/699e9ffd
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/699e9ffd
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/699e9ffd
Branch: refs/heads/master
Commit: 699e9ffd921db84575b0fdedcf5fdb5dee06a8fd
Parents: ec191b4
Author: Antoine Duprat <ad...@linagora.com>
Authored: Wed Mar 29 14:23:36 2017 +0200
Committer: benwa <bt...@linagora.com>
Committed: Thu Mar 30 08:21:04 2017 +0700
----------------------------------------------------------------------
.../store/event/MailboxEventDispatcher.java | 8 +++++--
.../store/MailboxEventDispatcherTest.java | 22 ++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/699e9ffd/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index e6fb0d5..0d64ed9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -89,7 +89,9 @@ public class MailboxEventDispatcher {
* @param mailbox The mailbox
*/
public void expunged(MailboxSession session, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) {
- listener.event(eventFactory.expunged(session, uids, mailbox));
+ if (!uids.isEmpty()) {
+ listener.event(eventFactory.expunged(session, uids, mailbox));
+ }
}
public void expunged(MailboxSession session, MessageMetaData messageMetaData, Mailbox mailbox) {
@@ -104,7 +106,9 @@ public class MailboxEventDispatcher {
* registered MailboxListener will get triggered then
*/
public void flagsUpdated(MailboxSession session, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) {
- listener.event(eventFactory.flagsUpdated(session, uids, mailbox, uflags));
+ if (!uids.isEmpty()) {
+ listener.event(eventFactory.flagsUpdated(session, uids, mailbox, uflags));
+ }
}
public void flagsUpdated(MailboxSession session, MessageUid uid, Mailbox mailbox, UpdatedFlags uflags) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/699e9ffd/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
index 179d2f6..52d99be 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import javax.mail.Flags;
+import javax.mail.Flags.Flag;
import org.apache.james.mailbox.FlagsBuilder;
import org.apache.james.mailbox.MailboxListener;
@@ -32,6 +33,7 @@ import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.MessageResult;
import org.apache.james.mailbox.model.TestId;
import org.apache.james.mailbox.model.UpdatedFlags;
@@ -44,6 +46,7 @@ import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
public class MailboxEventDispatcherTest {
private static final int sessionId = 10;
@@ -365,4 +368,23 @@ public class MailboxEventDispatcherTest {
assertThat(event.getUpdatedFlags().get(0).systemFlagIterator())
.containsOnly(Flags.Flag.SEEN, Flags.Flag.RECENT, Flags.Flag.ANSWERED);
}
+
+ @Test
+ public void expungedShouldNotFireEventWhenEmptyMap() {
+ dispatcher.expunged(session, ImmutableMap.<MessageUid, MessageMetaData> of(), mailbox);
+ assertThat(collector.getEvents()).isEmpty();
+ }
+
+ @Test
+ public void flagsUpdatedShouldNotFireEventWhenEmptyIdList() {
+ UpdatedFlags updatedFlags = UpdatedFlags.builder()
+ .uid(MessageUid.of(1))
+ .modSeq(2)
+ .oldFlags(new Flags(Flag.RECENT))
+ .newFlags(new Flags(Flag.ANSWERED))
+ .build();
+
+ dispatcher.flagsUpdated(session, ImmutableList.<MessageUid> of(), mailbox, ImmutableList.of(updatedFlags));
+ assertThat(collector.getEvents()).isEmpty();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org