Package org.springmodules.validation.util.condition

Examples of org.springmodules.validation.util.condition.Condition


        // validation and recursively calling this method on them.
        CascadeValidation[] cascadeValidations = configuration.getCascadeValidations();
        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


        ruleControl.expectAndReturn(rule.getCondition(), condition);
        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

        ruleControl.expectAndReturn(rule.getCondition(), condition);
        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 boolean supports(Annotation annotation, Class clazz, PropertyDescriptor descriptor) {
        return IsFirstLetterCapitalized.class.isInstance(annotation);
    }

    public void handleAnnotation(Annotation annotation, Class clazz, PropertyDescriptor descriptor, MutableBeanValidationConfiguration configuration) {
        Condition cond = new AbstractCondition() {
            public boolean doCheck(Object object) {
                String text = (String)object;
                if (text.length() == 0) {
                    return false;
                }
View Full Code Here

    public boolean supports(Element element, Class clazz, PropertyDescriptor descriptor) {
        return element.getLocalName().equals("is-first-letter-capitalized");
    }

    public void handle(Element element, String propertyName, MutableBeanValidationConfiguration configuration) {
        Condition cond = new AbstractCondition() {
            public boolean doCheck(Object object) {
                String text = (String)object;
                if (text.length() == 0) {
                    return false;
                }
View Full Code Here

            // expected
        }
    }

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

        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

        ErrorArgumentsResolver argumentsResolver = extractArgumentsResolver(annotation);
        if (argumentsResolver != null) {
            rule.setErrorArgumentsResolver(argumentsResolver);
        }

        Condition applicabilityCondition = extractApplicabilityContidion(annotation);
        if (applicabilityCondition != null) {
            rule.setApplicabilityCondition(applicabilityCondition);
        }

        String[] applicableContexts = extractApplicableContexts(annotation);
View Full Code Here

        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

        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 {
            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

TOP

Related Classes of org.springmodules.validation.util.condition.Condition

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.