### Question:
RegexValidator implements Validator { @Override public <T> boolean validate(T string) { boolean retVal = false; Matcher matcher = pattern.matcher((String) string); retVal = matcher.matches(); if (retVal && logger.isDebugEnabled()) { logger.debug("Found error line: {}", string); } return retVal; } RegexValidator(String regex); @Override boolean validate(T string);  }### Answer:
@Test public void testValidate_exception_found() throws Exception { boolean result = instance .validate("catalina.out:Exception in thread \"Studio Teletype\" java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation"); assertTrue(result); }
@Test public void testValidate_no_exception_found() throws Exception { boolean result = instance.validate("This is okay"); assertFalse(result); }
@Test(expected = NullPointerException.class) public void testValidate_null_line() throws Exception { boolean result = instance.validate(null); assertFalse(result); }