use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImap method testMailfoldersOnlyList.
@Test
public void testMailfoldersOnlyList() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER);
String folderName = "newfolder1";
ZFolder folder = mbox.createFolder(Mailbox.ID_FOLDER_USER_ROOT + "", folderName, ZFolder.View.unknown, ZFolder.Color.DEFAULTCOLOR, null, null);
Provisioning.getInstance().getLocalServer().setImapDisplayMailFoldersOnly(true);
List<ListData> listResult = connection.list("", "*");
assertNotNull(listResult);
assertTrue("List result should have atleast 5 entries", listResult.size() >= 5);
boolean hasContacts = false;
boolean hasChats = false;
boolean hasEmailedContacts = false;
boolean hasTrash = false;
boolean hasDrafts = false;
boolean hasInbox = false;
boolean hasJunk = false;
boolean hasSent = false;
boolean hasUnknown = false;
for (ListData ld : listResult) {
if ((ld.getMailbox().equalsIgnoreCase("Contacts"))) {
hasContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Chats"))) {
hasChats = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Emailed Contacts"))) {
hasEmailedContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("newfolder1"))) {
hasUnknown = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Trash"))) {
hasTrash = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Drafts"))) {
hasDrafts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Inbox"))) {
hasInbox = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Sent"))) {
hasSent = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Junk"))) {
hasJunk = true;
}
}
assertFalse("MailonlyfolderList * contains chats", hasChats);
assertFalse("MailonlyfolderList * contains contacts", hasContacts);
assertFalse("MailonlyfolderList * contains emailed contacts", hasEmailedContacts);
assertTrue("MailonlyfolderList * contains Trash", hasTrash);
assertTrue("MailonlyfolderList * contains Drafts ", hasDrafts);
assertTrue("MailonlyfolderList * contains Inbox", hasInbox);
assertTrue("MailonlyfolderList * contains Sent", hasSent);
assertTrue("MailonlyfolderList * contains Junk", hasJunk);
assertTrue("MailonlyfolderList * contains unknown sub folders", hasUnknown);
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImap method testFoldersList.
@Test
public void testFoldersList() throws Exception {
List<ListData> listResult = connection.list("", "*");
assertNotNull(listResult);
assertTrue("List result should have atleast 5 entries", listResult.size() >= 5);
boolean hasContacts = false;
boolean hasChats = false;
boolean hasEmailedContacts = false;
boolean hasTrash = false;
boolean hasDrafts = false;
boolean hasInbox = false;
boolean hasJunk = false;
boolean hasSent = false;
for (ListData ld : listResult) {
if ((ld.getMailbox().equalsIgnoreCase("Contacts"))) {
hasContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Chats"))) {
hasChats = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Emailed Contacts"))) {
hasEmailedContacts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Trash"))) {
hasTrash = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Drafts"))) {
hasDrafts = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Inbox"))) {
hasInbox = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Sent"))) {
hasSent = true;
} else if ((ld.getMailbox().equalsIgnoreCase("Junk"))) {
hasJunk = true;
}
}
assertTrue("folderList * contains chats", hasChats);
assertTrue("folderList * contains contacts", hasContacts);
assertTrue("folderList * contains emailed contacts", hasEmailedContacts);
assertTrue("folderList * contains Trash", hasTrash);
assertTrue("folderList * contains Drafts ", hasDrafts);
assertTrue("folderList * contains Inbox", hasInbox);
assertTrue("folderList * contains Sent", hasSent);
assertTrue("folderList * contains Junk", hasJunk);
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class TestImap method testListContacts.
@Test
public void testListContacts() throws Exception {
List<ListData> listResult = connection.list("", "*Contacts*");
assertNotNull(listResult);
// 'Contacts' and 'Emailed Contacts'
assertTrue("List result should have at least 2 entries", listResult.size() >= 2);
for (ListData le : listResult) {
assertTrue(String.format("mailbox '%s' contains 'Contacts'", le.getMailbox()), le.getMailbox().contains("Contacts"));
}
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class ImapUtilTest method testSortFolders.
@Test
public void testSortFolders() {
List<ListData> result = ImapUtil.sortFolders(this.folders);
// dup of "INBOX"
Assert.assertEquals(result.size(), this.folders.size() - 1);
this.folders.add(new ListData("INbox/t/a", '/'));
this.folders.add(new ListData("INBox/t/a", '/'));
result = ImapUtil.sortFolders(this.folders);
Assert.assertEquals(result.size(), this.folders.size() - 1);
folders.add(new ListData("INBox/T/a", '/'));
folders.add(new ListData("INBox/T/A", '/'));
result = ImapUtil.sortFolders(this.folders);
Assert.assertEquals(result.size(), this.folders.size() - 1);
}
use of com.zimbra.cs.mailclient.imap.ListData in project zm-mailbox by Zimbra.
the class ImapUtil method sortFolders.
public static List<ListData> sortFolders(List<ListData> folders) {
// Keep INBOX and inferiors separate so we can return them first
ListData inbox = null;
ListData defaultInbox = null;
List<ListData> inboxInferiors = new ArrayList<ListData>();
List<ListData> otherFolders = new ArrayList<ListData>();
for (ListData ld : folders) {
if (INBOX.equalsIgnoreCase(ld.getMailbox())) {
// rfc3501(5.1), INBOX is case-insensitive
if (inbox == null) {
// Ignore duplicate INBOX (fixes bug 26483)
inbox = ld;
}
} else if (isInboxInferior(ld)) {
inboxInferiors.add(ld);
if (defaultInbox == null) {
defaultInbox = new ListData(INBOX, ld.getDelimiter());
}
} else {
otherFolders.add(ld);
}
}
List<ListData> sorted = new ArrayList<ListData>(folders.size());
if (inbox == null) {
// If INBOX missing from LIST response, then see if we can
// determine a reasonable default (bug 30844).
inbox = defaultInbox;
}
if (inbox != null) {
sorted.add(inbox);
}
Collections.sort(inboxInferiors, COMPARATOR);
sorted.addAll(inboxInferiors);
Collections.sort(otherFolders, COMPARATOR);
sorted.addAll(otherFolders);
return sorted;
}
Aggregations