Package org.drools.ide.common.client.factconstraints

Examples of org.drools.ide.common.client.factconstraints.ValidationResult


    }

    @Test @Ignore
    public void testValidConstraint(){

        ValidationResult result = cons.validate("Bart", conf);
        assertTrue(result.isSuccess());

        result = cons.validate("", conf);
        assertFalse(result.isSuccess());

        result = cons.validate("bart", conf);
        assertFalse(result.isSuccess());

        result = cons.validate(new Long("12"), conf);
        assertFalse(result.isSuccess());

        result = cons.validate(12L, conf);
        assertFalse(result.isSuccess());

        result = cons.validate(12.8, conf);
        assertFalse(result.isSuccess());
    }
View Full Code Here


    }

    @Test @Ignore
    public void testInvalidConstraint(){

        ValidationResult result = cons.validate(null, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: "+result.getMessage());

    }
View Full Code Here

    @Test
    public void testValidConstraint() {
        Constraint cons = new IntegerConstraint();

        ValidationResult result = cons.validate(12, conf);
        assertTrue(result.isSuccess());

        result = cons.validate(new Integer("12"), conf);
        assertTrue(result.isSuccess());

        result = cons.validate("12", conf);
        assertTrue(result.isSuccess());

    }
View Full Code Here

    @Test
    public void testInvalidConstraint() {
        Constraint cons = new IntegerConstraint();

        ValidationResult result = cons.validate(new Object(), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("ABC", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(null, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(new Long("12"), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12L, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(12.8, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());
    }
View Full Code Here

    }

    @Test
    public void testValidConstraint(){

        ValidationResult result = cons.validate(new Object(), conf);
        assertTrue(result.isSuccess());

        result = cons.validate("", conf);
        assertTrue(result.isSuccess());

        result = cons.validate("ABC", conf);
        assertTrue(result.isSuccess());

        result = cons.validate(new Long("12"), conf);
        assertTrue(result.isSuccess());

        result = cons.validate(12L, conf);
        assertTrue(result.isSuccess());

        result = cons.validate(12.8, conf);
        assertTrue(result.isSuccess());
    }
View Full Code Here

    }

    @Test
    public void testInvalidConstraint(){

        ValidationResult result = cons.validate(null, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: "+result.getMessage());

    }
View Full Code Here

    public void testValidConstraint() {

        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MIN, "-0.5");
        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MAX, "100");

        ValidationResult result = cons.validate(12, conf);
        assertTrue(result.isSuccess());

        result = cons.validate(new Integer("12"), conf);
        assertTrue(result.isSuccess());

        result = cons.validate("12", conf);
        assertTrue(result.isSuccess());

        result = cons.validate(0.6, conf);
        assertTrue(result.isSuccess());

        result = cons.validate(new Float("-0.3"), conf);
        assertTrue(result.isSuccess());

        result = cons.validate("90.76", conf);
        assertTrue(result.isSuccess());

    }
View Full Code Here

    public void testInvalidConstraint() {

        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MIN, "-0.5");
        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MAX, "100");

        ValidationResult result = cons.validate(new Object(), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(null, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate("ABC", conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(new Long("-100"), conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(-0.5, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());

        result = cons.validate(100, conf);
        assertFalse(result.isSuccess());
        System.out.println("Message: " + result.getMessage());


    }
View Full Code Here

     * @deprecated Use drools-verifier instead of this method:
     * {@link #getVerifierRule(org.drools.ide.common.factconstraints.client.ConstraintConfiguration) }
     */
    @Deprecated
    public ValidationResult validate(Object value, ConstraintConfiguration config) {
        ValidationResult result = new ValidationResult();
        result.setSuccess(true);

        return result;
    }
View Full Code Here

        return this.createVerifierRuleTemplate(config, context, "Integer_Field_Constraint", constraints, "The value must be an integer"); //I18N
    }

    @Override
    public ValidationResult validate(Object value, ConstraintConfiguration config) {
        ValidationResult result = new ValidationResult();

        if (value == null){
            result.setSuccess(false);
            result.setMessage("The value is null"); //TODO: I18N
        }else if (value instanceof Integer){
            result.setSuccess(true);
        }else if (value instanceof String){
            try{
                Integer.parseInt((String)value);
                result.setSuccess(true);
            } catch(NumberFormatException ex){
                result.setSuccess(false);
                result.setMessage(ex.getMessage()); //TODO: I18N
            }
        }else{
            result.setSuccess(false);
            result.setMessage("Invalid value type "+value.getClass().getName()); //TODO: I18N
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.factconstraints.ValidationResult

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.