Example usage for org.springframework.integration.mail ImapMailReceiver setSearchTermStrategy

List of usage examples for org.springframework.integration.mail ImapMailReceiver setSearchTermStrategy

Introduction

In this page you can find the example usage for org.springframework.integration.mail ImapMailReceiver setSearchTermStrategy.

Prototype

public void setSearchTermStrategy(SearchTermStrategy searchTermStrategy) 

Source Link

Document

Provides a way to set custom SearchTermStrategy to compile a SearchTerm to be applied when retrieving mail

Usage

From source file:org.springframework.integration.mail.ImapMailReceiverTests.java

@Test
public void testIdleWithServerCustomSearch() throws Exception {
    ImapMailReceiver receiver = new ImapMailReceiver(
            "imap://user:pw@localhost:" + imapIdleServer.getPort() + "/INBOX");
    receiver.setSearchTermStrategy((supportedFlags, folder) -> {
        try {//from www .jav a2 s .  com
            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);
}