Search in sources :

Example 6 with RecipientStringTerm

use of javax.mail.search.RecipientStringTerm 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);
}
Also used : AndTerm(javax.mail.search.AndTerm) OrTerm(javax.mail.search.OrTerm) FromStringTerm(javax.mail.search.FromStringTerm) RecipientStringTerm(javax.mail.search.RecipientStringTerm) NotTerm(javax.mail.search.NotTerm) SearchTerm(javax.mail.search.SearchTerm) SubjectTerm(javax.mail.search.SubjectTerm) Test(org.junit.Test)

Example 7 with RecipientStringTerm

use of javax.mail.search.RecipientStringTerm in project jodd by oblac.

the class EmailFilterTest method testOr2.

@Test
public void testOr2() {
    EmailFilter emailFilter = filter().or(filter().from("from"), filter().to("to"));
    SearchTerm expected = new OrTerm(new FromStringTerm("from"), new RecipientStringTerm(Message.RecipientType.TO, "to"));
    assertEquals(expected, emailFilter.searchTerm);
}
Also used : OrTerm(javax.mail.search.OrTerm) FromStringTerm(javax.mail.search.FromStringTerm) RecipientStringTerm(javax.mail.search.RecipientStringTerm) SearchTerm(javax.mail.search.SearchTerm) Test(org.junit.Test)

Example 8 with RecipientStringTerm

use of javax.mail.search.RecipientStringTerm in project jodd by oblac.

the class EmailFilter method to.

/**
	 * Defines filter for TO field.
	 */
public EmailFilter to(String toAddress) {
    SearchTerm toTerm = new RecipientStringTerm(Message.RecipientType.TO, toAddress);
    concat(toTerm);
    return this;
}
Also used : RecipientStringTerm(javax.mail.search.RecipientStringTerm) SearchTerm(javax.mail.search.SearchTerm)

Example 9 with RecipientStringTerm

use of javax.mail.search.RecipientStringTerm in project camel by apache.

the class SearchTermBuilder method recipient.

public SearchTermBuilder recipient(Op op, Message.RecipientType type, String pattern) {
    SearchTerm st = new RecipientStringTerm(type, pattern);
    addTerm(op, st);
    return this;
}
Also used : RecipientStringTerm(javax.mail.search.RecipientStringTerm) SearchTerm(javax.mail.search.SearchTerm)

Aggregations

RecipientStringTerm (javax.mail.search.RecipientStringTerm)9 SearchTerm (javax.mail.search.SearchTerm)9 FromStringTerm (javax.mail.search.FromStringTerm)5 Test (org.junit.Test)5 OrTerm (javax.mail.search.OrTerm)4 AndTerm (javax.mail.search.AndTerm)3 NotTerm (javax.mail.search.NotTerm)2 SubjectTerm (javax.mail.search.SubjectTerm)2