Search in sources :

Example 11 with ZMarkAction

use of com.zimbra.client.ZFilterAction.ZMarkAction in project zm-mailbox by Zimbra.

the class TestFilter method doBodyContainsTest.

private void doBodyContainsTest(String substring, boolean contains) throws Exception {
    List<ZFilterCondition> conditions = new ArrayList<ZFilterCondition>();
    List<ZFilterAction> actions = new ArrayList<ZFilterAction>();
    List<ZFilterRule> rules = new ArrayList<ZFilterRule>();
    // If subject matches the first for characters + *, mark as flagged.
    conditions.add(new ZBodyCondition(BodyOp.CONTAINS, substring));
    actions.add(new ZMarkAction(MarkOp.FLAGGED));
    rules.add(new ZFilterRule("testBodyContains", true, false, conditions, actions));
    ZFilterRules zRules = new ZFilterRules(rules);
    saveIncomingRules(mMbox, zRules);
    // Add a message and test the flagged state.
    String address = TestUtil.getAddress(USER_NAME);
    String msgContent = new String(ByteUtil.getContent(new File("/opt/zimbra/unittest/TestFilter-testBodyContains.msg")));
    TestUtil.addMessageLmtp(new String[] { address }, address, msgContent);
    ZMessage msg = TestUtil.getMessage(mMbox, "in:inbox subject:testBodyContains");
    assertEquals("Unexpected message flag state", contains, msg.isFlagged());
    mMbox.deleteMessage(msg.getId());
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZFilterCondition(com.zimbra.client.ZFilterCondition) ArrayList(java.util.ArrayList) ZFilterAction(com.zimbra.client.ZFilterAction) ZFilterRule(com.zimbra.client.ZFilterRule) ZBodyCondition(com.zimbra.client.ZFilterCondition.ZBodyCondition) ZMarkAction(com.zimbra.client.ZFilterAction.ZMarkAction) File(java.io.File) ZFilterRules(com.zimbra.client.ZFilterRules)

Aggregations

ZMarkAction (com.zimbra.client.ZFilterAction.ZMarkAction)11 ArrayList (java.util.ArrayList)11 ZFilterAction (com.zimbra.client.ZFilterAction)10 ZFilterCondition (com.zimbra.client.ZFilterCondition)10 ZFilterRule (com.zimbra.client.ZFilterRule)10 ZFilterRules (com.zimbra.client.ZFilterRules)10 ZMessage (com.zimbra.client.ZMessage)8 ZHeaderCondition (com.zimbra.client.ZFilterCondition.ZHeaderCondition)7 Test (org.junit.Test)7 ZFileIntoAction (com.zimbra.client.ZFilterAction.ZFileIntoAction)4 ZBodyCondition (com.zimbra.client.ZFilterCondition.ZBodyCondition)4 ZDiscardAction (com.zimbra.client.ZFilterAction.ZDiscardAction)3 ZTagAction (com.zimbra.client.ZFilterAction.ZTagAction)3 ZKeepAction (com.zimbra.client.ZFilterAction.ZKeepAction)2 ZRedirectAction (com.zimbra.client.ZFilterAction.ZRedirectAction)2 File (java.io.File)2 ZNotifyAction (com.zimbra.client.ZFilterAction.ZNotifyAction)1 ZRFCCompliantNotifyAction (com.zimbra.client.ZFilterAction.ZRFCCompliantNotifyAction)1 ZReplyAction (com.zimbra.client.ZFilterAction.ZReplyAction)1 ZStopAction (com.zimbra.client.ZFilterAction.ZStopAction)1