Search in sources :

Example 6 with Atom

use of com.zimbra.cs.mailclient.imap.Atom in project zm-mailbox by Zimbra.

the class SharedImapNotificationTests method testDeleteTagNotificationCachedFolder.

@Test
public void testDeleteTagNotificationCachedFolder() throws Exception {
    String folderName1 = "TestRemoteImapNotifications-folder";
    String folderName2 = "TestRemoteImapNotifications-folder2";
    String tagName = "TestRemoteImapNotifications-tag";
    String subject = "TestRemoteImapNotifications-testMessage";
    ZMailbox zmbox = TestUtil.getZMailbox(USER);
    ZFolder folder = TestUtil.createFolder(zmbox, folderName1);
    TestUtil.createFolder(zmbox, folderName2);
    ZTag tag = zmbox.createTag(tagName, Color.blue);
    zmbox.addMessage(folder.getId(), null, tag.getId(), 0, TestUtil.getTestMessage(subject), true);
    connection = connect();
    connection.login(PASS);
    MailboxInfo info = connection.select(folderName1);
    Flags flags = info.getPermanentFlags();
    assertTrue("folder info should list tag", flags.contains(new Atom(tagName)));
    Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
    Flags msgFlags = mdMap.get(1L).getFlags();
    assertTrue("message should be flagged with tag", msgFlags.contains(new Atom(tagName)));
    connection.select(folderName2);
    MailboxOperation deleteTag = new MailboxOperation() {

        @Override
        protected void run(ZMailbox zmbox) throws Exception {
            zmbox.deleteTag(tag.getId());
        }

        @Override
        protected String checkResult() throws Exception {
            MailboxInfo info = connection.select(folderName1);
            Flags flags = info.getPermanentFlags();
            if (flags.contains(new Atom(tagName))) {
                return String.format("folder info should not list tag %s", tagName);
            }
            Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
            Flags msgFlags = mdMap.get(1L).getFlags();
            if (msgFlags.contains(new Atom(tagName))) {
                return String.format("message should not be flagged with %s", tagName);
            }
            return null;
        }
    };
    runOp(deleteTag, zmbox, folder);
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) MessageData(com.zimbra.cs.mailclient.imap.MessageData) ZFolder(com.zimbra.client.ZFolder) ZTag(com.zimbra.client.ZTag) MailboxInfo(com.zimbra.cs.mailclient.imap.MailboxInfo) Flags(com.zimbra.cs.mailclient.imap.Flags) Atom(com.zimbra.cs.mailclient.imap.Atom) Test(org.junit.Test)

Aggregations

ZFolder (com.zimbra.client.ZFolder)6 ZMailbox (com.zimbra.client.ZMailbox)6 ZTag (com.zimbra.client.ZTag)6 Atom (com.zimbra.cs.mailclient.imap.Atom)6 Flags (com.zimbra.cs.mailclient.imap.Flags)6 Test (org.junit.Test)6 MailboxInfo (com.zimbra.cs.mailclient.imap.MailboxInfo)4 MessageData (com.zimbra.cs.mailclient.imap.MessageData)4