### Question:
TituloEleitorValidator implements ConstraintValidator<TituloEleitor, String> { @Override public boolean isValid(final String value, final ConstraintValidatorContext context) { boolean result = false; if (value != null && !value.equals("")) { String tituloCalc = insertZeros(removeChars(value, '.', '/', '-', ' '), 12); String verifierDigit = tituloCalc.substring(tituloCalc.length() - 2, tituloCalc.length()); int sum1 = 0; for (int index = 0; index < 8; index++) { sum1 += (tituloCalc.charAt(index) - 48) * (index + 2); } int digit1 = (sum1 % 11) % 10; int sum2 = ((tituloCalc.charAt(8) - 48) * 7) + ((tituloCalc.charAt(9) - 48) * 8) + ((tituloCalc.charAt(10) - 48) * 9); int digit2 = (sum2 % 11) % 10; String dvReal = digit1 + "" + digit2; if (dvReal.equals(verifierDigit)) { result = true; } } return result; }  @Override void initialize(final TituloEleitor constraintAnnotation); String insertZeros(final String string, final int howMuchZeros); @Override boolean isValid(final String value, final ConstraintValidatorContext context); String removeChars(String string, final char... chars);  }### Answer:
@Test public void testValidator() { TituloEleitorValidator validator = new TituloEleitorValidator(); assertFalse(validator.isValid(null, null)); assertFalse(validator.isValid("", null)); assertFalse(validator.isValid("ABC", null)); assertTrue(validator.isValid("026878511287", null)); assertTrue(validator.isValid("60524580680", null)); assertTrue(validator.isValid("106644440302", null)); assertTrue(validator.isValid("000000000000", null)); assertTrue(validator.isValid("0000000000000000", null)); }