Package org.springmodules.validation.util.condition

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


    protected AbstractCompoundCondition createCondition(Condition[] conditions) {
        return new OrCondition(conditions);
    }

    public void testCheck_WhenAllAreFalse() throws Exception {
        Condition condition = createCondition(new Condition[]{
            createFalseCondition(),
            createFalseCondition(),
            createFalseCondition()
        });
        assertFalse(condition.check(new Object()));
    }
View Full Code Here


        });
        assertFalse(condition.check(new Object()));
    }

    public void testCheck_WhenOneIsTrue() throws Exception {
        Condition condition = createCondition(new Condition[]{
            createFalseCondition(),
            createFalseCondition(),
            createTrueCondition()
        });
        assertTrue(condition.check(new Object()));
    }
View Full Code Here

    protected AbstractCompoundCondition createCondition(Condition[] conditions) {
        return new AndCondition(conditions);
    }

    public void testCheck_WhenAllAreTrue() throws Exception {
        Condition condition = createCondition(new Condition[]{
            createTrueCondition(),
            createTrueCondition(),
            createTrueCondition()
        });
        assertTrue(condition.check(new Object()));
    }
View Full Code Here

        });
        assertTrue(condition.check(new Object()));
    }

    public void testCheck_WhenOneIsFalse() throws Exception {
        Condition condition = createCondition(new Condition[]{
            createFalseCondition(),
            createTrueCondition(),
            createTrueCondition()
        });
        assertFalse(condition.check(new Object()));
    }
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

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

    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

        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

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

        Condition applicabilityCondition = extractApplicabilityCondition(element);
        if (applicabilityCondition != null) {
            rule.setApplicabilityCondition(applicabilityCondition);
        }

        if (isConditionGloballyScoped(element)) {
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.