@Test void doBackupWithOneMessageShouldStoreAnArchiveWithTwoEntries() throws Exception { ByteArrayOutputStream destination = new ByteArrayOutputStream(BUFFER_SIZE); createMailboxWithMessages(sessionUser, MAILBOX_PATH_USER1_MAILBOX1, getMessage1AppendCommand()); backup.backupAccount(USERNAME_1, destination); try (ZipAssert zipAssert = ZipAssert.assertThatZip(destination)) { zipAssert.containsOnlyEntriesMatching( EntryChecks.hasName(MAILBOX_1_NAME + "/").isDirectory(), EntryChecks.hasName(MESSAGE_ID_1.serialize()).hasStringContent(MESSAGE_CONTENT_1) ); } }
@Override public void backupAccount(Username username, OutputStream destination) throws IOException, MailboxException { MailboxSession session = mailboxManager.createSystemSession(username); List<MailAccountContent> accountContents = getAccountContentForUser(session); List<MailboxWithAnnotations> mailboxes = accountContents.stream() .map(MailAccountContent::getMailboxWithAnnotations) .collect(Guavate.toImmutableList()); Stream<MessageResult> messages = allMessagesForUser(accountContents); archive(mailboxes, messages, destination); }
DefaultMailboxBackup implements MailboxBackup { @Override public void backupAccount(Username username, OutputStream destination) throws IOException, MailboxException { MailboxSession session = mailboxManager.createSystemSession(username); List<MailAccountContent> accountContents = getAccountContentForUser(session); List<MailboxWithAnnotations> mailboxes = accountContents.stream() .map(MailAccountContent::getMailboxWithAnnotations) .collect(Guavate.toImmutableList()); Stream<MessageResult> messages = allMessagesForUser(accountContents); archive(mailboxes, messages, destination); } }
DefaultMailboxBackup implements MailboxBackup { @Override public void backupAccount(Username username, OutputStream destination) throws IOException, MailboxException { MailboxSession session = mailboxManager.createSystemSession(username); List<MailAccountContent> accountContents = getAccountContentForUser(session); List<MailboxWithAnnotations> mailboxes = accountContents.stream() .map(MailAccountContent::getMailboxWithAnnotations) .collect(Guavate.toImmutableList()); Stream<MessageResult> messages = allMessagesForUser(accountContents); archive(mailboxes, messages, destination); } @Inject  DefaultMailboxBackup(MailboxManager mailboxManager, ArchiveService archiveService, MailArchiveRestorer archiveRestorer); }
DefaultMailboxBackup implements MailboxBackup { @Override public void backupAccount(Username username, OutputStream destination) throws IOException, MailboxException { MailboxSession session = mailboxManager.createSystemSession(username); List<MailAccountContent> accountContents = getAccountContentForUser(session); List<MailboxWithAnnotations> mailboxes = accountContents.stream() .map(MailAccountContent::getMailboxWithAnnotations) .collect(Guavate.toImmutableList()); Stream<MessageResult> messages = allMessagesForUser(accountContents); archive(mailboxes, messages, destination); } @Inject  DefaultMailboxBackup(MailboxManager mailboxManager, ArchiveService archiveService, MailArchiveRestorer archiveRestorer); @Override void backupAccount(Username username, OutputStream destination); @Override Publisher<BackupStatus> restore(Username username, InputStream source); }
DefaultMailboxBackup implements MailboxBackup { @Override public void backupAccount(Username username, OutputStream destination) throws IOException, MailboxException { MailboxSession session = mailboxManager.createSystemSession(username); List<MailAccountContent> accountContents = getAccountContentForUser(session); List<MailboxWithAnnotations> mailboxes = accountContents.stream() .map(MailAccountContent::getMailboxWithAnnotations) .collect(Guavate.toImmutableList()); Stream<MessageResult> messages = allMessagesForUser(accountContents); archive(mailboxes, messages, destination); } @Inject  DefaultMailboxBackup(MailboxManager mailboxManager, ArchiveService archiveService, MailArchiveRestorer archiveRestorer); @Override void backupAccount(Username username, OutputStream destination); @Override Publisher<BackupStatus> restore(Username username, InputStream source);  }