### Question:
BbCodeNestingValidator implements ConstraintValidator<BbCodeNesting, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isEmpty(value)) { return true; } try { processor.process(value); return true; } catch (TextProcessorNestingException e) { LOGGER.warn("Too deep bb-code nesting: " + value); return false; } }  @Override void initialize(BbCodeNesting constraintAnnotation); @Override boolean isValid(String value, ConstraintValidatorContext context);  }### Answer:
@Test public void nullAndEmptyStringShouldBeTreatedAsValid() { assertTrue(instance.isValid(null, null)); assertTrue(instance.isValid("", null)); }
@Test(dataProvider = "validMessages") public void testValidMessages(String message, String assertinMessage) { assertTrue(instance.isValid(message, null), message + " - " + assertinMessage); }
@Test(dataProvider = "invalidMessages") public void testInvalidMessages(String message, String assertionMessage) { assertFalse(instance.isValid(message, null), message + " - " + assertionMessage); }