WeekdayValidationMatcher implements ValidationMatcher, ControlExpressionParser { @Override public List<String> extractControlValues(String controlExpression, Character delimiter) { List<String> parameters = new ArrayList<>(); if (controlExpression.contains("(")) { parameters.add(controlExpression.substring(0, controlExpression.indexOf("('"))); parameters.add(controlExpression.substring(controlExpression.indexOf("('") + 2, controlExpression.length() - 2)); } else { parameters.add(controlExpression); } return parameters; }  @Override void validate(String fieldName, String value, List<String> controlParameters, TestContext context); @Override List<String> extractControlValues(String controlExpression, Character delimiter);  }
@Test(dataProvider = "validParameters") public void shouldExtractParametersSuccessfully(String controlExpression, List<String> expectedParameters) { List<String> controlValues = matcher.extractControlValues(controlExpression, null); Assert.assertEquals(controlValues.size(), expectedParameters.size()); for (int i = 0; i < controlValues.size(); i++) { Assert.assertEquals(controlValues.get(i), expectedParameters.get(i)); } }