james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [38/44] james-project git commit: JAMES-2267 Factorize a bit user creation in RRT integration test
Date Fri, 05 Jan 2018 03:01:22 GMT
JAMES-2267 Factorize a bit user creation in RRT integration test


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

Branch: refs/heads/master
Commit: 85e48efcc0f7c18f6de958abedb49e0085ce49ad
Parents: 21e1326
Author: benwa <btellier@linagora.com>
Authored: Thu Dec 21 11:44:53 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Jan 5 09:34:38 2018 +0700

----------------------------------------------------------------------
 .../org/apache/mailet/base/test/FakeMail.java    | 14 +++++++-------
 .../RecipientRewriteTableIntegrationTest.java    | 19 ++++---------------
 2 files changed, 11 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/85e48efc/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
----------------------------------------------------------------------
diff --git a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
index bcb59f9..4dc8dbb 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/test/FakeMail.java
@@ -44,6 +44,7 @@ import org.apache.mailet.PerRecipientHeaders;
 import org.apache.mailet.PerRecipientHeaders.Header;
 
 import com.github.fge.lambdas.Throwing;
+import com.github.steveash.guavate.Guavate;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
@@ -151,22 +152,21 @@ public class FakeMail implements Mail {
         }
 
         public Builder recipients(MailAddress... recipients) {
-            this.recipients.addAll(ImmutableList.copyOf(recipients));
-            return this;
+            return recipients(ImmutableList.copyOf(recipients));
         }
 
         public Builder recipients(String... recipients) {
-            Arrays.stream(recipients).forEach(Throwing.consumer(this::recipient));
-            return this;
+            return recipients(Arrays.stream(recipients)
+                .map(Throwing.function(MailAddress::new))
+                .collect(Guavate.toImmutableList()));
         }
 
         public Builder recipient(MailAddress recipient) {
-            this.recipients.add(recipient);
-            return this;
+            return recipients(recipient);
         }
 
         public Builder recipient(String recipient) throws AddressException {
-            return recipient(new MailAddress(recipient));
+            return recipients(recipient);
         }
 
         public Builder name(String name) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/85e48efc/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
index e59342a..041e001 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
@@ -41,10 +41,8 @@ public class RecipientRewriteTableIntegrationTest {
 
     private static final String FROM = "fromUser@" + DEFAULT_DOMAIN;
     private static final String RECIPIENT = "touser@" + DEFAULT_DOMAIN;
-
     private static final String ANY_AT_JAMES = "any@" + DEFAULT_DOMAIN;
     private static final String OTHER_AT_JAMES = "other@" + DEFAULT_DOMAIN;
-
     private static final String ANY_AT_ANOTHER_DOMAIN = "any@" + JAMES_ANOTHER_DOMAIN;
 
     @Rule
@@ -64,6 +62,10 @@ public class RecipientRewriteTableIntegrationTest {
         dataProbe = jamesServer.getProbe(DataProbeImpl.class);
         dataProbe.addDomain(DEFAULT_DOMAIN);
         dataProbe.addDomain(JAMES_ANOTHER_DOMAIN);
+
+        dataProbe.addUser(RECIPIENT, PASSWORD);
+        dataProbe.addUser(ANY_AT_JAMES, PASSWORD);
+        dataProbe.addUser(OTHER_AT_JAMES, PASSWORD);
     }
 
     @After
@@ -73,10 +75,6 @@ public class RecipientRewriteTableIntegrationTest {
 
     @Test
     public void rrtServiceShouldDeliverEmailToMappingRecipients() throws Exception {
-        dataProbe.addUser(FROM, PASSWORD);
-        dataProbe.addUser(ANY_AT_JAMES, PASSWORD);
-        dataProbe.addUser(OTHER_AT_JAMES, PASSWORD);
-
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, ANY_AT_JAMES);
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, OTHER_AT_JAMES);
 
@@ -96,11 +94,6 @@ public class RecipientRewriteTableIntegrationTest {
 
     @Test
     public void rrtServiceShouldNotDeliverEmailToRecipientWhenHaveMappingRecipients() throws
Exception {
-        dataProbe.addUser(FROM, PASSWORD);
-        dataProbe.addUser(RECIPIENT, PASSWORD);
-        dataProbe.addUser(ANY_AT_JAMES, PASSWORD);
-        dataProbe.addUser(OTHER_AT_JAMES, PASSWORD);
-
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, ANY_AT_JAMES);
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, OTHER_AT_JAMES);
 
@@ -118,9 +111,7 @@ public class RecipientRewriteTableIntegrationTest {
     public void rrtServiceShouldDeliverEmailToRecipientOnLocalWhenMappingContainsNonDomain()
throws Exception {
         String nonDomainUser = "nondomain";
         String localUser = nonDomainUser + "@" + dataProbe.getDefaultDomain();
-        dataProbe.addUser(FROM, PASSWORD);
         dataProbe.addUser(localUser, PASSWORD);
-        dataProbe.addUser(OTHER_AT_JAMES, PASSWORD);
 
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, nonDomainUser);
         dataProbe.addAddressMapping("touser", DEFAULT_DOMAIN, OTHER_AT_JAMES);
@@ -142,7 +133,6 @@ public class RecipientRewriteTableIntegrationTest {
     @Test
     public void messageShouldRedirectToTheSameUserWhenDomainMapping() throws Exception {
         dataProbe.addDomainAliasMapping(DEFAULT_DOMAIN, JAMES_ANOTHER_DOMAIN);
-        dataProbe.addUser(ANY_AT_JAMES, PASSWORD);
         dataProbe.addUser(ANY_AT_ANOTHER_DOMAIN, PASSWORD);
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)
@@ -158,7 +148,6 @@ public class RecipientRewriteTableIntegrationTest {
     @Test
     public void messageShouldNotSendToRecipientWhenDomainMapping() throws Exception {
         dataProbe.addDomainAliasMapping(DEFAULT_DOMAIN, JAMES_ANOTHER_DOMAIN);
-        dataProbe.addUser(ANY_AT_JAMES, PASSWORD);
         dataProbe.addUser(ANY_AT_ANOTHER_DOMAIN, PASSWORD);
 
         messageSender.connect(LOCALHOST_IP, SMTP_PORT)


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