Package org.springmodules.validation.util.condition

Examples of org.springmodules.validation.util.condition.Condition.check()


        BeanWrapper wrapper = wrapBean(obj);
        for (int i=0; i<cascadeValidations.length; i++) {
            CascadeValidation cascadeValidation = cascadeValidations[i];
            Condition applicabilityCondition = cascadeValidation.getApplicabilityCondition();

            if (!applicabilityCondition.check(obj)) {
                continue;
            }

            String propertyName = cascadeValidation.getPropertyName();
            Class propertyType = wrapper.getPropertyType(propertyName);
View Full Code Here


        conditionControl.replay();
        ruleControl.replay();

        PropertyValidationRule propertyValidationRule = new PropertyValidationRule("name", rule);
        Condition propertyCondition = propertyValidationRule.getCondition();
        assertTrue(propertyCondition.check(new Person("Uri")));

        conditionControl.verify();
        ruleControl.verify();
    }
View Full Code Here

        conditionControl.replay();
        ruleControl.replay();

        PropertyValidationRule propertyValidationRule = new PropertyValidationRule("name", rule);
        Condition propertyCondition = propertyValidationRule.getCondition();
        assertFalse(propertyCondition.check(new Person("Uri")));

        conditionControl.verify();
        ruleControl.verify();
    }
View Full Code Here

        }
    }

    public void testCheck_Success() throws Exception {
        Condition condition = new PropertyBeanCondition("name", new StringCondition());
        assertTrue(condition.check(new Person("Uri", "Boness", 88)));
    }

    public void testCheck_SuccessWithNestedProperty() throws Exception {
        Condition condition = new PropertyBeanCondition("address.street", new StringCondition());
        assertTrue(condition.check(new Person("Uri", "Boness", 88, new Address("street"))));
View Full Code Here

        assertTrue(condition.check(new Person("Uri", "Boness", 88)));
    }

    public void testCheck_SuccessWithNestedProperty() throws Exception {
        Condition condition = new PropertyBeanCondition("address.street", new StringCondition());
        assertTrue(condition.check(new Person("Uri", "Boness", 88, new Address("street"))));
    }

    public void testCheck_Failure() throws Exception {
        Condition condition = new PropertyBeanCondition("age", new StringCondition());
        assertFalse(condition.check(new Person("Uri", "Boness", 88)));
View Full Code Here

        assertTrue(condition.check(new Person("Uri", "Boness", 88, new Address("street"))));
    }

    public void testCheck_Failure() throws Exception {
        Condition condition = new PropertyBeanCondition("age", new StringCondition());
        assertFalse(condition.check(new Person("Uri", "Boness", 88)));
    }

    public void testCheck_WhenBeanMissingThePropoerty() throws Exception {
        Condition condition = new PropertyBeanCondition("missingProperty", new StringCondition());
        try {
View Full Code Here

    }

    public void testCheck_WhenBeanMissingThePropoerty() throws Exception {
        Condition condition = new PropertyBeanCondition("missingProperty", new StringCondition());
        try {
            assertFalse(condition.check(new Person("Uri", "Boness", 88)));
            fail("An InvalidPropertyException must be thrown if the checked bean doesn't have the checked property");
        } catch (InvalidPropertyException ipe) {
            // expected
        }
    }
View Full Code Here

    }

    public void testCheck_WhenBeanHasNullInNestedPath() throws Exception {
        Condition condition = new PropertyBeanCondition("address.street", new StringCondition());
        try {
            assertFalse(condition.check(new Person("Uri", "Boness", 88)));
            fail("An InvalidPropertyException must be thrown if the checked bean has a null value in the nested property path");
        } catch (InvalidPropertyException ipe) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testCheck_Success() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition("name", "nickname");
        assertTrue(condition.check(new Person("boness", "boness", 88)));
    }

    public void testCheck_SuccessWithArray() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "nickname"});
        assertTrue(condition.check(new Person("boness", "boness", 88)));
View Full Code Here

        assertTrue(condition.check(new Person("boness", "boness", 88)));
    }

    public void testCheck_SuccessWithArray() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "nickname"});
        assertTrue(condition.check(new Person("boness", "boness", 88)));
    }

    public void testCheck_Failure() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition("name", "nickname");
        assertFalse(condition.check(new Person("uri", "boness", 88)));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.