Min extends AbstractValidator<Long, Number> { public void validate(Field field, Long constraintValue, MessageFormatter formatter, Number value) throws ValidationException { if (value.longValue() < constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); } Min(JavaScriptSupport javaScriptSupport, Html5Support html5Support); void validate(Field field, Long constraintValue, MessageFormatter formatter, Number value); void render(Field field, Long constraintValue, MessageFormatter formatter, MarkupWriter writer,
                       FormSupport formSupport);  }
@Test public void large_enough() throws Exception { Field field = mockField(); MessageFormatter formatter = mockMessageFormatter(); Long constraint = 50L; Min validator = new Min(null, mockHtml5Support()); replay(); for (int value = 50; value < 52; value++) validator.validate(field, constraint, formatter, value); verify(); }
@Test public void value_too_small() throws Exception { String label = "My Field"; Field field = mockFieldWithLabel(label); MessageFormatter formatter = mockMessageFormatter(); String message = "{message}"; Long constraint = 100l; Number value = 99; train_format(formatter, message, constraint, label); Min validator = new Min(null, mockHtml5Support()); replay(); try { validator.validate(field, constraint, formatter, value); unreachable(); } catch (ValidationException ex) { assertEquals(ex.getMessage(), message); } verify(); }