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 getMessageListShouldFilterMessagesWhenInMailboxesFilterDoesntMatches() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "emptyMailbox");
    MailboxId emptyMailboxId = mailboxProbe
            .getMailbox(MailboxConstants.USER_NAMESPACE, username, "emptyMailbox").getMailboxId();

    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());
    await();/*from  w  ww  . j a  va  2s  .  c  o m*/

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

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

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateDefault() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from  ww  w . j a va  2  s.  co  m

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

From source file:org.apache.james.mailbox.store.mail.model.MessageIdMapperTest.java

private SimpleMailboxMessage createMessage(Mailbox mailbox, String content, int bodyStart,
        PropertyBuilder propertyBuilder) {
    return new SimpleMailboxMessage(mapperProvider.generateMessageId(), new Date(), content.length(), bodyStart,
            new SharedByteArrayInputStream(content.getBytes()), new Flags(), propertyBuilder,
            mailbox.getMailboxId());// w w w  .  ja v  a 2  s.  c o m
}

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

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from   w w w . j  a  va 2 s .co  m

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

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

@Test
public void getMessageListShouldSupportIdSorting() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from   w  w w  .jav  a 2s .c  o  m*/

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

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

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateDesc() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from  www  .  jav a2  s.c o m*/

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

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

@Test
public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from  w  w  w. j  a v a 2  s  .com

    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 getMessageListShouldReturnSkipMessagesWhenPositionIsGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();// w  w  w  . j  a  v a 2  s  .c om

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

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

@Test
public void getMessageListShouldReturnSkipMessagesWhenPositionAndLimitGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(2)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from   w  w  w  . j  a  v a2 s .c o m*/

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"position\":1, \"limit\":1, \"sort\":[\"date desc\"]}, \"#0\"]]")
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize()));
}

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

@Test
public void getMessageListShouldReturnAllMessagesWhenLimitIsNotGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from w  w w .j  a  v a2  s  . com*/

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