Search in sources :

Example 1 with FromStringTerm

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

the class EmailFilterTest method testAnd1.

@Test
public void testAnd1() {
    EmailFilter emailFilter = filter().from("from");
    SearchTerm expected = new FromStringTerm("from");
    assertEquals(expected, emailFilter.searchTerm);
}
Also used : FromStringTerm(javax.mail.search.FromStringTerm) SearchTerm(javax.mail.search.SearchTerm) Test(org.junit.Test)

Example 2 with FromStringTerm

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

the class EmailFilter method from.

/**
	 * Defines filter for FROM field.
	 */
public EmailFilter from(String fromAddress) {
    SearchTerm fromTerm = new FromStringTerm(fromAddress);
    concat(fromTerm);
    return this;
}
Also used : FromStringTerm(javax.mail.search.FromStringTerm) SearchTerm(javax.mail.search.SearchTerm)

Example 3 with FromStringTerm

use of javax.mail.search.FromStringTerm 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 4 with FromStringTerm

use of javax.mail.search.FromStringTerm 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 5 with FromStringTerm

use of javax.mail.search.FromStringTerm 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)

Aggregations

FromStringTerm (javax.mail.search.FromStringTerm)12 SearchTerm (javax.mail.search.SearchTerm)12 AndTerm (javax.mail.search.AndTerm)7 SubjectTerm (javax.mail.search.SubjectTerm)6 Test (org.junit.Test)6 RecipientStringTerm (javax.mail.search.RecipientStringTerm)5 OrTerm (javax.mail.search.OrTerm)4 URISyntaxException (java.net.URISyntaxException)3 DateFormat (java.text.DateFormat)3 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 InternetAddress (javax.mail.internet.InternetAddress)3 MimeMessage (javax.mail.internet.MimeMessage)3 NotTerm (javax.mail.search.NotTerm)2 LocalDateTime (java.time.LocalDateTime)1 ZonedDateTime (java.time.ZonedDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1