Package grails.validation

Examples of grails.validation.Constraint


                getConstraint("{val, obj -> return propertyName == 'testString'}"),
                "test");
    }

    public void testConstraintCreation() {
        Constraint validatorConstraint = new ValidatorConstraint();
        assertEquals(ConstrainedProperty.VALIDATOR_CONSTRAINT, validatorConstraint.getName());
        assertTrue(validatorConstraint.supports(TestClass.class));
        assertFalse(validatorConstraint.supports(null));

        validatorConstraint.setOwningClass(TestClass.class);
        validatorConstraint.setPropertyName(PROP_NAME);

        try {
            getConstraint("testString", "Test");
            fail("ValidatorConstraint must throw an exception for non-closure parameter.");
        } catch (IllegalArgumentException iae) {
View Full Code Here


        // test a scale of zero applied to a BigDecimal
        testBigDecimal(0, "0.123", "0");
    }

    public void testNullPasses() {
        Constraint constraint = getConstraint("testBigDecimal", 2);
        assertEquals(null, proceedValidation(constraint, null));
    }
View Full Code Here

        Constraint constraint = getConstraint("testBigDecimal", 2);
        assertEquals(null, proceedValidation(constraint, null));
    }

    public void testValidationOnInvalidField() {
        Constraint constraint = getConstraint("testString", 2);
        try {
            proceedValidation(constraint, "123");
            fail("ScaleConstraint must throw an exception when applied to field with unsupported type");
        } catch (IllegalArgumentException iae) {
            // Great
View Full Code Here

            // Great
        }
    }

    private void testFloat(int scale, float value, float result) {
        Constraint constraint = getConstraint("testFloat", scale);
        assertEquals(result, proceedValidation(constraint, value));
    }
View Full Code Here

        Constraint constraint = getConstraint("testFloat", scale);
        assertEquals(result, proceedValidation(constraint, value));
    }

    private void testDouble(int scale, double value, double result) {
        Constraint constraint = getConstraint("testDouble", scale);
        assertEquals(Double.valueOf(result), proceedValidation(constraint, value));
    }
View Full Code Here

    private void testDouble(int scale, double value, double result) {
        Constraint constraint = getConstraint("testDouble", scale);
        assertEquals(Double.valueOf(result), proceedValidation(constraint, value));
    }
    private void testBigDecimal(int scale, String value, String result) {
        Constraint constraint = getConstraint("testBigDecimal", scale);
        assertEquals(new BigDecimal(result), proceedValidation(constraint, new BigDecimal(value)));
    }
View Full Code Here

TOP

Related Classes of grails.validation.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.