use of groovy.lang.IntRange in project grails-core by grails.
the class SizeConstraintTests method testValidation.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testValidation() {
testConstraintMessageCodes(getConstraint("testString", new IntRange(2, 5)), "123456", new String[] { "testClass.testString.size.error", "testClass.testString.size.toobig" }, new Object[] { "testString", TestClass.class, "123456", 2, 5 });
testConstraintMessageCodes(getConstraint("testString", new IntRange(2, 5)), "1", new String[] { "testClass.testString.size.error", "testClass.testString.size.toosmall" }, new Object[] { "testString", TestClass.class, "1", 2, 5 });
testConstraintPassed(getConstraint("testArray", new IntRange(2, 5)), new String[] { "one", "two", "three" });
List list = new ArrayList();
list.add("one");
testConstraintFailed(getConstraint("testArray", new IntRange(2, 5)), list);
list.add("two");
testConstraintPassed(getConstraint("testArray", new IntRange(2, 5)), list);
// must always pass on null value
testConstraintPassed(getConstraint("testArray", new IntRange(2, 5)), null);
testConstraintDefaultMessage(getConstraint("testString", new IntRange(1, 5)), "123456", "Property [{0}] of class [{1}] with value [{2}] does not fall within the valid size range from [{3}] to [{4}]");
}
Aggregations