james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [43/50] [abbrv] james-project git commit: MAILET-115 getReversePath methods return an Optional
Date Wed, 11 Jan 2017 09:26:31 GMT
MAILET-115 getReversePath methods return an Optional


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

Branch: refs/heads/master
Commit: 7a618b9ba470e1a548cc9fd1aabc33270aa18f64
Parents: 70f8c25
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Tue Jan 3 13:24:04 2017 +0100
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Jan 11 10:03:32 2017 +0700

----------------------------------------------------------------------
 .../apache/james/transport/mailets/Bounce.java  |  9 +++---
 .../james/transport/mailets/DSNBounce.java      |  9 +++---
 .../apache/james/transport/mailets/Forward.java |  8 +++---
 .../transport/mailets/NotifyPostmaster.java     |  9 +++---
 .../james/transport/mailets/NotifySender.java   |  9 +++---
 .../james/transport/mailets/Redirect.java       | 23 ++++++++-------
 .../apache/james/transport/mailets/Resend.java  | 15 +++++-----
 .../mailets/redirect/MailModifier.java          |  5 ++--
 .../mailets/redirect/RedirectNotify.java        |  4 +--
 .../transport/util/SpecialAddressesUtils.java   |  7 +++--
 .../util/SpecialAddressesUtilsTest.java         | 30 +++++++++++---------
 11 files changed, 69 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
