Example usage for javax.mail Flags Flags

List of usage examples for javax.mail Flags Flags

Introduction

In this page you can find the example usage for javax.mail Flags Flags.

Prototype

public Flags() 

Source Link

Document

Construct an empty Flags object.

Usage

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnAllMessagesWhenMultipleMailboxesAndNoParameters() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    await();//  w  w w.  j a  va  2  s.c o  m

    given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when()
            .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(),
                    message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnAllMessagesOfCurrentUserOnlyWhenMultipleMailboxesAndNoParameters()
        throws Exception {
    String otherUser = "other@" + domain;
    String password = "password";
    dataProbe.addUser(otherUser, password);

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    await();//from w ww  .j  a va  2s .  c  o m

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox");
    mailboxProbe.appendMessage(otherUser,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, otherUser, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    await();

    given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when()
            .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(),
                    message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    await();//from www. ja  v  a  2  s . c o m

    MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox")
            .getMailboxId();

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId.serialize()
                    + "\"]}}, \"#0\"]]")
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatches() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    await();//from ww  w. java2 s  .c om

    MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox")
            .getMailboxId();
    MailboxId mailboxId2 = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2")
            .getMailboxId();

    given().header("Authorization", accessToken.serialize())
            .body(String.format(
                    "[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]",
                    mailboxId.serialize(), mailboxId2.serialize()))
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatches() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox")
            .getMailboxId();/*from ww w  .  j  a  va 2 s . c o  m*/

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    await();

    given().header("Authorization", accessToken.serialize())
            .body(String.format("[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[\"%s\"]}}, \"#0\"]]",
                    mailboxId.serialize()))
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", empty());
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldFilterMessagesWhenNotInMailboxesFilterMatchesTwice() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox")
            .getMailboxId();//from ww w .  j  av a2s. co m

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    MailboxId mailbox2Id = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2")
            .getMailboxId();
    await();

    given().header("Authorization", accessToken.serialize())
            .body(String.format(
                    "[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]",
                    mailboxId.serialize(), mailbox2Id.serialize()))
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", empty());
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldFilterMessagesWhenIdenticalNotInMailboxesAndInmailboxesFilterMatch()
        throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());
    MailboxId mailboxId = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox")
            .getMailboxId();//ww w .  ja va2s. c  o m
    await();

    given().header("Authorization", accessToken.serialize()).body(String.format(
            "[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[\"%s\"], \"inMailboxes\":[\"%s\"]}}, \"#0\"]]",
            mailboxId.serialize(), mailboxId.serialize())).when().post("/jmap").then().statusCode(200)
            .body(NAME, equalTo("messageList")).body(ARGUMENTS + ".messageIds", empty());
}

From source file:org.alfresco.repo.imap.ImapServiceImpl.java

/**
 * Return flags that belong to the specified imap folder.
 * //from w ww.  j  a v  a 2s . c om
 * @param messageInfo imap folder info.
 * @return flags.
 */
public Flags getFlags(FileInfo messageInfo) {
    Flags flags = new Flags();
    Map<QName, Serializable> props = nodeService.getProperties(messageInfo.getNodeRef());

    for (QName key : qNameToFlag.keySet()) {
        Boolean value = (Boolean) props.get(key);
        if (value != null && value) {
            flags.add(qNameToFlag.get(key));
        }
    }

    return flags;
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldNotFilterMessagesWhenNotInMailboxesFilterDoesNotMatch() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    MailboxId mailbox2Id = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2")
            .getMailboxId();//from  w w  w .  j a v a2 s.c o m
    await();

    given().header("Authorization", accessToken.serialize())
            .body(String.format("[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[\"%s\"]}}, \"#0\"]]",
                    mailbox2Id.serialize()))
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldNotFilterMessagesWhenEmptyNotInMailboxesFilter() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false,
            new Flags());

    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    await();/*from   w  w w .j a  va2  s.  c  om*/

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[]}}, \"#0\"]]").when().post("/jmap")
            .then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize()));
}