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 548af735ae74fbecad2048627f062633e63d1f7b
Author: Trung NGUYEN <[email protected]>
AuthorDate: Wed Sep 10 11:06:14 2025 +0200

    JAMES-4143 Add tests in JMAPFilteringTest
---
 .../jmap/mailet/filter/JMAPFilteringTest.java      | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git 
a/server/protocols/jmap-rfc-8621/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
 
b/server/protocols/jmap-rfc-8621/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
index eeea375ba0..3008166590 100644
--- 
a/server/protocols/jmap-rfc-8621/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
+++ 
b/server/protocols/jmap-rfc-8621/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java
@@ -24,6 +24,7 @@ import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Comparator.CONT
 import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Comparator.EXACTLY_EQUALS;
 import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Comparator.NOT_CONTAINS;
 import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Comparator.NOT_EXACTLY_EQUALS;
+import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Comparator.START_WITH;
 import static org.apache.james.jmap.api.filtering.Rule.Condition.Field.CC;
 import static org.apache.james.jmap.api.filtering.Rule.Condition.Field.FROM;
 import static 
org.apache.james.jmap.api.filtering.Rule.Condition.Field.RECIPIENT;
@@ -1129,4 +1130,56 @@ class JMAPFilteringTest {
 
         
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME).isEmpty()).isTrue();
     }
+
+    @Test
+    void startWithAddressMailMatched(JMAPFilteringTestSystem testSystem) 
throws Exception {
+        testSystem.defineRulesForRecipient1(
+            Rule.Condition.of(FROM, START_WITH, USER_1_ADDRESS.substring(0, 2))
+        );
+
+        FakeMail mail = testSystem.asMail(mimeMessageBuilder()
+            .addFrom(USER_1_FULL_ADDRESS));
+        testSystem.getJmapFiltering().service(mail);
+
+        
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME)).isNotEmpty();
+    }
+
+    @Test
+    void startWithAddressMailNotMatched(JMAPFilteringTestSystem testSystem) 
throws Exception {
+        testSystem.defineRulesForRecipient1(
+            Rule.Condition.of(FROM, START_WITH, "abcdef")
+        );
+
+        FakeMail mail = testSystem.asMail(mimeMessageBuilder()
+            .addFrom(USER_1_FULL_ADDRESS));
+        testSystem.getJmapFiltering().service(mail);
+
+        
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME)).isEmpty();
+    }
+
+    @Test
+    void startWithSubjectMatched(JMAPFilteringTestSystem testSystem) throws 
Exception {
+        testSystem.defineRulesForRecipient1(
+            Rule.Condition.of(SUBJECT, START_WITH, 
SCRAMBLED_SUBJECT.substring(0, 2))
+        );
+
+        FakeMail mail = testSystem.asMail(mimeMessageBuilder()
+            .addHeader(SUBJECT.asString(), SCRAMBLED_SUBJECT));
+        testSystem.getJmapFiltering().service(mail);
+
+        
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME)).isNotEmpty();
+    }
+
+    @Test
+    void startWithSubjectNotMatched(JMAPFilteringTestSystem testSystem) throws 
Exception {
+        testSystem.defineRulesForRecipient1(
+            Rule.Condition.of(SUBJECT, START_WITH, "abcdef")
+        );
+
+        FakeMail mail = testSystem.asMail(mimeMessageBuilder()
+            .addHeader(SUBJECT.asString(), SCRAMBLED_SUBJECT));
+        testSystem.getJmapFiltering().service(mail);
+
+        
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME)).isEmpty();
+    }
 }
\ No newline at end of file


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

Reply via email to