use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemQueryTest method testNoneItemsQuery.
@Test
public void testNoneItemsQuery() throws Exception {
Account acct = Provisioning.getInstance().getAccountByName("zero@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX).setFlags(Flag.BITMASK_UNREAD);
mbox.addMessage(null, MailboxTestUtil.generateMessage("test subject"), dopt, null);
SearchResponse resp;
List<SearchHit> hits;
SearchRequest sr = new SearchRequest();
sr.setSearchTypes("message");
sr.setQuery("item:{none}");
sr.setSortBy(SortBy.ATTACHMENT_ASC.toString());
resp = doSearch(sr, acct);
hits = resp.getSearchHits();
Assert.assertEquals("Number of hits", 0, hits.size());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemQueryTest method testListOfItemsQuery.
@Test
public void testListOfItemsQuery() throws Exception {
Account acct = Provisioning.getInstance().getAccountByName("zero@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX).setFlags(Flag.BITMASK_UNREAD);
Message msg1 = mbox.addMessage(null, MailboxTestUtil.generateMessage("test subject"), dopt, null);
mbox.addMessage(null, MailboxTestUtil.generateMessage("test subject2"), dopt, null);
Message msg3 = mbox.addMessage(null, MailboxTestUtil.generateMessage("test subject3"), dopt, null);
SearchResponse resp;
List<SearchHit> hits;
SearchRequest sr = new SearchRequest();
sr.setSearchTypes("message");
sr.setQuery(String.format("item:{%d,%d}", msg1.getId(), msg3.getId()));
sr.setSortBy(SortBy.ATTACHMENT_ASC.toString());
resp = doSearch(sr, acct);
hits = resp.getSearchHits();
Assert.assertEquals("Number of hits", 2, hits.size());
int msgId = Integer.parseInt(hits.get(0).getId());
Assert.assertEquals("correct hit 1", msg1.getId(), msgId);
msgId = Integer.parseInt(hits.get(1).getId());
Assert.assertEquals("correct hit 2", msg3.getId(), msgId);
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemActionTest method deleteAllTagKeepsStatusOfFlags.
@Test
public void deleteAllTagKeepsStatusOfFlags() throws Exception {
// Bug 76781
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
acct.setMailThreadingAlgorithm(MailThreadingAlgorithm.subject);
// setup: add the root message
ParsedMessage pm = MailboxTestUtil.generateMessage("test subject");
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
mbox.addMessage(null, pm, dopt, null);
// add additional messages for conversation
pm = MailboxTestUtil.generateMessage("Re: test subject");
int msgId = mbox.addMessage(null, pm, dopt, null).getId();
// set flag to unread for this message
MailboxTestUtil.setFlag(mbox, msgId, Flag.FlagInfo.UNREAD);
MailItem item = mbox.getItemById(null, msgId, MailItem.Type.UNKNOWN);
// verify message unread flag is set
Assert.assertEquals("Verifying Unread flag is set.", Flag.BITMASK_UNREAD, item.getFlagBitmask());
// add 2 tags
mbox.alterTag(null, msgId, MailItem.Type.MESSAGE, tag1, true, null);
mbox.alterTag(null, msgId, MailItem.Type.MESSAGE, tag2, true, null);
Element request = new Element.XMLElement(MailConstants.ITEM_ACTION_REQUEST);
Element action = request.addElement(MailConstants.E_ACTION);
action.addAttribute(MailConstants.A_OPERATION, ItemAction.OP_UPDATE);
action.addAttribute(MailConstants.A_ITEM_TYPE, "");
action.addAttribute(MailConstants.A_ID, msgId);
new ItemAction().handle(request, ServiceTestUtil.getRequestContext(acct));
Assert.assertEquals("Verifying unread flag is set after tag deletion", Flag.BITMASK_UNREAD, item.getFlagBitmask());
Tag tag = mbox.getTagByName(null, tag1);
Assert.assertEquals(tag1 + " (tag messages)", 0, tag.getSize());
tag = mbox.getTagByName(null, tag2);
Assert.assertEquals(tag1 + " (tag messages)", 0, tag.getSize());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemActionTest method copyMessageFromDraftsToSent.
@Test
public void copyMessageFromDraftsToSent() throws Exception {
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
ParsedMessage pm = MailboxTestUtil.generateMessage("test subject copyMessageFromDraftsToSent");
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_DRAFTS);
int msgId = mbox.addMessage(null, pm, dopt, null).getId();
ItemId iidTarget = new ItemId(mbox, Mailbox.ID_FOLDER_SENT);
ItemActionHelper op = ItemActionHelper.COPY(null, mbox, SoapProtocol.Soap12, Arrays.asList(msgId), MailItem.Type.MESSAGE, null, iidTarget);
Assert.assertNotNull("test non-null response", op);
Assert.assertTrue("test CopyActionResult", op.getResult() instanceof CopyActionResult);
CopyActionResult copyActionResult = (CopyActionResult) op.getResult();
Assert.assertNotNull("test non-null success info", copyActionResult.getSuccessIds());
Assert.assertEquals("test correct success count", 1, copyActionResult.getSuccessIds().size());
ItemId iid = new ItemId(copyActionResult.getCreatedIds().get(0), acct.getId());
Assert.assertNotNull("test non-null created info", iid);
Message copiedMessage = mbox.getMessageById(null, iid.getId());
Assert.assertNotNull("test non-null message", copiedMessage);
Assert.assertNotNull("test non-null subject in copied message", copiedMessage.getSubject());
Assert.assertEquals("test subject copyMessageFromDraftsToSent", copiedMessage.getSubject());
Assert.assertEquals("test parent folder of copied message", Mailbox.ID_FOLDER_SENT, copiedMessage.getFolderId());
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ItemActionTest method moveConversationToAcctRelativePath.
@Test
public void moveConversationToAcctRelativePath() throws Exception {
Account acct = Provisioning.getInstance().get(Key.AccountBy.name, "test@zimbra.com");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(acct);
acct.setMailThreadingAlgorithm(MailThreadingAlgorithm.subject);
ParsedMessage pm = MailboxTestUtil.generateMessage("test subject");
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
int msgId = mbox.addMessage(null, pm, dopt, null).getId();
String targetFolderName = "folder1";
ItemActionHelper.MOVE(null, mbox, SoapProtocol.Soap12, Arrays.asList(msgId * -1), null, targetFolderName);
Folder newFolder = mbox.getFolderByName(null, Mailbox.ID_FOLDER_USER_ROOT, targetFolderName);
Message msg = mbox.getMessageById(null, msgId);
Assert.assertEquals(msg.getFolderId(), newFolder.getId());
}
Aggregations