Search in sources :

Example 1 with NotTerm

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);
}
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 2 with NotTerm

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);
    }
}
Also used : NotTerm(javax.mail.search.NotTerm)

Example 3 with NotTerm

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;
}
Also used : NotTerm(javax.mail.search.NotTerm) SearchTerm(javax.mail.search.SearchTerm)

Example 4 with NotTerm

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);
}
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)

Aggregations

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