JAMES-2285 FakeMail should handle Per Recipients Header

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

Branch: refs/heads/master
Commit: 1a9d80d1b390ac93a1aa66ecfc274e7b3d8ec84a
Parents: eeae0a0
Author: benwa <[email protected]>
Authored: Thu Jan 11 15:19:34 2018 +0700
Committer: benwa <[email protected]>
Committed: Mon Jan 15 17:04:03 2018 +0700

----------------------------------------------------------------------
 .../java/org/apache/mailet/base/test/FakeMail.java  | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/1a9d80d1/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 31e65c2..c2c6e98 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
@@ -86,7 +86,8 @@ public class FakeMail implements Mail {
             attributes(mail),
             mail.getMessageSize(),
             mail.getRemoteAddr(),
-            mail.getRemoteHost());
+            mail.getRemoteHost(),
+            mail.getPerRecipientSpecificHeaders());
     }
 
     public static FakeMail from(MimeMessage message) throws MessagingException 
{
@@ -113,6 +114,7 @@ public class FakeMail implements Mail {
         private Optional<Long> size;
         private Optional<String> remoteAddr;
         private Optional<String> remoteHost;
+        private PerRecipientHeaders perRecipientHeaders;
 
         private Builder() {
             fileName = Optional.empty();
@@ -127,6 +129,7 @@ public class FakeMail implements Mail {
             size = Optional.empty();
             remoteAddr = Optional.empty();
             remoteHost = Optional.empty();
+            perRecipientHeaders = new PerRecipientHeaders();
         }
 
         public Builder size(long size) {
@@ -225,9 +228,14 @@ public class FakeMail implements Mail {
             return this;
         }
 
+        public Builder addHeaderForRecipient(Header header, MailAddress 
recipient) {
+            this.perRecipientHeaders.addHeaderForRecipient(header, recipient);
+            return this;
+        }
+
         public FakeMail build() throws MessagingException {
             return new FakeMail(getMimeMessage(), recipients, 
name.orElse(null), sender.orElse(null), state.orElse(null), 
errorMessage.orElse(null), lastUpdated.orElse(null),
-                attributes, size.orElse(0L), 
remoteAddr.orElse(DEFAULT_REMOTE_ADDRESS), 
remoteHost.orElse(DEFAULT_REMOTE_HOST));
+                attributes, size.orElse(0L), 
remoteAddr.orElse(DEFAULT_REMOTE_ADDRESS), 
remoteHost.orElse(DEFAULT_REMOTE_HOST), perRecipientHeaders);
         }
 
         private MimeMessage getMimeMessage() throws MessagingException {
@@ -265,7 +273,7 @@ public class FakeMail implements Mail {
     private PerRecipientHeaders perRecipientHeaders;
     
     public FakeMail(MimeMessage msg, List<MailAddress> recipients, String 
name, MailAddress sender, String state, String errorMessage, Date lastUpdated,
-            Map<String, Serializable> attributes, long size, String 
remoteAddr, String remoteHost) {
+            Map<String, Serializable> attributes, long size, String 
remoteAddr, String remoteHost, PerRecipientHeaders perRecipientHeaders) {
         this.msg = msg;
         this.recipients = recipients;
         this.name = name;
@@ -276,7 +284,7 @@ public class FakeMail implements Mail {
         this.attributes = attributes;
         this.size = size;
         this.remoteAddr = remoteAddr;
-        this.perRecipientHeaders = new PerRecipientHeaders();
+        this.perRecipientHeaders = perRecipientHeaders;
         this.remoteHost = remoteHost;
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to