Package org.springmodules.validation.util.condition

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


            // expected
        }
    }

    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


            // expected
        }
    }

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

        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

        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

        Condition condition = new EqualPropertiesBeanCondition("name", "nickname");
        assertFalse(condition.check(new Person("uri", "boness", 88)));
    }

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

        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "nickname"});
        assertFalse(condition.check(new Person("uri", "boness", 88)));
    }

    public void testCheck_WithMissingPropertyInBean() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "missingProperty"});
        try {
            condition.check(new Person("uri", "boness", 88));
            fail("An InvalidPropertyException if the checked bean doesn't have one of the compared properties");
        } catch (InvalidPropertyException ipe) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }

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

        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "address.street"});
        assertTrue(condition.check(new Person("uri", "boness", 88, new Address("uri"))));
    }

    public void testCheck_WithNullInNestedPropertyPath() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "address.street"});
        try {
            condition.check(new Person("uri", "boness", 88)); // the address property here is null
            fail("An InvalidPropertyException if the checked bean holds null in the nested property path");
        } catch (InvalidPropertyException ipe) {
            // expected
        }
    }
View Full Code Here

        Class annotationClass = annotation.annotationType();
        ValidatorClass validatorClassAnnotation = (ValidatorClass) annotationClass.getAnnotation(ValidatorClass.class);
        Class<? extends Validator> validatorClass = validatorClassAnnotation.value();
        Validator validator = (Validator) BeanUtils.instantiateClass(validatorClass);
        validator.initialize(annotation);
        Condition condition = Conditions.property(descriptor.getName(), new HibernateValidatorCondition(validator));
        String message;
        try {
            message = (String) annotationClass.getMethod("message").invoke(annotation);
        } catch (NoSuchMethodException nsme) {
            message = annotationClass.getSimpleName() + ".error";
View Full Code Here

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

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

        String[] applicableContexts = extractApplicableContexts(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.