use of javax.mail.search.NotTerm in project jodd by oblac.
the class EmailFilterTest method testAndOrNotAlt.
@Test
public void testAndOrNotAlt() {
EmailFilter emailFilter = filter().or(filter().and(filter().from("from"), filter().to("to")), filter().not(filter().subject("subject")), filter().from("from2"));
SearchTerm expected = new OrTerm(new SearchTerm[] { new AndTerm(new FromStringTerm("from"), new RecipientStringTerm(Message.RecipientType.TO, "to")), new NotTerm(new SubjectTerm("subject")), new FromStringTerm("from2") });
assertEquals(expected, emailFilter.searchTerm);
}
use of javax.mail.search.NotTerm in project jodd by oblac.
the class EmailFilter method concat.
// ---------------------------------------------------------------- concat
/**
* Concatenates last search term with new one.
*/
protected void concat(SearchTerm searchTerm) {
if (nextIsNot) {
searchTerm = new NotTerm(searchTerm);
nextIsNot = false;
}
if (operatorAnd) {
and(searchTerm);
} else {
or(searchTerm);
}
}
use of javax.mail.search.NotTerm in project jodd by oblac.
the class EmailFilter method not.
/**
* Appends single filter as NOT.
*/
public EmailFilter not(EmailFilter emailFilter) {
SearchTerm searchTerm = new NotTerm(emailFilter.searchTerm);
concat(searchTerm);
return this;
}
use of javax.mail.search.NotTerm in project jodd by oblac.
the class EmailFilterTest method testAndOrNot.
@Test
public void testAndOrNot() {
EmailFilter emailFilter = filter().from("from").to("to").or().not().subject("subject").from("from2");
SearchTerm expected = new OrTerm(new OrTerm(new AndTerm(new FromStringTerm("from"), new RecipientStringTerm(Message.RecipientType.TO, "to")), new NotTerm(new SubjectTerm("subject"))), new FromStringTerm("from2"));
assertEquals(expected, emailFilter.searchTerm);
}
Aggregations