james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/12] james-project git commit: JAMES-2161 Remove a bit of logic duplication in Keywords.Factory
Date Tue, 27 Nov 2018 02:06:30 GMT
JAMES-2161 Remove a bit of logic duplication in Keywords.Factory


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

Branch: refs/heads/master
Commit: 017f3570338213577aeb75cf7dee9bf176f909c8
Parents: 2a65542
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Nov 23 10:54:23 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Tue Nov 27 09:01:54 2018 +0700

----------------------------------------------------------------------
 .../integration/cucumber/SetMessagesMethodStepdefs.java  |  2 +-
 .../main/java/org/apache/james/jmap/model/Keywords.java  | 11 +++--------
 .../java/org/apache/james/jmap/model/KeywordsTest.java   |  4 ++--
 3 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/017f3570/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
index 831c99f..5902d39 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java
@@ -292,7 +292,7 @@ public class SetMessagesMethodStepdefs {
 
     @When("^message \"([^\"]*)\" has flags (.*) in mailbox \"([^\"]*)\" of user \"([^\"]*)\"$")
     public void setMessageFlagsInSpecifiedMailbox(String message, List<String> flags,
String mailbox, String mailboxOwner) throws Exception {
-        Flags newFlags = Keywords.lenientFactory().fromList(flags).asFlags();
+        Flags newFlags = Keywords.lenientFactory().fromCollection(flags).asFlags();
         String username = userStepdefs.getConnectedUser();
         MessageId messageId = messageIdStepdefs.getMessageId(message);
         MailboxId mailboxId = mainStepdefs.getMailboxId(mailboxOwner, mailbox);

http://git-wip-us.apache.org/repos/asf/james-project/blob/017f3570/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keywords.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keywords.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keywords.java
index 4a3b6a4..c77b602 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keywords.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keywords.java
@@ -20,7 +20,7 @@
 package org.apache.james.jmap.model;
 
 import java.util.Arrays;
-import java.util.List;
+import java.util.Collection;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -114,7 +114,7 @@ public class Keywords {
                     .collect(Guavate.toImmutableSet()));
         }
 
-        public Keywords fromList(List<String> keywords) {
+        public Keywords fromCollection(Collection<String> keywords) {
             return fromSet(keywords.stream()
                     .flatMap(toKeyword::asKeywordStream)
                     .collect(Guavate.toImmutableSet()));
@@ -126,12 +126,7 @@ public class Keywords {
                 .stream()
                 .allMatch(keywordValue -> keywordValue), "Keyword must be true");
 
-            Set<Keyword> setKeywords = mapKeywords.keySet()
-                .stream()
-                .flatMap(toKeyword::asKeywordStream)
-                .collect(Guavate.toImmutableSet());
-
-            return fromSet(setKeywords);
+            return fromCollection(mapKeywords.keySet());
         }
 
         public Keywords fromFlags(Flags flags) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/017f3570/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordsTest.java
index b8940a8..b3c2493 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordsTest.java
@@ -180,7 +180,7 @@ public class KeywordsTest {
     @Test
     public void fromListShouldReturnKeywordsFromListOfStrings() {
         Keywords keywords = Keywords.lenientFactory()
-            .fromList(ImmutableList.of("$Answered", "$Flagged"));
+            .fromCollection(ImmutableList.of("$Answered", "$Flagged"));
 
         assertThat(keywords.getKeywords())
             .containsOnly(Keyword.ANSWERED, Keyword.FLAGGED);
@@ -189,7 +189,7 @@ public class KeywordsTest {
     @Test
     public void fromListShouldNotThrowOnInvalidKeywordForLenientFactory() {
         assertThat(Keywords.lenientFactory()
-            .fromList(ImmutableList.of("in&valid")))
+            .fromCollection(ImmutableList.of("in&valid")))
             .isEqualTo(Keywords.DEFAULT_VALUE);
     }
 


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