### Question:
RegexValidator implements Validator { @Override public boolean validate(String value) { return value != null && regex.matcher(value).matches(); } RegexValidator(String parameter); @Override boolean validate(String value);  }### Answer:
@Test public void testValidateMatchesRegex() throws ValidatorConfigurationException { Validator validator = new RegexValidator("\\d-\\d"); assertTrue(validator.validate("1-1")); }
@Test public void testValidateDoesNotMatchRegex() throws ValidatorConfigurationException { Validator validator = new RegexValidator("\\d-\\d"); assertFalse(validator.validate("a-a")); assertFalse(validator.validate("")); assertFalse(validator.validate(null)); }