Search in sources :

Example 1 with FromTerm

use of jakarta.mail.search.FromTerm in project spring-integration by spring-projects.

the class ImapMailReceiverTests method testIdleWithServerCustomSearch.

@Test
public void testIdleWithServerCustomSearch() throws Exception {
    ImapMailReceiver receiver = new ImapMailReceiver("imap://user:pw@localhost:" + this.imapIdleServer.getImap().getPort() + "/INBOX");
    receiver.setSearchTermStrategy((supportedFlags, folder) -> {
        try {
            FromTerm fromTerm = new FromTerm(new InternetAddress("bar@baz"));
            return new AndTerm(fromTerm, new FlagTerm(new Flags(Flag.SEEN), false));
        } catch (AddressException e) {
            throw new RuntimeException(e);
        }
    });
    testIdleWithServerGuts(receiver, false);
}
Also used : AndTerm(jakarta.mail.search.AndTerm) InternetAddress(jakarta.mail.internet.InternetAddress) FlagTerm(jakarta.mail.search.FlagTerm) AddressException(jakarta.mail.internet.AddressException) Flags(jakarta.mail.Flags) FromTerm(jakarta.mail.search.FromTerm) Test(org.junit.jupiter.api.Test) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Aggregations

ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)1 Flags (jakarta.mail.Flags)1 AddressException (jakarta.mail.internet.AddressException)1 InternetAddress (jakarta.mail.internet.InternetAddress)1 AndTerm (jakarta.mail.search.AndTerm)1 FlagTerm (jakarta.mail.search.FlagTerm)1 FromTerm (jakarta.mail.search.FromTerm)1 Test (org.junit.jupiter.api.Test)1