This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 96a1d3e69e40e395442e4c14bc0dfab19e0ef4e5
Author: Quan Tran <hqt...@linagora.com>
AuthorDate: Tue Nov 12 11:49:11 2024 +0700

    JAMES-4087 Rephrase MatcherInverterTest::testOneMatch to better reflect 
real usage
---
 .../apache/mailet/base/MatcherInverterTest.java    | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git 
a/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java 
b/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
index 5f35b10985..35b3b8da06 100644
--- a/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
+++ b/mailet/base/src/test/java/org/apache/mailet/base/MatcherInverterTest.java
@@ -73,21 +73,24 @@ class MatcherInverterTest {
 
     @Test
     void testOneMatch() throws MessagingException {
-        final MailAddress address1 = new MailAddress("user", "domain");
-        final MailAddress address2 = new MailAddress("user", "domain2");
+        MailAddress errorRecipient = new MailAddress("er...@domain.tld");
+        MailAddress validRecipient = new MailAddress("va...@domain.tld");
 
-        MatcherInverter inverter = new MatcherInverter(new GenericMatcher() {
+        // e.g. <mailet notMatch="RecipientIs=er...@domain.tld" 
class="org.apache.james.Whatever"/>
+        MatcherInverter notErrorRecipientMatcher = new MatcherInverter(new 
GenericMatcher() {
             @Override
-            public Collection<MailAddress> match(Mail mail) throws 
MessagingException {
-                return Arrays.asList(address1);
+            public Collection<MailAddress> match(Mail mail) {
+                return Arrays.asList(errorRecipient);
             }
         });
 
-        FakeMail mail = FakeMail.builder()
-                .name("mail")
-                .recipients(address1, address2)
-                .build();
+        FakeMail mailToBothValidAndErrorRecipient = FakeMail.builder()
+            .name("mail")
+            .recipients(validRecipient, errorRecipient)
+            .build();
 
-        
assertThat(inverter.match(mail).iterator().next().toString()).describedAs("Should
 match one recipient").isEqualTo(address2.toString());
+        
assertThat(notErrorRecipientMatcher.match(mailToBothValidAndErrorRecipient))
+            .describedAs("Only valid address should not match the error 
recipient")
+            .containsOnly(validRecipient);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to