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());
}
Aggregations