You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/11/13 02:31:59 UTC
(james-project) 07/08: JAMES-4087 Rephrase MatcherInverterTest::testOneMatch to better reflect real usage
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 <hq...@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("error@domain.tld");
+ MailAddress validRecipient = new MailAddress("valid@domain.tld");
- MatcherInverter inverter = new MatcherInverter(new GenericMatcher() {
+ // e.g. <mailet notMatch="RecipientIs=error@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-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org