Java 类org.hibernate.validator.constraints.ScriptAssert 实例源码

项目:nest-old    文件:TestObject.java   
@Test
public void testScriptAssert() {
    Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, ScriptAssert.class);
    assertNotNull(violations);
    assertEquals(violations.size(), 1);

    if (runPeformance) {
        long time = System.currentTimeMillis();
        for (int index = 0; index < 10000; index++) {
            validator.validate(obj, ScriptAssert.class);
        }
        long used = System.currentTimeMillis() - time;
        System.out.println("Hibernate Validator [ScriptAssert] check used " + used + "ms, avg. " + ((double) used)
                / 10000 + "ms.");
    }
}
项目:nest-old    文件:BeanScriptConvertor.java   
/**
 * (non-Javadoc)
 * 
 * @see com.github.nest.arcteryx.meta.beans.internal.validators.hibernate.convertors.AbstractHibernateConstraintConvertor#registerErrorCode()
 */
@Override
protected void registerErrorCode() {
    HibernateErrorCodeRegistry.registerErrorCode(ScriptAssert.class, BeanScriptConstraint.class.getSimpleName());
}