Package org.springmodules.validation.util.condition

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


        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)));
    }

    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


        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)));
    }

    public void testCheck_WithMissingPropertyInBean() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "missingProperty"});
        try {
View Full Code Here

    }

    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

        }
    }

    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"))));
    }

    public void testCheck_WithNullInNestedPropertyPath() throws Exception {
        Condition condition = new EqualPropertiesBeanCondition(new String[]{"name", "address.street"});
        try {
View Full Code Here

    }

    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

        Object object = new Object();
        predicateControl.expectAndReturn(predicate.evaluate(object), true);
        predicateControl.replay();

        Condition condition = new CommonsPredicateCondition(predicate);
        assertTrue(condition.check(object));

        predicateControl.verify();
    }

    public void testCheck_Failure() throws Exception {
View Full Code Here

        Object object = new Object();
        predicateControl.expectAndReturn(predicate.evaluate(object), false);
        predicateControl.replay();

        Condition condition = new CommonsPredicateCondition(predicate);
        assertFalse(condition.check(object));

        predicateControl.verify();
    }
}
View Full Code Here

        }
    }

    public void testCheck_Success() throws Exception {
        Condition condition = new NotCondition(createFalseCondition());
        assertTrue(condition.check(new Object()));
    }

    public void testCheck_Failure() throws Exception {
        Condition condition = new NotCondition(createTrueCondition());
        assertFalse(condition.check(new Object()));
View Full Code Here

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

    public void testCheck_Failure() throws Exception {
        Condition condition = new NotCondition(createTrueCondition());
        assertFalse(condition.check(new Object()));
    }

    //=============================================== Helper Methods ===================================================

    protected Condition createTrueCondition() {
View Full Code Here

        }
    }

    public void testCheck_Success() throws Exception {
        Condition condition = new InstanceOfCondition(String.class);
        assertTrue(condition.check("test"));
    }

    public void testCheck_SuccessWithInheritance() throws Exception {
        Condition condition = new InstanceOfCondition(Collection.class);
        assertTrue(condition.check(new ArrayList()));
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.