### Question:
CNPJValidator implements Validator<String> { 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; } CNPJValidator();  CNPJValidator(boolean isFormatted);  CNPJValidator(boolean isFormatted, boolean isIgnoringRepeatedDigits);  CNPJValidator(MessageProducer messageProducer, boolean isFormatted, boolean isIgnoringRepeatedDigits);  CNPJValidator(MessageProducer messageProducer, boolean isFormatted);  CNPJValidator(MessageProducer messageProducer); boolean isEligible(String value); @Override void assertValid(String cnpj); @Override List<ValidationMessage> invalidMessagesFor(String cnpj); @Override String generateRandomValid(); static final Pattern FORMATED; static final Pattern UNFORMATED; }### Answer:
@Test public void shouldNotBeEligibleWithNullCNPJ() { final CNPJValidator cnpjValidator = new CNPJValidator(); assertFalse(cnpjValidator.isEligible(null)); }
@Test public void shouldBeEligibleDefaultConstructor() { final CNPJValidator cnpjValidator = new CNPJValidator(); assertTrue(cnpjValidator.isEligible(validStringNotFormatted)); assertFalse(cnpjValidator.isEligible(validString)); }
@Test public void shouldBeEligibleConstructorNotFormatted() { final CNPJValidator cnpjValidator = new CNPJValidator(false); assertTrue(cnpjValidator.isEligible(validStringNotFormatted)); assertFalse(cnpjValidator.isEligible(validString)); }
@Test public void shouldBeEligibleConstructorFormatted() { final CNPJValidator cnpjValidator = new CNPJValidator(true); assertFalse(cnpjValidator.isEligible(validStringNotFormatted)); assertTrue(cnpjValidator.isEligible(validString)); }