Ejemplo n.º 1
0
  @Test
  public void testMoveFromAndToSubMailbox() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    String fromSubMailbox = "ANYMAILBOX.SUBMAILBOX";
    String toOtherSubMailbox = "ANYMAILBOX.SUBMAILBOX.SUBSUBMAILBOX";
    testUtils.createFolders(fromSubMailbox, toOtherSubMailbox);

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(INBOX),
        testUtils.mailboxPath(fromSubMailbox),
        sentEmail.getUid());
    Email emailInSubMailbox = testUtils.emailInMailbox(fromSubMailbox);

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(fromSubMailbox),
        testUtils.mailboxPath(toOtherSubMailbox),
        emailInSubMailbox.getUid());

    Set<Email> fromEmails = testUtils.mailboxEmails(fromSubMailbox);
    Set<Email> movedEmails = testUtils.mailboxEmails(toOtherSubMailbox);
    Assertions.assertThat(fromEmails).isEmpty();
    Assertions.assertThat(movedEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(movedEmails);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }
Ejemplo n.º 2
0
  @Test(expected = CollectionNotFoundException.class)
  public void testMoveToNonExistingMailbox() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    String toNonExistingMailbox = "NONEXISTING_BOX";

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(INBOX),
        testUtils.mailboxPath(toNonExistingMailbox),
        sentEmail.getUid());
  }
Ejemplo n.º 3
0
  @Test
  public void testGreenmailServerImplementUIDPLUS() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    testUtils.createFolders(DRAFT);

    long testErrorUidValue = -1;
    long movedEmailUid = testErrorUidValue;
    try {
      movedEmailUid =
          mailboxService.moveItem(
              udr, testUtils.mailboxPath(INBOX), testUtils.mailboxPath(DRAFT), sentEmail.getUid());
    } catch (Exception nonExpectedException) {
      Assert.fail("Greenmail should implement UIDPLUS, so no exception is expected");
    }

    Set<Email> movedEmails = testUtils.mailboxEmails(DRAFT);
    Assertions.assertThat(movedEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(movedEmails);
    Assertions.assertThat(movedEmail.getUid())
        .isNotEqualTo(testErrorUidValue)
        .isEqualTo(movedEmailUid);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }
Ejemplo n.º 4
0
  @Ignore("Greenmail replied that the command succeed")
  @Test(expected = ImapMessageNotFoundException.class)
  public void testMovingNonExistingEmailTriggersException() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();
    Long nonExistingEmail = sentEmail.getUid() + 1;

    String toMoveEmailMailbox = "ANYBOX";
    testUtils.createFolders(toMoveEmailMailbox);

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(INBOX),
        testUtils.mailboxPath(toMoveEmailMailbox),
        nonExistingEmail);
  }
Ejemplo n.º 5
0
  @Test
  public void testMoveToInbox() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    mailboxService.moveItem(
        udr, testUtils.mailboxPath(INBOX), testUtils.mailboxPath(INBOX), sentEmail.getUid());

    Set<Email> inboxEmails = testUtils.mailboxEmails(INBOX);
    Assertions.assertThat(inboxEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(inboxEmails);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }