james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [13/14] james-project git commit: JAMES-2546 Add nullSender support to MailRepository contract
Date Mon, 17 Sep 2018 06:33:23 GMT
JAMES-2546 Add nullSender support to MailRepository contract


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

Branch: refs/heads/master
Commit: ce1646eb234a881530144161d384cd0781bab1ef
Parents: d8c5821
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Sep 13 15:43:50 2018 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Sep 17 08:14:16 2018 +0200

----------------------------------------------------------------------
 .../jdbc/JDBCMailRepositoryTest.java               |  7 +++++++
 .../mailrepository/MailRepositoryContract.java     | 17 +++++++++++++++++
 .../cassandra/CassandraMailRepositoryMailDAO.java  |  2 +-
 3 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ce1646eb/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
index db385a0..59a06b1 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/mailrepository/jdbc/JDBCMailRepositoryTest.java
@@ -32,6 +32,7 @@ import org.apache.james.mailrepository.MailRepositoryContract;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
 
 public class JDBCMailRepositoryTest implements MailRepositoryContract {
 
@@ -72,4 +73,10 @@ public class JDBCMailRepositoryTest implements MailRepositoryContract {
         ds.setPassword("james");
         return ds;
     }
+
+    @Override
+    @Disabled("JAMES-2546 This mail repository does not support null sender")
+    public void storeRegularMailShouldNotFailWhenNullSender() {
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/ce1646eb/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
index 7c1d83e..fd7d997 100644
--- a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/MailRepositoryContract.java
@@ -43,6 +43,8 @@ import org.apache.james.utils.DiscreteDistribution;
 import org.apache.james.utils.DiscreteDistribution.DistributionEntry;
 import org.apache.mailet.Mail;
 import org.apache.mailet.PerRecipientHeaders;
+import org.apache.mailet.base.MailAddressFixture;
+import org.apache.mailet.base.test.FakeMail;
 import org.junit.jupiter.api.RepeatedTest;
 import org.junit.jupiter.api.Test;
 
@@ -136,6 +138,21 @@ public interface MailRepositoryContract {
     }
 
     @Test
+    default void storeRegularMailShouldNotFailWhenNullSender() throws Exception {
+        MailRepository testee = retrieveRepository();
+        Mail mail = FakeMail.builder()
+            .sender(MailAddress.nullSender())
+            .recipient(MailAddressFixture.RECIPIENT1)
+            .name(MAIL_1.asString())
+            .mimeMessage(generateMailContent("String body"))
+            .build();
+
+        testee.store(mail);
+
+        assertThat(testee.retrieve(MAIL_1).getSender()).isEqualTo(MailAddress.nullSender());
+    }
+
+    @Test
     default void storeRegularMailShouldNotFail() throws Exception {
         MailRepository testee = retrieveRepository();
         Mail mail = createMail(MAIL_1);

http://git-wip-us.apache.org/repos/asf/james-project/blob/ce1646eb/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAO.java
----------------------------------------------------------------------
diff --git a/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAO.java
b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAO.java
index b106437..7c4ffcc 100644
--- a/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAO.java
+++ b/server/mailrepository/mailrepository-cassandra/src/main/java/org/apache/james/mailrepository/cassandra/CassandraMailRepositoryMailDAO.java
@@ -174,7 +174,7 @@ public class CassandraMailRepositoryMailDAO {
 
     private MailDTO toMail(Row row) {
         MailAddress sender = Optional.ofNullable(row.getString(SENDER))
-            .map(Throwing.function(MailAddress::new))
+            .map(MailAddress::getMailSender)
             .orElse(null);
         List<MailAddress> recipients = row.getList(RECIPIENTS, String.class)
             .stream()


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