Search in sources :

Example 1 with TestClass

use of grails.validation.TestClass in project grails-core by grails.

the class ScaleConstraintTests method proceedValidation.

private Object proceedValidation(Constraint constraint, Object value) {
    BeanWrapper constrainedBean = new BeanWrapperImpl(new TestClass());
    constrainedBean.setPropertyValue(constraint.getPropertyName(), value);
    Errors errors = new BindException(constrainedBean.getWrappedInstance(), constrainedBean.getWrappedClass().getName());
    assertFalse(errors.hasErrors());
    constraint.validate(constrainedBean.getWrappedInstance(), value, errors);
    return constrainedBean.getPropertyValue(constraint.getPropertyName());
}
Also used : Errors(org.springframework.validation.Errors) BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) BindException(org.springframework.validation.BindException) TestClass(grails.validation.TestClass)

Aggregations

TestClass (grails.validation.TestClass)1 BeanWrapper (org.springframework.beans.BeanWrapper)1 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)1 BindException (org.springframework.validation.BindException)1 Errors (org.springframework.validation.Errors)1