### Question:
CPFValidator implements Validator<String> { @Override public boolean isEligible(String value) { if (value == null) { return false; } boolean result; if (isFormatted) { result = FORMATED.matcher(value).matches(); } else { result = UNFORMATED.matcher(value).matches(); } return result; } CPFValidator();  CPFValidator(boolean isFormatted);  CPFValidator(boolean isFormatted, boolean isIgnoringRepeatedDigits);  CPFValidator(MessageProducer messageProducer, boolean isFormatted);  CPFValidator(MessageProducer messageProducer, boolean isFormatted, boolean isIgnoringRepeatedDigits); @Override boolean isEligible(String value); @Override void assertValid(String cpf); @Override List<ValidationMessage> invalidMessagesFor(String cpf); @Override String generateRandomValid(); static final Pattern FORMATED; static final Pattern UNFORMATED; }### Answer:
@Test public void shouldNeverThrowsNPE() { assertThat(validator.isEligible(null), is(false)); }
@Test public void shouldBeEligibleDefaultConstructor() { final CPFValidator cpfValidator = new CPFValidator(); assertTrue(cpfValidator.isEligible(validStringNotFormatted)); assertFalse(cpfValidator.isEligible(validString)); }
@Test public void shouldBeEligibleConstructorNotFormatted() { final CPFValidator cpfValidator = new CPFValidator(false); assertTrue(cpfValidator.isEligible(validStringNotFormatted)); assertFalse(cpfValidator.isEligible(validString)); }
@Test public void shouldBeEligibleConstructorFormatted() { final CPFValidator cpfValidator = new CPFValidator(true); assertFalse(cpfValidator.isEligible(validStringNotFormatted)); assertTrue(cpfValidator.isEligible(validString)); }