Package groovy.lang

Examples of groovy.lang.ObjectRange


                getConstraint("testInteger", new IntRange(1, 5)), 0,
                new String[] {"testClass.testInteger.range.error","testClass.testInteger.range.toosmall"},
                new Object[] {"testInteger",TestClass.class, 0, 1, 5 });

        testConstraintPassed(
                getConstraint("testString", new ObjectRange("abca","abcf")),
                "abcd");

        testConstraintPassed(getConstraint("testInteger", new IntRange(1, 7)), 5);

        // must always pass for null value
View Full Code Here


        cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 123.45d);
        assertEquals(123.45d, cp.getMin());

        // validate that getMin returns the correct value when the range constraint is defined for the property (but no min constraint is defined)
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(123.45d, 678.9d));
        assertEquals(123.45d, cp.getMin());

        // validate that getMin returns the maximum of the min constraint and the lower bound of the range constraint
        //   1) validate where the lower bound of the range constraint is greater than the min constraint
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 1.23d);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(4.56d, 7.89d));
        assertEquals(4.56d, cp.getMin());

        //   2) validate where the min constraint is greater than the lower bound of the range constraint
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 4.56d);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 7.89d));
        assertEquals(4.56d, cp.getMin());
    }
View Full Code Here

        cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 123.45d);
        assertEquals(123.45d, cp.getMax());

        // validate that getMax returns the correct value when the range constraint is defined for the property (but no max constraint is defined)
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(123.45d, 678.9d));
        assertEquals(678.9d, cp.getMax());

        // validate that getMax returns the minimum of the max constraint and the upper bound of the range constraint
        //   1) validate where the upper bound of the range constraint is less than the max constraint
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 7.89d);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 4.56d));
        assertEquals(4.56d, cp.getMax());

        //   2) validate where the max constraint is less than the upper bound of the range constraint
        cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
        cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 4.56d);
        cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 7.89d));
        assertEquals(4.56d, cp.getMax());
    }
View Full Code Here

TOP

Related Classes of groovy.lang.ObjectRange

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.