hungphan227 commented on code in PR #1643:
URL: https://github.com/apache/james-project/pull/1643#discussion_r1264811514
##########
server/protocols/jmap-draft/src/test/java/org/apache/james/jmap/mailet/filter/JMAPFilteringTest.java:
##########
@@ -1057,4 +1059,79 @@ void actionShouldCombineFlags(JMAPFilteringTestSystem
testSystem) throws Excepti
assertThat(StorageDirective.fromMail(Username.of("recipient1"),
mail).getFlags().get())
.isEqualTo(expectedFlags);
}
+
+ @Test
+ void shouldMatchRuleOfAndConditionCombiner(JMAPFilteringTestSystem
testSystem) throws Exception {
+
Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Optional.empty(),
+ Rule.builder()
+ .id(Rule.Id.of("1"))
+ .name("rule 1")
+
.conditionGroup(Rule.ConditionGroup.of(Rule.ConditionCombiner.AND,
Rule.Condition.of(FROM, CONTAINS, USER_2_USERNAME), Rule.Condition.of(SUBJECT,
CONTAINS, "cd")))
+
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(testSystem.getRecipient1MailboxId().serialize()),
+ false, false, false, ImmutableList.of()))
+ .build())).block();
+
+ FakeMail mail =
testSystem.asMail(mimeMessageBuilder().addHeader(FROM.asString(),
USER_2_ADDRESS).addHeader(SUBJECT.asString(), "abcdef"));
+
+ testSystem.getJmapFiltering().service(mail);
+
+
assertThatAttribute(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME))
+ .isEqualTo(RECIPIENT_1_MAILBOX_1_ATTRIBUTE);
+ }
+
+ @Test
+ void shouldNotMatchRuleOfAndConditionCombiner(JMAPFilteringTestSystem
testSystem) throws Exception {
+
Mono.from(testSystem.getFilteringManagement().defineRulesForUser(RECIPIENT_1_USERNAME,
+ Optional.empty(),
+ Rule.builder()
+ .id(Rule.Id.of("1"))
+ .name("rule 1")
+
.conditionGroup(Rule.ConditionGroup.of(Rule.ConditionCombiner.AND,
Rule.Condition.of(FROM, CONTAINS, USER_2_USERNAME), Rule.Condition.of(SUBJECT,
CONTAINS, "cdf")))
+
.action(Rule.Action.of(Rule.Action.AppendInMailboxes.withMailboxIds(testSystem.getRecipient1MailboxId().serialize()),
+ false, false, false, ImmutableList.of()))
+ .build())).block();
+
+ FakeMail mail =
testSystem.asMail(mimeMessageBuilder().addHeader(FROM.asString(),
USER_2_ADDRESS).addHeader(SUBJECT.asString(), "abcdef"));
+ testSystem.getJmapFiltering().service(mail);
+
+
assertThat(mail.getAttribute(RECIPIENT_1_USERNAME_ATTRIBUTE_NAME).isEmpty()).isTrue();
+ }
+
+ @Test
+ void shouldMatchRuleOfOrConditionCombiner(JMAPFilteringTestSystem
testSystem) throws Exception {
Review Comment:
orShouldMatchWhenSomeConditionsAreMet
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]