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.mailbox.elasticsearch.json.IndexableMessageTest.java

@Test
public void textShouldContainsCcWhenCc() throws Exception {
    MailboxMessage mailboxMessage = mock(MailboxMessage.class);
    TestId mailboxId = TestId.of(1);//from  ww w. java 2s  .  com
    when(mailboxMessage.getMailboxId()).thenReturn(mailboxId);
    when(mailboxMessage.getFullContent()).thenReturn(new ByteArrayInputStream(
            "Cc: First cc <user@james.org>\nCc: Second cc <user2@james.org>".getBytes()));
    when(mailboxMessage.createFlags()).thenReturn(new Flags());

    IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage,
            ImmutableList.of(new MockMailboxSession("username").getUser()), new DefaultTextExtractor(),
            ZoneId.of("Europe/Paris"));

    assertThat(indexableMessage.getText()).isEqualTo("First cc user@james.org Second cc user2@james.org");
}

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

@Given("^\"([^\"]*)\" mailbox \"([^\"]*)\" contains a message \"([^\"]*)\" with an attachment \"([^\"]*)\"$")
public void appendMessageWithAttachmentToMailbox(String user, String mailbox, String messageId,
        String attachmentId) throws Throwable {
    MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox);

    mainStepdefs.jmapServer.serverProbe().appendMessage(user, mailboxPath,
            ClassLoader.getSystemResourceAsStream("eml/oneAttachment.eml"), new Date(), false, new Flags());

    attachmentsByMessageId.put(messageId, attachmentId);
    blobIdByAttachmentId.put(attachmentId, "4000c5145f633410b80be368c44e1c394bff9437");
}

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

private static SimpleMailboxMessage buildMessage(String content) {
    return new SimpleMailboxMessage(Calendar.getInstance().getTime(), content.length(), BODY_START_OCTET,
            new SharedByteArrayInputStream(content.getBytes(MESSAGE_CHARSET)), new Flags(),
            new PropertyBuilder(), TEST_ID);
}

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

@Test
public void copyShouldReturnFieldByFieldEqualsObject() throws MailboxException {
    long textualLineCount = 42L;
    String text = "text";
    String plain = "plain";
    PropertyBuilder propertyBuilder = new PropertyBuilder();
    propertyBuilder.setTextualLineCount(textualLineCount);
    propertyBuilder.setMediaType(text);//from  w  w w.  j a  v a  2  s.c om
    propertyBuilder.setSubType(plain);
    SimpleMailboxMessage original = new SimpleMailboxMessage(new Date(), MESSAGE_CONTENT.length(),
            BODY_START_OCTET, new SharedByteArrayInputStream(MESSAGE_CONTENT.getBytes(MESSAGE_CHARSET)),
            new Flags(), propertyBuilder, TEST_ID);

    SimpleMailboxMessage copy = SimpleMailboxMessage.copy(TestId.of(1337), original);

    assertThat((Object) copy).isEqualToIgnoringGivenFields(original, "message", "mailboxId")
            .isNotSameAs(original);
    assertThat(copy.getMessage()).usingComparator(new FieldByFieldComparator())
            .isEqualTo(original.getMessage());
    assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getTextualLineCount()).isEqualTo(textualLineCount);
    assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getMediaType()).isEqualTo(text);
    assertThat(SimpleMailboxMessage.copy(TEST_ID, original).getSubType()).isEqualTo(plain);

}

From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java

@Test
public void spamEmailShouldBeWellConvertedToJson() throws IOException {
    MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
            new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES);
    MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID, date, SIZE, BODY_START_OCTET,
            new SharedByteArrayInputStream(
                    IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/spamMail.eml"))),
            new Flags(), propertyBuilder, MAILBOX_ID);
    spamMail.setUid(UID);// w  w  w  . ja v  a  2  s .c  o  m
    spamMail.setModSeq(MOD_SEQ);
    assertThatJson(messageToElasticSearchJson.convertToJson(spamMail,
            ImmutableList.of(new MockMailboxSession("username").getUser()))).when(IGNORING_ARRAY_ORDER)
                    .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/spamMail.json"), CHARSET));
}

From source file:org.apache.james.mailbox.cassandra.mail.CassandraMessageDAOTest.java

@BeforeEach
void setUp(CassandraCluster cassandra) {
    messageIdFactory = new CassandraMessageId.Factory();
    messageId = messageIdFactory.generate();
    CassandraBlobsDAO blobsDAO = new CassandraBlobsDAO(cassandra.getConf());
    HashBlobId.Factory blobIdFactory = new HashBlobId.Factory();
    testee = new CassandraMessageDAO(cassandra.getConf(), cassandra.getTypesProvider(), blobsDAO, blobIdFactory,
            CassandraUtils.WITH_DEFAULT_CONFIGURATION, new CassandraMessageId.Factory());

    messageIds = ImmutableList.of(ComposedMessageIdWithMetaData.builder()
            .composedMessageId(new ComposedMessageId(MAILBOX_ID, messageId, messageUid)).flags(new Flags())
            .modSeq(1).build());/*  ww  w  .  ja v a  2  s  . com*/
}

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

private void appendMessage(String mailbox, ContentType contentType, String subject, String content,
        Optional<Map<String, String>> headers) throws Exception {
    ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
    mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox),
            new ByteArrayInputStream(message(contentType, subject, content, headers).getBytes(Charsets.UTF_8)),
            Date.from(dateTime.toInstant()), false, new Flags());
}

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

@Given("^\"([^\"]*)\" mailbox \"([^\"]*)\" contains a message \"([^\"]*)\" with an inlined attachment \"([^\"]*)\"$")
public void appendMessageWithInlinedAttachmentToMailbox(String user, String mailbox, String messageId,
        String attachmentId) throws Throwable {
    MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, user, mailbox);

    mainStepdefs.jmapServer.serverProbe().appendMessage(user, mailboxPath,
            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(), false, new Flags());

    attachmentsByMessageId.put(messageId, attachmentId);
    // TODO//  ww  w . ja  v a 2s . c om
    //blobIdByAttachmentId.put(attachmentId, "<correctComputedBlobId>");
}

From source file:org.apache.james.mailbox.elasticsearch.json.IndexableMessageTest.java

@Test
public void textShouldContainsBccWhenBcc() throws Exception {
    MailboxMessage mailboxMessage = mock(MailboxMessage.class);
    TestId mailboxId = TestId.of(1);// www .  j  a  v a  2  s  .  co m
    when(mailboxMessage.getMailboxId()).thenReturn(mailboxId);
    when(mailboxMessage.getFullContent()).thenReturn(new ByteArrayInputStream(
            "Bcc: First bcc <user@james.org>\nBcc: Second bcc <user2@james.org>".getBytes()));
    when(mailboxMessage.createFlags()).thenReturn(new Flags());

    IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage,
            ImmutableList.of(new MockMailboxSession("username").getUser()), new DefaultTextExtractor(),
            ZoneId.of("Europe/Paris"));

    assertThat(indexableMessage.getText()).isEqualTo("Second bcc user2@james.org First bcc user@james.org");
}

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

@Test
public void getMessageListShouldNotDuplicateMessagesInSeveralMailboxes() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");
    Mailbox mailbox = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");
    Mailbox mailbox2 = mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2");

    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   w  ww . ja  v  a  2s .  c o  m*/

    jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(message.getMessageId(), username,
            mailbox.getMailboxId(), mailbox2.getMailboxId());

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