LengthValidator lengthValidator = new LengthValidator(messageProducer, 2);
String message = "O tamanho da entrada é inválido.";
final ValidationMessage validationMessage = new SimpleValidationMessage(message);
mockery.checking(new Expectations() {
{
one(messageProducer).getMessage(with(equal(new LengthError(2))));
will(returnValue(validationMessage));
}
});
List<ValidationMessage> invalidMessages = lengthValidator.invalidMessagesFor(12345);
Assert.assertEquals(1, invalidMessages.size());