james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [12/16] james-project git commit: JAMES-2134 Buidler for Final-Recipient field
Date Thu, 05 Apr 2018 12:52:02 GMT
JAMES-2134 Buidler for Final-Recipient field


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

Branch: refs/heads/master
Commit: bda0634431881f48812e077969ca1a432d80f3ac
Parents: 800f176
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Wed Apr 4 10:41:29 2018 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Thu Apr 5 14:48:42 2018 +0200

----------------------------------------------------------------------
 .../java/org/apache/james/mdn/MDNReport.java    |  2 +-
 .../apache/james/mdn/fields/FinalRecipient.java | 39 +++++++++++++----
 .../james/mdn/MDNReportFormattingTest.java      | 46 ++++++++++----------
 .../org/apache/james/mdn/MDNReportTest.java     |  6 +--
 .../james/mdn/fields/FinalRecipientTest.java    | 17 ++++----
 5 files changed, 66 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/bda06344/mdn/src/main/java/org/apache/james/mdn/MDNReport.java
----------------------------------------------------------------------
diff --git a/mdn/src/main/java/org/apache/james/mdn/MDNReport.java b/mdn/src/main/java/org/apache/james/mdn/MDNReport.java
index b8ea4c7..bfcbf30 100644
--- a/mdn/src/main/java/org/apache/james/mdn/MDNReport.java
+++ b/mdn/src/main/java/org/apache/james/mdn/MDNReport.java
@@ -101,7 +101,7 @@ public class MDNReport {
         }
 
         public Builder finalRecipientField(String finalRecipientField) {
-            this.finalRecipientField = Optional.of(new FinalRecipient(Text.fromRawText(finalRecipientField)));
+            this.finalRecipientField = Optional.of(FinalRecipient.builder().finalRecipient(Text.fromRawText(finalRecipientField)).build());
             return this;
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/bda06344/mdn/src/main/java/org/apache/james/mdn/fields/FinalRecipient.java
----------------------------------------------------------------------
diff --git a/mdn/src/main/java/org/apache/james/mdn/fields/FinalRecipient.java b/mdn/src/main/java/org/apache/james/mdn/fields/FinalRecipient.java
index 0775479..14bfb4a 100644
--- a/mdn/src/main/java/org/apache/james/mdn/fields/FinalRecipient.java
+++ b/mdn/src/main/java/org/apache/james/mdn/fields/FinalRecipient.java
@@ -20,6 +20,7 @@
 package org.apache.james.mdn.fields;
 
 import java.util.Objects;
+import java.util.Optional;
 
 import com.google.common.base.Preconditions;
 
@@ -31,21 +32,43 @@ import com.google.common.base.Preconditions;
 public class FinalRecipient implements Field {
     public static final String FIELD_NAME = "Final-Recipient";
 
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private Optional<AddressType> addressType;
+        private Text finalRecipient;
+
+        private Builder() {
+            addressType = Optional.empty();
+        }
+
+        public Builder addressType(AddressType addressType) {
+            this.addressType = Optional.of(addressType);
+            return this;
+        }
+
+        public Builder finalRecipient(Text finalRecipient) {
+            this.finalRecipient = finalRecipient;
+            return this;
+        }
+
+        public FinalRecipient build() {
+            Preconditions.checkNotNull(finalRecipient);
+
+            return new FinalRecipient(addressType.orElse(AddressType.RFC_822), finalRecipient);
+        }
+    }
+
     private final Text finalRecipient;
     private final AddressType addressType;
 
-    public FinalRecipient(AddressType addressType, Text finalRecipient) {
-        Preconditions.checkNotNull(finalRecipient);
-        Preconditions.checkNotNull(addressType);
-
+    private FinalRecipient(AddressType addressType, Text finalRecipient) {
         this.finalRecipient = finalRecipient;
         this.addressType = addressType;
     }
 
-    public FinalRecipient(Text finalRecipient) {
-        this(AddressType.RFC_822, finalRecipient);
-    }
-
     public Text getFinalRecipient() {
         return finalRecipient;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/bda06344/mdn/src/test/java/org/apache/james/mdn/MDNReportFormattingTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/MDNReportFormattingTest.java b/mdn/src/test/java/org/apache/james/mdn/MDNReportFormattingTest.java
index 9ab758a..063be54 100644
--- a/mdn/src/test/java/org/apache/james/mdn/MDNReportFormattingTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/MDNReportFormattingTest.java
@@ -51,7 +51,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -78,7 +78,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -105,7 +105,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -132,7 +132,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -159,7 +159,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -186,7 +186,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -212,7 +212,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -238,7 +238,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -263,7 +263,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -290,7 +290,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -317,7 +317,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
             .build()
@@ -342,7 +342,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .dispositionField(disposition)
             .build()
@@ -368,7 +368,7 @@ public class MDNReportFormattingTest {
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
             .gatewayField(Gateway.builder().name(Text.fromRawText("host.com")).build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -397,7 +397,7 @@ public class MDNReportFormattingTest {
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
             .gatewayField(Gateway.builder().nameType(new AddressType("postal")).name(Text.fromRawText("5
rue Charles mercier")).build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -425,7 +425,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().addressType(new AddressType("roomNumber")).originalRecipient(Text.fromRawText("385")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -453,7 +453,7 @@ public class MDNReportFormattingTest {
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
             .gatewayField(Gateway.builder().nameType(new AddressType("postal")).name(Text.fromRawText("8
rue Charles mercier\n 36555 Saint Coincoin\n France")).build())
-            .finalRecipientField(new FinalRecipient(new AddressType("postal"), Text.fromRawText("5
rue Mercier\n 36555 Saint Coincoin\n France")))
+            .finalRecipientField(FinalRecipient.builder().addressType(new AddressType("postal")).finalRecipient(Text.fromRawText("5
rue Mercier\n 36555 Saint Coincoin\n France")).build())
             .originalRecipientField(OriginalRecipient.builder().addressType(new AddressType("postal")).originalRecipient(Text.fromRawText("3
rue Mercier\n 36555 Saint Coincoin\n France")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -487,7 +487,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.ofUnknown(Text.fromRawText("#$%*")))
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -514,7 +514,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(new AddressType("roomNumber"), Text.fromRawText("781")))
+            .finalRecipientField(FinalRecipient.builder().addressType(new AddressType("roomNumber")).finalRecipient(Text.fromRawText("781")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -541,7 +541,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -570,7 +570,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -602,7 +602,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -632,7 +632,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)
@@ -662,7 +662,7 @@ public class MDNReportFormattingTest {
 
         String report = MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .originalMessageIdField(new OriginalMessageId("original_message_id"))
             .dispositionField(disposition)

http://git-wip-us.apache.org/repos/asf/james-project/blob/bda06344/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java b/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java
index 7effd8d..526511c 100644
--- a/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/MDNReportTest.java
@@ -62,7 +62,7 @@ public class MDNReportTest {
 
         MDNReport.builder()
             .reportingUserAgentField(ReportingUserAgent.builder().userAgentName("UA_name").userAgentProduct("UA_product").build())
-            .finalRecipientField(new FinalRecipient(Text.fromRawText("final_recipient")))
+            .finalRecipientField(FinalRecipient.builder().finalRecipient(Text.fromRawText("final_recipient")).build())
             .originalRecipientField(OriginalRecipient.builder().originalRecipient(Text.fromRawText("originalRecipient")).build())
             .build();
     }
@@ -95,7 +95,7 @@ public class MDNReportTest {
             .type(DispositionType.Processed)
             .build();
 
-        FinalRecipient finalRecipientField = new FinalRecipient(Text.fromRawText("any@domain.com"));
+        FinalRecipient finalRecipientField = FinalRecipient.builder().finalRecipient(Text.fromRawText("any@domain.com")).build();
         MDNReport mdnReport = MDNReport.builder()
             .finalRecipientField(finalRecipientField)
             .dispositionField(disposition)
@@ -114,7 +114,7 @@ public class MDNReportTest {
             .sendingMode(DispositionSendingMode.Automatic)
             .type(DispositionType.Processed)
             .build();
-        FinalRecipient finalRecipientField = new FinalRecipient(Text.fromRawText("any@domain.com"));
+        FinalRecipient finalRecipientField = FinalRecipient.builder().finalRecipient(Text.fromRawText("any@domain.com")).build();
         ExtensionField extensionField1 = new ExtensionField("name1", "value1");
         ExtensionField extensionField2 = new ExtensionField("name2", "value2");
         Gateway gateway = Gateway.builder().name(Text.fromRawText("address")).build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/bda06344/mdn/src/test/java/org/apache/james/mdn/fields/FinalRecipientTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/fields/FinalRecipientTest.java b/mdn/src/test/java/org/apache/james/mdn/fields/FinalRecipientTest.java
index b53cf61..ef4cd69 100644
--- a/mdn/src/test/java/org/apache/james/mdn/fields/FinalRecipientTest.java
+++ b/mdn/src/test/java/org/apache/james/mdn/fields/FinalRecipientTest.java
@@ -43,48 +43,47 @@ public class FinalRecipientTest {
     public void shouldThrowOnNullAddress() {
         expectedException.expect(NullPointerException.class);
 
-        new FinalRecipient(null);
+        FinalRecipient.builder().finalRecipient(null).build();
     }
 
     @Test
     public void shouldThrowOnNullAddressWithType() {
         expectedException.expect(NullPointerException.class);
 
-        new FinalRecipient(new AddressType("customType"), null);
+        FinalRecipient.builder().addressType(new AddressType("customType")).finalRecipient(null).build();
     }
 
     @Test
     public void shouldThrowOnNullType() {
         expectedException.expect(NullPointerException.class);
 
-        AddressType addressType = null;
-        new FinalRecipient(addressType, Text.fromRawText("address"));
+        FinalRecipient.builder().addressType(null).finalRecipient(Text.fromRawText("address")).build();
     }
 
     @Test
     public void typeShouldDefaultToRfc822() {
         Text address = Text.fromRawText("address");
-        assertThat(new FinalRecipient(address))
-            .isEqualTo(new FinalRecipient(AddressType.RFC_822, address));
+        assertThat(FinalRecipient.builder().finalRecipient(address).build())
+            .isEqualTo(FinalRecipient.builder().addressType(AddressType.RFC_822).finalRecipient(address).build());
     }
 
     @Test
     public void formattedValueShouldDisplayAddress() {
-        assertThat(new FinalRecipient(Text.fromRawText("Plop"))
+        assertThat(FinalRecipient.builder().finalRecipient(Text.fromRawText("Plop")).build()
             .formattedValue())
             .isEqualTo("Final-Recipient: rfc822; Plop");
     }
 
     @Test
     public void formattedValueShouldDisplayCustomType() {
-        assertThat(new FinalRecipient(new AddressType("postal"), Text.fromRawText("Plop"))
+        assertThat(FinalRecipient.builder().addressType(new AddressType("postal")).finalRecipient(Text.fromRawText("Plop")).build()
             .formattedValue())
             .isEqualTo("Final-Recipient: postal; Plop");
     }
 
     @Test
     public void formattedValueShouldDisplayMultilineAddress() {
-        assertThat(new FinalRecipient(Text.fromRawText("Plop\nGlark"))
+        assertThat(FinalRecipient.builder().finalRecipient(Text.fromRawText("Plop\nGlark")).build()
             .formattedValue())
             .isEqualTo("Final-Recipient: rfc822; Plop\r\n" +
                 " Glark");


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