james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/3] james-project git commit: PROTOCOLS-117 FlagsFactory should trim empty and null user flags
Date Tue, 07 Nov 2017 03:17:33 GMT
Repository: james-project
Updated Branches:
  refs/heads/master f1d6f12f6 -> b353752b2


PROTOCOLS-117 FlagsFactory should trim empty and null user flags


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

Branch: refs/heads/master
Commit: 0b27e88688324a46cd01c62e5465ba7e279ca64b
Parents: f1d6f12
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Mon Nov 6 15:12:19 2017 +0100
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Mon Nov 6 15:12:19 2017 +0100

----------------------------------------------------------------------
 .../james/mailbox/store/mail/model/FlagsFactory.java |  2 ++
 .../mailbox/store/mail/model/FlagsFactoryTest.java   | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0b27e886/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/FlagsFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/FlagsFactory.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/FlagsFactory.java
index eb3c9e4..3f506cd 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/FlagsFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/FlagsFactory.java
@@ -25,6 +25,7 @@ import java.util.stream.Stream;
 
 import javax.mail.Flags;
 
+import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 
 public class FlagsFactory {
@@ -114,6 +115,7 @@ public class FlagsFactory {
                         toUserFlagStream(flagsOrEmpty),
                         userFlags.stream())
                     .distinct()
+                    .filter(s -> !Strings.isNullOrEmpty(s))
                     .filter(flagsFilter.getUserFlagFilter());
 
             final Flags result = new Flags();

http://git-wip-us.apache.org/repos/asf/james-project/blob/0b27e886/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
index 9f080cd..5f32579 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/FlagsFactoryTest.java
@@ -123,4 +123,19 @@ public class FlagsFactoryTest {
         assertThat(actual.getUserFlags()).containsOnly("soCool");
     }
 
+    @Test
+    public void builderShouldTrimEmptyUserFlags() {
+        Flags flags = new Flags();
+        flags.add("");
+        flags.add("value2");
+        Flags actual = FlagsFactory.builder().flags(flags).addUserFlags("", "value").build();
+        assertThat(actual.getUserFlags()).containsOnly("value", "value2");
+    }
+
+    @Test
+    public void builderShouldTrimNullUserFlags() {
+        Flags actual = FlagsFactory.builder().addUserFlags(null, "value").build();
+        assertThat(actual.getUserFlags()).containsOnly("value");
+    }
+
 }
\ No newline at end of file


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