@Test
public void testAdditionalValidator()
{
UIContext ctx = new MockUIContext();
MockValidationContext context = new MockValidationContext(ctx);
withValidator.addValidator(new UIValidator()
{
@Override
public void validate(UIValidationContext validator)
{
validator.addValidationError(withValidator, "MSG");
}
});
withValidator.setValue("FOO");
withValidator.validate(context);
List<String> errors = context.getErrorsFor(withValidator);
Assert.assertThat(errors, notNullValue());
Assert.assertThat(errors.size(), equalTo(1));
Assert.assertThat(errors, hasItem("MSG"));
}