### Question:
LengthValidator implements Validator<Object> { public void assertValid(Object object) { base.assertValid(getInvalidValuesFor(object)); } LengthValidator(int validLength);  LengthValidator(MessageProducer messageProducer, int validLength); void assertValid(Object object); List<ValidationMessage> invalidMessagesFor(Object object); boolean isEligible(Object object); @Override Object generateRandomValid();  }### Answer:
@Test public void shouldAssertValidCorrectLengthStrings() { LengthValidator validator = new LengthValidator(2); validator.assertValid("23"); }
@Test(expected = InvalidStateException.class) public void shouldNotAssertValidIncorrectLengthStrings() { LengthValidator validator = new LengthValidator(2); validator.assertValid("230"); }
@Test public void shouldAssertValidCorrectLengthIntegers() { LengthValidator validator = new LengthValidator(4); validator.assertValid(1234); }
@Test(expected = InvalidStateException.class) public void shouldNotAssertValidIncorrectLengthIntegers() { LengthValidator validator = new LengthValidator(4); validator.assertValid(123); }