index 8cd05c1..f3c360b 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
@@ -206,12 +206,12 @@ public class Bounce extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) {
-        return SpecialAddress.NULL;
+    public Optional<MailAddress> getReversePath(Mail originalMail) {
+        return Optional.of(SpecialAddress.NULL);
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
@@ -219,7 +219,8 @@ public class Bounce extends GenericMailet implements RedirectNotify {
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
index a8ccd72..9651f47 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
@@ -194,20 +194,21 @@ public class DSNBounce extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) {
-        return SpecialAddress.NULL;
+    public Optional<MailAddress> getReversePath(Mail originalMail) {
+        return Optional.of(SpecialAddress.NULL);
     }
 
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
index 8b495cc..1e4dbb6 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
@@ -211,13 +211,13 @@ public class Forward extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
-        return null;
+    public Optional<MailAddress> getReversePath() throws MessagingException {
+        return Optional.absent();
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
-        return null;
+    public Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException
{
+        return Optional.absent();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
index e79a63e..a9a8df5 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
@@ -222,20 +222,21 @@ public class NotifyPostmaster extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
-        return getSender(originalMail).orNull();
+    public Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException
{
+        return getSender(originalMail);
     }
 
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
index bb17a82..b0ad1ee 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
@@ -222,20 +222,21 @@ public class NotifySender extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
-        return getSender(originalMail).orNull();
+    public Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException
{
+        return getSender(originalMail);
     }
 
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
index 21a2be8..f8fafaf 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
@@ -428,25 +428,25 @@ public class Redirect extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
ImmutableList.of("postmaster", "sender", "null"));
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
-        MailAddress reversePath = retrieveReversePath();
-        if (reversePath != null) {
+    public Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException
{
+        Optional<MailAddress> reversePath = retrieveReversePath();
+        if (reversePath.isPresent()) {
             return reversePath;
         }
-        return getSender(originalMail).orNull();
+        return getSender(originalMail);
     }
 
-    private MailAddress retrieveReversePath() throws MessagingException {
-        MailAddress reversePath = getReversePath();
-        if (reversePath != null) {
-            if (MailAddressUtils.isUnalteredOrReversePathOrSender(reversePath)) {
-                return null;
+    private Optional<MailAddress> retrieveReversePath() throws MessagingException {
+        Optional<MailAddress> reversePath = getReversePath();
+        if (reversePath.isPresent()) {
+            if (MailAddressUtils.isUnalteredOrReversePathOrSender(reversePath.get())) {
+                return Optional.absent();
             }
         }
         return reversePath;
@@ -455,7 +455,8 @@ public class Redirect extends GenericMailet implements RedirectNotify
{
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
index d62a4a6..386d372 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Resend.java
@@ -399,17 +399,17 @@ public class Resend extends GenericMailet implements RedirectNotify
{
     }
 
     @Override
-    public MailAddress getReversePath() throws MessagingException {
+    public Optional<MailAddress> getReversePath() throws MessagingException {
         return SpecialAddressesUtils.from(this)
                 .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getReversePath(),
RedirectNotify.REVERSE_PATH_ALLOWED_SPECIALS);
     }
 
     @Override
-    public MailAddress getReversePath(Mail originalMail) throws MessagingException {
-        MailAddress reversePath = getReversePath();
-        if (reversePath != null) {
-            if (MailAddressUtils.isUnalteredOrReversePathOrSender(reversePath)) {
-                return null;
+    public Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException
{
+        Optional<MailAddress> reversePath = getReversePath();
+        if (reversePath.isPresent()) {
+            if (MailAddressUtils.isUnalteredOrReversePathOrSender(reversePath.get())) {
+                return Optional.absent();
             }
         }
         return reversePath;
@@ -418,7 +418,8 @@ public class Resend extends GenericMailet implements RedirectNotify {
     @Override
     public MailAddress getSender() throws MessagingException {
         return SpecialAddressesUtils.from(this)
-                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS);
+                .getFirstSpecialAddressIfMatchingOrGivenAddress(getInitParameters().getSender(),
RedirectNotify.SENDER_ALLOWED_SPECIALS)
+                .orNull();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
index 990cd55..9a9d228 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/MailModifier.java
@@ -157,8 +157,9 @@ public class MailModifier {
      * requested value is <code>SpecialAddress.NULL</code> sets it to "<>".
If
      * the requested value is null does nothing.
      */
-    public void setReversePath(MailAddress reversePath, Mail originalMail) {
-        if (reversePath != null) {
+    public void setReversePath(Optional<MailAddress> maybeReversePath, Mail originalMail)
{
+        if (maybeReversePath.isPresent()) {
+            MailAddress reversePath = maybeReversePath.get();
             if (reversePath.equals(SpecialAddress.NULL)) {
                 mail.setSender(null);
                 if (mailet.getInitParameters().isDebug()) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
index 028bdf0..a87c298 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectNotify.java
@@ -235,7 +235,7 @@ public interface RedirectNotify extends Mailet, MailetConfig {
      *         <code>SpecialAddress.UNALTERED</code> or <code>null</code>
if
      *         missing
      */
-    MailAddress getReversePath() throws MessagingException; 
+    Optional<MailAddress> getReversePath() throws MessagingException; 
 
     /**
      * Gets the <code>reversePath</code> property, built dynamically using the
@@ -248,7 +248,7 @@ public interface RedirectNotify extends Mailet, MailetConfig {
      *         but not replacing <code>SpecialAddress.NULL</code> that will be
      *         handled by {@link #setReversePath}
      */
-    MailAddress getReversePath(Mail originalMail) throws MessagingException;
+    Optional<MailAddress> getReversePath(Mail originalMail) throws MessagingException;
 
     /**
      * Gets the <code>sender</code> property. Returns the new sender as a

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
index dc4912d..9097e7a 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/util/SpecialAddressesUtils.java
@@ -34,6 +34,7 @@ import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.RFC2822Headers;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Strings;
 import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableList;
@@ -262,15 +263,15 @@ public class SpecialAddressesUtils {
      * If the givenAddress matches one of the allowedSpecials SpecialAddresses, then it's
returned
      * else the givenAddress is returned.
      */
-    public MailAddress getFirstSpecialAddressIfMatchingOrGivenAddress(String givenAddress,
List<String> allowedSpecials) throws MessagingException {
+    public Optional<MailAddress> getFirstSpecialAddressIfMatchingOrGivenAddress(String
givenAddress, List<String> allowedSpecials) throws MessagingException {
         if (Strings.isNullOrEmpty(givenAddress)) {
-            return null;
+            return Optional.absent();
         }
 
         List<MailAddress> extractAddresses = AddressExtractor
                 .withContext(mailet.getMailetContext())
                 .allowedSpecials(allowedSpecials)
                 .extract(givenAddress);
-        return FluentIterable.from(extractAddresses).first().orNull();
+        return FluentIterable.from(extractAddresses).first();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a618b9b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
index 369befc..670d518 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/util/SpecialAddressesUtilsTest.java
@@ -19,6 +19,7 @@
 package org.apache.james.transport.util;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.guava.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -40,6 +41,7 @@ import org.apache.mailet.base.test.FakeMail;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableList;
 
 public class SpecialAddressesUtilsTest {
@@ -447,47 +449,47 @@ public class SpecialAddressesUtilsTest {
     }
 
     @Test
-    public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnNullWhenSenderInitParameterIsNull()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress(null,
ImmutableList.of("postmaster", "sender", "unaltered"));
+    public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnAbsentWhenSenderInitParameterIsNull()
throws Exception {
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress(null,
ImmutableList.of("postmaster", "sender", "unaltered"));
 
-        assertThat(sender).isNull();
+        assertThat(sender).isAbsent();
     }
 
     @Test
-    public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnNullWhenSenderInitParameterIsEmpty()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("", ImmutableList.of("postmaster",
"sender", "unaltered"));
+    public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnAbsentWhenSenderInitParameterIsEmpty()
throws Exception {
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("",
ImmutableList.of("postmaster", "sender", "unaltered"));
 
-        assertThat(sender).isNull();
+        assertThat(sender).isAbsent();
     }
 
     @Test
     public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnGivenAddressWhenNoSpecialAddressMatches()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("test@james.org",
ImmutableList.of("postmaster", "sender", "unaltered"));
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("test@james.org",
ImmutableList.of("postmaster", "sender", "unaltered"));
 
         MailAddress expectedMailAddress = new MailAddress("test", "james.org");
-        assertThat(sender).isEqualTo(expectedMailAddress);
+        assertThat(sender).contains(expectedMailAddress);
     }
 
     @Test
     public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnFirstSpecialAddressWhenMatching()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("postmaster",
ImmutableList.of("postmaster", "sender", "unaltered"));
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("postmaster",
ImmutableList.of("postmaster", "sender", "unaltered"));
 
-        assertThat(sender).isEqualTo(postmaster);
+        assertThat(sender).contains(postmaster);
     }
 
     @Test
     public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnSecondSpecialAddressWhenMatching()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("sender",
ImmutableList.of("postmaster", "sender", "unaltered"));
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("sender",
ImmutableList.of("postmaster", "sender", "unaltered"));
 
         MailAddress expectedMailAddress = SpecialAddress.SENDER;
-        assertThat(sender).isEqualTo(expectedMailAddress);
+        assertThat(sender).contains(expectedMailAddress);
     }
 
     @Test
     public void getFirstSpecialAddressIfMatchingOrGivenAddressShouldReturnLastSpecialAddressWhenMatching()
throws Exception {
-        MailAddress sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("unaltered",
ImmutableList.of("postmaster", "sender", "unaltered"));
+        Optional<MailAddress> sender = testee.getFirstSpecialAddressIfMatchingOrGivenAddress("unaltered",
ImmutableList.of("postmaster", "sender", "unaltered"));
 
         MailAddress expectedMailAddress = SpecialAddress.UNALTERED;
-        assertThat(sender).isEqualTo(expectedMailAddress);
+        assertThat(sender).contains(expectedMailAddress);
     }
 }


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