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