Search in sources :

Example 1 with Atom

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

the class SharedImapNotificationTests method testDeleteTagNotificationActiveFolder.

@Test
public void testDeleteTagNotificationActiveFolder() throws Exception {
    String folderName = "TestRemoteImapNotifications-folder";
    String tagName = "TestRemoteImapNotifications-tag";
    String subject = "TestRemoteImapNotifications-testMessage";
    ZMailbox zmbox = TestUtil.getZMailbox(USER);
    ZFolder folder = TestUtil.createFolder(zmbox, folderName);
    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(folderName);
    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)));
    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(folderName);
            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)

Example 2 with Atom

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

the class SharedImapNotificationTests method testModifyItemNotificationCachedFolder.

@Test
public void testModifyItemNotificationCachedFolder() throws Exception {
    String folderName1 = "testNotificationsActiveFolder-folder1";
    String folderName2 = "testNotificationsActiveFolder-folder2";
    String subject = "testNotificationsActiveFolder-msg1";
    String tagName = "testNotificationsActiveFolder-tag";
    ZMailbox zmbox = TestUtil.getZMailbox(USER);
    ZFolder folder = TestUtil.createFolder(zmbox, folderName1);
    TestUtil.createFolder(zmbox, folderName2);
    ZTag tag = zmbox.createTag(tagName, Color.blue);
    String msgId = TestUtil.addMessage(zmbox, subject, folder.getId(), null);
    connection = connect();
    connection.login(PASS);
    connection.select(folderName1);
    Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
    assertEquals("Size of map returned by fetch 1", 1, mdMap.size());
    // sanity check - make sure the tag is not already set on the message
    Flags flags = mdMap.get(1L).getFlags();
    assertFalse(flags.contains(new Atom(tag.getName())));
    connection.select(folderName2);
    MailboxOperation tagMessage = new MailboxOperation() {

        @Override
        protected void run(ZMailbox zmbox) throws Exception {
            zmbox.tagMessage(msgId, tag.getId(), true);
        }

        @Override
        protected String checkResult() throws Exception {
            connection.select(folderName1);
            Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
            if (mdMap.size() != 1) {
                return String.format("Size of map returned by fetch should be 1. Found: %d", mdMap.size());
            }
            Flags flags = mdMap.get(1L).getFlags();
            if (!flags.contains(new Atom(tag.getName()))) {
                return String.format("Flags should contain %s", tag.getName());
            }
            return null;
        }
    };
    runOp(tagMessage, 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) Flags(com.zimbra.cs.mailclient.imap.Flags) Atom(com.zimbra.cs.mailclient.imap.Atom) Test(org.junit.Test)

Example 3 with Atom

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

the class SharedImapNotificationTests method testRenameTagNotificationActiveFolder.

@Test
public void testRenameTagNotificationActiveFolder() throws Exception {
    String folderName = "TestRemoteImapNotifications-folder";
    String tagName = "TestRemoteImapNotifications-tag";
    String newTagName = "TestRemoteImapNotifications-tag2";
    String subject = "TestRemoteImapNotifications-testMessage";
    ZMailbox zmbox = TestUtil.getZMailbox(USER);
    ZFolder folder = TestUtil.createFolder(zmbox, folderName);
    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(folderName);
    Flags flags = info.getPermanentFlags();
    assertTrue(flags.contains(new Atom(tagName)));
    MailboxOperation renameTag = new MailboxOperation() {

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

        @Override
        protected String checkResult() throws Exception {
            MailboxInfo info = connection.select(folderName);
            Flags flags = info.getPermanentFlags();
            if (flags.contains(new Atom(tagName))) {
                return String.format("Permanent flags should not contain %s", tagName);
            }
            if (!flags.contains(new Atom(newTagName))) {
                return String.format("Permanent flags should contain %s", newTagName);
            }
            return null;
        }
    };
    runOp(renameTag, zmbox, folder);
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) 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)

Example 4 with Atom

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

the class SharedImapNotificationTests method testRenameTagNotificationCachedFolder.

@Test
public void testRenameTagNotificationCachedFolder() throws Exception {
    String folderName1 = "TestRemoteImapNotifications-folder1";
    String folderName2 = "TestRemoteImapNotifications-folder2";
    String tagName = "TestRemoteImapNotifications-tag";
    String newTagName = "TestRemoteImapNotifications-tag2";
    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(flags.contains(new Atom(tagName)));
    info = connection.select(folderName2);
    MailboxOperation renameTag = new MailboxOperation() {

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

        @Override
        protected String checkResult() throws Exception {
            MailboxInfo info = connection.select(folderName1);
            Flags flags = info.getPermanentFlags();
            if (flags.contains(new Atom(tagName))) {
                return String.format("Flags should NOT contain %s", tagName);
            }
            if (!flags.contains(new Atom(newTagName))) {
                return String.format("Flags should contain %s", newTagName);
            }
            return null;
        }
    };
    runOp(renameTag, zmbox, folder);
}
Also used : ZMailbox(com.zimbra.client.ZMailbox) 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)

Example 5 with Atom

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

the class SharedImapNotificationTests method testModifyItemNotificationActiveFolder.

@Test
public void testModifyItemNotificationActiveFolder() throws Exception {
    String folderName = "testNotificationsActiveFolder-folder";
    String subject = "testNotificationsActiveFolder-msg1";
    String tagName = "testNotificationsActiveFolder-tag";
    ZMailbox zmbox = TestUtil.getZMailbox(USER);
    ZFolder folder = TestUtil.createFolder(zmbox, folderName);
    ZTag tag = zmbox.createTag(tagName, Color.blue);
    String msgId = TestUtil.addMessage(zmbox, subject, folder.getId(), null);
    connection = connect();
    connection.login(PASS);
    connection.select(folderName);
    Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
    assertEquals("Size of map returned by fetch 1", 1, mdMap.size());
    // sanity check - make sure the tag is not already set on the message
    Flags flags = mdMap.get(1L).getFlags();
    assertFalse(flags.contains(new Atom(tag.getName())));
    MailboxOperation tagMessage = new MailboxOperation() {

        @Override
        protected void run(ZMailbox zmbox) throws Exception {
            zmbox.tagMessage(msgId, tag.getId(), true);
        }

        @Override
        protected String checkResult() throws Exception {
            Map<Long, MessageData> mdMap = connection.fetch("1:*", "(FLAGS)");
            if (mdMap.size() != 1) {
                return String.format("Size of map returned by fetch should be 1. Getting %d", mdMap.size());
            }
            Flags flags = mdMap.get(1L).getFlags();
            if (!flags.contains(new Atom(tag.getName()))) {
                return String.format("Flags should contain %s", tag.getName());
            }
            return null;
        }
    };
    runOp(tagMessage, 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) 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