Search in sources :

Example 26 with ItemIdentifier

use of com.zimbra.common.mailbox.ItemIdentifier in project zm-mailbox by Zimbra.

the class TestRemoteImapMailboxStore method testOpenImapFolder.

@Test
public void testOpenImapFolder() throws Exception {
    Mailbox mbox = TestUtil.getMailbox(USER_NAME);
    Folder folder = mbox.createFolder(null, "TestOpenImapFolder", new Folder.FolderOptions().setDefaultView(MailItem.Type.MESSAGE));
    int folderId = folder.getId();
    List<ImapMessage> expected = new LinkedList<ImapMessage>();
    for (int i = 1; i <= 3; i++) {
        Message msg = TestUtil.addMessage(mbox, folderId, String.format("imap message %s", i), System.currentTimeMillis());
        expected.add(new ImapMessage(msg));
    }
    ZMailbox zmbox = TestUtil.getZMailbox(USER_NAME);
    RemoteImapMailboxStore remoteStore = new RemoteImapMailboxStore(zmbox, TestUtil.getAccount(USER_NAME).getId());
    List<ImapMessage> actual = remoteStore.openImapFolder(null, new ItemIdentifier(mbox.getAccountId(), folderId));
    Collections.sort(expected);
    Collections.sort(actual);
    assertEquals("expected and actual ImapMessage lists have different lengths", expected.size(), actual.size());
    for (int i = 0; i < expected.size(); i++) {
        assertEquals(expected.get(i), actual.get(i));
    }
}
Also used : ItemIdentifier(com.zimbra.common.mailbox.ItemIdentifier) ZMailbox(com.zimbra.client.ZMailbox) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZMailbox(com.zimbra.client.ZMailbox) ImapMessage(com.zimbra.cs.imap.ImapMessage) Message(com.zimbra.cs.mailbox.Message) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) ImapMessage(com.zimbra.cs.imap.ImapMessage) RemoteImapMailboxStore(com.zimbra.cs.imap.RemoteImapMailboxStore) Folder(com.zimbra.cs.mailbox.Folder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ItemIdentifier (com.zimbra.common.mailbox.ItemIdentifier)26 ZMailbox (com.zimbra.client.ZMailbox)12 Mailbox (com.zimbra.cs.mailbox.Mailbox)12 Test (org.junit.Test)11 ZMessage (com.zimbra.client.ZMessage)6 ServiceException (com.zimbra.common.service.ServiceException)6 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)6 ArrayList (java.util.ArrayList)6 ZMountpoint (com.zimbra.client.ZMountpoint)5 MailboxStore (com.zimbra.common.mailbox.MailboxStore)5 ImapMessage (com.zimbra.cs.imap.ImapMessage)5 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)5 Message (com.zimbra.cs.mailbox.Message)5 ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)4 ZimbraMailItem (com.zimbra.common.mailbox.ZimbraMailItem)4 Folder (com.zimbra.cs.mailbox.Folder)4 ZContact (com.zimbra.client.ZContact)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Contact (com.zimbra.cs.mailbox.Contact)3 OperationContext (com.zimbra.cs.mailbox.OperationContext)3