use of com.zimbra.soap.mail.type.FilterAction.DeleteheaderAction in project zm-mailbox by Zimbra.
the class ModifyFilterRulesAdminTest method testSoapToSieveDeleteheaderAction6.
// headerName, multiple headerValues, comparator, value, relationalComparator
@Test
public void testSoapToSieveDeleteheaderAction6() throws ServiceException, Exception {
List<String> values = new ArrayList<String>();
values.add("2");
EditheaderTest test = new EditheaderTest(null, null, true, "ge", "i;ascii-numeric", "X-Test-Header", values);
DeleteheaderAction action = new DeleteheaderAction(null, null, test);
FilterRule filterRule = new FilterRule("rule1", true);
filterRule.addFilterAction(action);
List<FilterRule> filterRules = new ArrayList<FilterRule>();
filterRules.add(filterRule);
RuleManager.clearCachedRules(account);
RuleManager.setAdminRulesFromXML(account, filterRules, FilterType.INCOMING, AdminFilterType.BEFORE);
String script = "require [" + SoapToSieve.requireCommon + ", \"editheader\"];\n\n" + "# rule1\n" + "deleteheader :value \"ge\" :comparator \"i;ascii-numeric\" \"X-Test-Header\" \"2\";\n";
Assert.assertEquals(script, account.getAdminSieveScriptBefore());
}
use of com.zimbra.soap.mail.type.FilterAction.DeleteheaderAction in project zm-mailbox by Zimbra.
the class ModifyFilterRulesAdminTest method testSoapToSieveDeleteheaderAction2.
// headerName and headerValue only
// default comparator and matchType
@Test
public void testSoapToSieveDeleteheaderAction2() throws ServiceException, Exception {
List<String> values = new ArrayList<String>();
values.add("Test value");
EditheaderTest test = new EditheaderTest(null, null, null, null, null, "X-Test-Header", values);
DeleteheaderAction action = new DeleteheaderAction(null, null, test);
FilterRule filterRule = new FilterRule("rule1", true);
filterRule.addFilterAction(action);
List<FilterRule> filterRules = new ArrayList<FilterRule>();
filterRules.add(filterRule);
RuleManager.clearCachedRules(account);
RuleManager.setAdminRulesFromXML(account, filterRules, FilterType.INCOMING, AdminFilterType.BEFORE);
String script = "require [" + SoapToSieve.requireCommon + ", \"editheader\"];\n\n" + "# rule1\n" + "deleteheader :comparator \"i;ascii-casemap\" :is \"X-Test-Header\" \"Test value\";\n";
Assert.assertEquals(script, account.getAdminSieveScriptBefore());
}
use of com.zimbra.soap.mail.type.FilterAction.DeleteheaderAction in project zm-mailbox by Zimbra.
the class ModifyFilterRulesAdminTest method testSoapToSieveDeleteheaderAction4.
// headerName, multiple headerValues, matchType and comparator
@Test
public void testSoapToSieveDeleteheaderAction4() throws ServiceException, Exception {
List<String> values = new ArrayList<String>();
values.add("Value1");
values.add("Value2");
values.add("Value3");
EditheaderTest test = new EditheaderTest("contains", null, null, null, "i;octet", "X-Test-Header", values);
DeleteheaderAction action = new DeleteheaderAction(null, null, test);
FilterRule filterRule = new FilterRule("rule1", true);
filterRule.addFilterAction(action);
List<FilterRule> filterRules = new ArrayList<FilterRule>();
filterRules.add(filterRule);
RuleManager.clearCachedRules(account);
RuleManager.setAdminRulesFromXML(account, filterRules, FilterType.INCOMING, AdminFilterType.BEFORE);
String script = "require [" + SoapToSieve.requireCommon + ", \"editheader\"];\n\n" + "# rule1\n" + "deleteheader :comparator \"i;octet\" :contains \"X-Test-Header\" [ \"Value1\", \"Value2\", \"Value3\" ];\n";
Assert.assertEquals(script, account.getAdminSieveScriptBefore());
}
use of com.zimbra.soap.mail.type.FilterAction.DeleteheaderAction in project zm-mailbox by Zimbra.
the class ModifyFilterRulesAdminTest method testSoapToSieveDeleteheaderAction5.
// headerName, multiple headerValues, comparator, value, relationalComparator
@Test
public void testSoapToSieveDeleteheaderAction5() throws ServiceException, Exception {
List<String> values = new ArrayList<String>();
values.add("2");
EditheaderTest test = new EditheaderTest(null, null, true, "ge", "i;ascii-numeric", "X-Test-Header", values);
DeleteheaderAction action = new DeleteheaderAction(null, null, test);
FilterRule filterRule = new FilterRule("rule1", true);
filterRule.addFilterAction(action);
List<FilterRule> filterRules = new ArrayList<FilterRule>();
filterRules.add(filterRule);
RuleManager.clearCachedRules(account);
RuleManager.setAdminRulesFromXML(account, filterRules, FilterType.INCOMING, AdminFilterType.BEFORE);
String script = "require [" + SoapToSieve.requireCommon + ", \"editheader\"];\n\n" + "# rule1\n" + "deleteheader :value \"ge\" :comparator \"i;ascii-numeric\" \"X-Test-Header\" \"2\";\n";
Assert.assertEquals(script, account.getAdminSieveScriptBefore());
}
use of com.zimbra.soap.mail.type.FilterAction.DeleteheaderAction in project zm-mailbox by Zimbra.
the class ModifyFilterRulesAdminTest method testSoapToSieveDeleteheaderAction7.
// headerName, multiple headerValues, comparator, count, relationalComparator
@Test
public void testSoapToSieveDeleteheaderAction7() throws ServiceException, Exception {
List<String> values = new ArrayList<String>();
values.add("2");
EditheaderTest test = new EditheaderTest(null, true, null, "ge", "i;ascii-numeric", "X-Test-Header", values);
DeleteheaderAction action = new DeleteheaderAction(null, null, test);
FilterRule filterRule = new FilterRule("rule1", true);
filterRule.addFilterAction(action);
List<FilterRule> filterRules = new ArrayList<FilterRule>();
filterRules.add(filterRule);
RuleManager.clearCachedRules(account);
RuleManager.setAdminRulesFromXML(account, filterRules, FilterType.INCOMING, AdminFilterType.BEFORE);
String script = "require [" + SoapToSieve.requireCommon + ", \"editheader\"];\n\n" + "# rule1\n" + "deleteheader :count \"ge\" :comparator \"i;ascii-numeric\" \"X-Test-Header\" \"2\";\n";
Assert.assertEquals(script, account.getAdminSieveScriptBefore());
}
Aggregations