use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ConversationTestTest method started.
@Test
public void started() throws Exception {
Account account = Provisioning.getInstance().getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
RuleManager.clearCachedRules(account);
account.setMailSieveScript("if conversation :where \"started\" { tag \"started\"; }");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
mbox.addMessage(new OperationContext(mbox), new ParsedMessage("From: test1@zimbra.com\nSubject: test".getBytes(), false), MailboxTest.STANDARD_DELIVERY_OPTIONS, new DeliveryContext());
DeliveryOptions dopt = new DeliveryOptions();
dopt.setFolderId(Mailbox.ID_FOLDER_SENT);
dopt.setFlags(Flag.BITMASK_FROM_ME);
mbox.addMessage(new OperationContext(mbox), new ParsedMessage("From: test@zimbra.com\nSubject: Re: test".getBytes(), false), dopt, new DeliveryContext());
List<ItemId> ids = RuleManager.applyRulesToIncomingMessage(new OperationContext(mbox), mbox, new ParsedMessage("From: test1@zimbra.com\nSubject: Re: test".getBytes(), false), 0, account.getName(), new DeliveryContext(), Mailbox.ID_FOLDER_INBOX, true);
Assert.assertEquals(1, ids.size());
Message msg = mbox.getMessageById(null, ids.get(0).getId());
Assert.assertEquals(0, msg.getTags().length);
dopt = new DeliveryOptions();
dopt.setFolderId(Mailbox.ID_FOLDER_SENT);
dopt.setFlags(Flag.BITMASK_FROM_ME);
mbox.addMessage(new OperationContext(mbox), new ParsedMessage("From: test@zimbra.com\nSubject: test1".getBytes(), false), dopt, new DeliveryContext());
ids = RuleManager.applyRulesToIncomingMessage(new OperationContext(mbox), mbox, new ParsedMessage("From: test1@zimbra.com\nSubject: Re: test1".getBytes(), false), 0, account.getName(), new DeliveryContext(), Mailbox.ID_FOLDER_INBOX, true);
Assert.assertEquals(1, ids.size());
msg = mbox.getMessageById(null, ids.get(0).getId());
Assert.assertEquals("started", ArrayUtil.getFirstElement(msg.getTags()));
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ConversationTestTest method participated.
@Test
public void participated() throws Exception {
Account account = Provisioning.getInstance().getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
RuleManager.clearCachedRules(account);
account.setMailSieveScript("if conversation :where \"participated\" { tag \"participated\"; }");
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
mbox.addMessage(new OperationContext(mbox), new ParsedMessage("From: test1@zimbra.com\nSubject: test".getBytes(), false), MailboxTest.STANDARD_DELIVERY_OPTIONS, new DeliveryContext());
List<ItemId> ids = RuleManager.applyRulesToIncomingMessage(new OperationContext(mbox), mbox, new ParsedMessage("From: test1@zimbra.com\nSubject: Re: test".getBytes(), false), 0, account.getName(), new DeliveryContext(), Mailbox.ID_FOLDER_INBOX, true);
Assert.assertEquals(1, ids.size());
Message msg = mbox.getMessageById(null, ids.get(0).getId());
Assert.assertEquals(0, msg.getTags().length);
DeliveryOptions dopt = new DeliveryOptions();
dopt.setFolderId(Mailbox.ID_FOLDER_SENT);
dopt.setFlags(Flag.BITMASK_FROM_ME);
mbox.addMessage(new OperationContext(mbox), new ParsedMessage("From: test@zimbra.com\nSubject: Re: test".getBytes(), false), dopt, new DeliveryContext());
ids = RuleManager.applyRulesToIncomingMessage(new OperationContext(mbox), mbox, new ParsedMessage("From: test1@zimbra.com\nSubject: Re: test".getBytes(), false), 0, account.getName(), new DeliveryContext(), Mailbox.ID_FOLDER_INBOX, true);
Assert.assertEquals(1, ids.size());
msg = mbox.getMessageById(null, ids.get(0).getId());
Assert.assertEquals("participated", ArrayUtil.getFirstElement(msg.getTags()));
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ExistingMessageHandlerTest method existing.
@Test
public void existing() throws Exception {
Account account = Provisioning.getInstance().getAccount(MockProvisioning.DEFAULT_ACCOUNT_ID);
RuleManager.clearCachedRules(account);
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account);
OperationContext octx = new OperationContext(mbox);
Message msg = mbox.addMessage(octx, new ParsedMessage("From: sender@zimbra.com\nTo: test@zimbra.com\nSubject: test".getBytes(), false), new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX).setFlags(Flag.BITMASK_PRIORITY), new DeliveryContext());
Folder f = mbox.createFolder(null, "test", new Folder.FolderOptions().setDefaultView(MailItem.Type.MESSAGE));
ExistingMessageHandler handler = new ExistingMessageHandler(octx, mbox, msg.getId(), (int) msg.getSize());
ItemId newMsgItemId = handler.fileInto("test", new ArrayList<ActionFlag>(), new String[0]);
Message newMsg = mbox.getMessageById(octx, newMsgItemId.getId());
Assert.assertEquals(msg.getFolderId(), Integer.parseInt(newMsg.getUnderlyingData().getPrevFolders().split(":")[1]));
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class ZimbraQueryTest method suggest.
@Test
public void suggest() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, new ParsedMessage("Subject: all hands meeting".getBytes(), false), dopt, null);
MailboxTestUtil.index(mbox);
SearchParams params = new SearchParams();
params.setQueryString("all hands me");
params.setSortBy(SortBy.NONE);
params.setTypes(EnumSet.of(MailItem.Type.MESSAGE));
params.setQuick(true);
ZimbraQuery query = new ZimbraQuery(new OperationContext(mbox), SoapProtocol.Soap12, mbox, params);
ZimbraQueryResults result = query.execute();
Assert.assertEquals(msg.getId(), result.getNext().getItemId());
Closeables.closeQuietly(result);
}
use of com.zimbra.cs.mailbox.DeliveryOptions in project zm-mailbox by Zimbra.
the class LuceneQueryOperationTest method subjectQuery.
@Test
public void subjectQuery() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
DeliveryOptions dopt = new DeliveryOptions().setFolderId(Mailbox.ID_FOLDER_INBOX);
Message msg = mbox.addMessage(null, new ParsedMessage("Subject: one two three".getBytes(), false), dopt, null);
MailboxTestUtil.index(mbox);
// phrase query
SearchParams params = new SearchParams();
params.setQueryString("subject:\"one two three\"");
params.setTypes(EnumSet.of(MailItem.Type.MESSAGE));
params.setSortBy(SortBy.NONE);
ZimbraQuery query = new ZimbraQuery(new OperationContext(mbox), SoapProtocol.Soap12, mbox, params);
ZimbraQueryResults results = query.execute();
Assert.assertTrue(results.hasNext());
Assert.assertEquals(msg.getId(), results.getNext().getItemId());
results.close();
// verify subject is not repeated during index
params = new SearchParams();
params.setQueryString("subject:\"three one\"");
params.setTypes(EnumSet.of(MailItem.Type.MESSAGE));
params.setSortBy(SortBy.NONE);
query = new ZimbraQuery(new OperationContext(mbox), SoapProtocol.Soap12, mbox, params);
results = query.execute();
Assert.assertFalse(results.hasNext());
results.close();
}
Aggregations