Search in sources :

Example 1 with RecipientStringTerm

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

the class EmailFilterTest method testAnd2.

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

Example 2 with RecipientStringTerm

use of javax.mail.search.RecipientStringTerm 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);
}
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 3 with RecipientStringTerm

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

the class EmailFilterTest method testOr2Alt.

@Test
public void testOr2Alt() {
    EmailFilter emailFilter = filter().or().from("from").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 4 with RecipientStringTerm

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

the class EmailFilter method cc.

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

Example 5 with RecipientStringTerm

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

the class EmailFilter method bcc.

/**
	 * Defines filter for BCC field.
	 */
public EmailFilter bcc(String bccAddress) {
    SearchTerm toTerm = new RecipientStringTerm(Message.RecipientType.BCC, bccAddress);
    concat(toTerm);
    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