Search in sources :

Example 1 with ActionFlag

use of com.zimbra.cs.filter.jsieve.ActionFlag 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]));
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) Message(com.zimbra.cs.mailbox.Message) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) ParsedMessage(com.zimbra.cs.mime.ParsedMessage) Folder(com.zimbra.cs.mailbox.Folder) ItemId(com.zimbra.cs.service.util.ItemId) ActionFlag(com.zimbra.cs.filter.jsieve.ActionFlag) Mailbox(com.zimbra.cs.mailbox.Mailbox) DeliveryContext(com.zimbra.cs.mailbox.DeliveryContext) DeliveryOptions(com.zimbra.cs.mailbox.DeliveryOptions) Test(org.junit.Test)

Aggregations

Account (com.zimbra.cs.account.Account)1 ActionFlag (com.zimbra.cs.filter.jsieve.ActionFlag)1 DeliveryContext (com.zimbra.cs.mailbox.DeliveryContext)1 DeliveryOptions (com.zimbra.cs.mailbox.DeliveryOptions)1 Folder (com.zimbra.cs.mailbox.Folder)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 Message (com.zimbra.cs.mailbox.Message)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)1 ItemId (com.zimbra.cs.service.util.ItemId)1 Test (org.junit.Test)1