use of com.zimbra.cs.db.DbResults in project zm-mailbox by Zimbra.
the class FolderTest method emptyFolderNonrecursive.
/**
* Confirms that emptying a folder removes subfolders only when requested.
*/
@Test
public void emptyFolderNonrecursive() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Folder parent = mbox.createFolder(null, "/" + "parent", new Folder.FolderOptions());
int parentId = parent.getId();
Folder child = mbox.createFolder(null, "child", parent.getId(), new Folder.FolderOptions());
int childId = child.getId();
mbox.emptyFolder(null, parent.getId(), false);
// Look up parent by id
mbox.getFolderById(null, parentId);
// Look up parent by query
String sql = "SELECT id " + "FROM " + DbMailItem.getMailItemTableName(mbox) + " WHERE mailbox_id = " + mbox.getId() + " AND id = " + parentId;
DbResults results = DbUtil.executeQuery(sql);
Assert.assertEquals("Parent folder query returned no data. id=" + parentId, 1, results.size());
// Look up child by id
mbox.getFolderById(null, childId);
// Look up child by query
sql = "SELECT id " + "FROM " + DbMailItem.getMailItemTableName(mbox) + " WHERE mailbox_id = " + mbox.getId() + " AND id = " + childId;
results = DbUtil.executeQuery(sql);
Assert.assertEquals("Child folder query returned no data. id=" + childId, 1, results.size());
}
use of com.zimbra.cs.db.DbResults in project zm-mailbox by Zimbra.
the class FolderTest method deleteParent.
/**
* Confirms that deleting a parent folder also deletes the child.
*/
@Test
public void deleteParent() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Folder parent = mbox.createFolder(null, "/" + "deleteParent - parent", new Folder.FolderOptions());
int parentId = parent.getId();
Folder child = mbox.createFolder(null, "deleteParent - child", parent.getId(), new Folder.FolderOptions());
int childId = child.getId();
mbox.delete(null, parent.getId(), parent.getType());
// Look up parent by id
try {
mbox.getFolderById(null, parentId);
Assert.fail("Parent folder lookup by id should have not succeeded");
} catch (NoSuchItemException e) {
}
// Look up parent by query
String sql = "SELECT id " + "FROM " + DbMailItem.getMailItemTableName(mbox) + " WHERE mailbox_id = " + mbox.getId() + " AND id = " + parentId;
DbResults results = DbUtil.executeQuery(sql);
Assert.assertEquals("Parent folder query returned data. id=" + parentId, 0, results.size());
// Look up child by id
try {
mbox.getFolderById(null, childId);
Assert.fail("Child folder lookup by id should have not succeeded");
} catch (NoSuchItemException e) {
}
// Look up child by query
sql = "SELECT id " + "FROM " + DbMailItem.getMailItemTableName(mbox) + " WHERE mailbox_id = " + mbox.getId() + " AND id = " + childId;
results = DbUtil.executeQuery(sql);
Assert.assertEquals("Child folder query returned data. id=" + childId, 0, results.size());
}
use of com.zimbra.cs.db.DbResults in project zm-mailbox by Zimbra.
the class ContactTest method locator.
/**
* Confirms that locator is not set for contacts.
*/
@Test
public void locator() throws Exception {
// Create contact.
Map<String, String> attrs = Maps.newHashMap();
attrs.put(ContactConstants.A_fullName, "Volume Id");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
mbox.createContact(null, new ParsedContact(attrs), Mailbox.ID_FOLDER_CONTACTS, null);
// Check volume id in database.
String sql = String.format("SELECT COUNT(*) FROM %s WHERE type = %d AND blob_digest IS NULL AND locator IS NOT NULL", DbMailItem.getMailItemTableName(mbox), MailItem.Type.CONTACT.toByte());
DbResults results = DbUtil.executeQuery(sql);
Assert.assertEquals("Found non-null locator values for contacts", 0, results.getInt(1));
}
use of com.zimbra.cs.db.DbResults in project zm-mailbox by Zimbra.
the class TestUnread method verifyAllUnreadFlags.
private void verifyAllUnreadFlags() throws Exception {
verifyUnreadFlag(getMessage1());
verifyUnreadFlag(getMessage2());
verifyUnreadFlag(getMessage3());
verifyUnreadFlag(getConv());
verifyUnreadFlag(getFolder1());
verifyUnreadFlag(getFolder2());
verifyUnreadFlag(getTag1());
verifyUnreadFlag(getTag2());
// Make sure we aren't still setting the old unread flag
DbResults results = DbUtil.executeQuery("SELECT COUNT(*) " + "FROM " + DbMailItem.getMailItemTableName(mMbox) + " WHERE mailbox_id = " + mMbox.getId() + " AND flags & " + Flag.BITMASK_UNREAD + " > 0");
int numRows = results.getInt(1);
Assert.assertEquals("Found " + numRows + " items with old unread flag set", 0, numRows);
}
Aggregations