use of org.apache.tapestry5.ValidationException in project tapestry-5 by apache.
the class RegexpTest method input_mismatch.
@Test
public void input_mismatch() throws Exception {
String label = "My Field";
Field field = mockFieldWithLabel(label);
MessageFormatter formatter = mockMessageFormatter();
String message = "{message}";
Pattern constraint = Pattern.compile("\\d{4}");
String value = "abc";
train_format(formatter, message, constraint.toString(), label);
replay();
Regexp validator = new Regexp(null);
try {
validator.validate(field, constraint, formatter, value);
unreachable();
} catch (ValidationException ex) {
assertEquals(ex.getMessage(), message);
}
verify();
}
use of org.apache.tapestry5.ValidationException in project tapestry-5 by apache.
the class RequiredTest method null_value.
@Test
public void null_value() {
Field field = mockFieldWithLabel("My Field");
MessageFormatter formatter = mockMessageFormatter();
train_format(formatter, "{message}", "My Field");
Html5Support html5Support = mockHtml5Support();
replay();
try {
new Required(null, html5Support).validate(field, null, formatter, null);
unreachable();
} catch (ValidationException ex) {
assertEquals(ex.getMessage(), "{message}");
}
verify();
}
use of org.apache.tapestry5.ValidationException in project tapestry-5 by apache.
the class TranslatorSourceImplTest method parse_client_failure.
@Test(dataProvider = "parse_client_failure_data")
public void parse_client_failure(Class type, String input, String expectedMessage) {
Translator t = source.getByType(type);
Field field = mockField();
replay();
try {
t.parseClient(field, input, expectedMessage);
unreachable();
} catch (ValidationException ex) {
assertEquals(ex.getMessage(), expectedMessage);
}
verify();
}
Aggregations