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);
}
Aggregations