Package org.springframework.validation

Examples of org.springframework.validation.BindException


        person.setAge(-1);
        person.setEmail("uri@b");
        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals(3, errors.getFieldErrorCount());

    }
View Full Code Here


        person.setAge(-1);
        person.setEmail("uri@b");
        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals(4, errors.getFieldErrorCount());

    }
View Full Code Here

        person.setNullableInteger(new Integer(3));

        AnnotationBeanValidationConfigurationLoader loader = new AnnotationBeanValidationConfigurationLoader();
        BeanValidator validator = new BeanValidator(loader);

        BindException errors = new BindException(person, "person");

        validator.validate(person, errors);

        assertTrue(errors.hasGlobalErrors());
        assertEquals(2, errors.getGlobalErrorCount());
        assertTrue(errors.hasFieldErrors());
        assertTrue(errors.hasFieldErrors("firstName"));
        assertTrue(errors.hasFieldErrors("lastName"));
        assertFalse(errors.hasFieldErrors("birthday"));
        assertEquals(1, errors.getFieldErrorCount("age"));
        assertEquals("Person.age[just.another.error.code]", errors.getFieldError("age").getCode());
        assertTrue(errors.hasFieldErrors("father"));
        assertTrue(errors.hasFieldErrors("mother.*"));
        assertTrue(errors.hasFieldErrors("friends"));
        assertTrue(errors.hasFieldErrors("address.street"));
        assertFalse(errors.hasFieldErrors("nullableString"));
        assertTrue(errors.hasFieldErrors("nullableInteger"));
        assertEquals("Address.street[not.null]", errors.getFieldError("address.street").getCode());


    }
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenAllValidatorsSupport() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), true);
        validator1.validate(object, errors);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), true);
        validator2.validate(object, errors);
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenOnlyOneValidatorSupports() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), true);
        validator1.validate(object, errors);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), false);
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenNoValidatorSupports() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), false);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), false);

        validatorControl1.replay();
View Full Code Here

        conditionControl.verify();
    }

    public void testValidate_WhenConditionCheckPass() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        conditionControl.expectAndReturn(condition.check(object), true);
        innerValidator.validate(object, errors);

        conditionControl.replay();
View Full Code Here

        innerValidatorControl.verify();
    }

    public void testValidate_WhenConditionCheckFail() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        conditionControl.expectAndReturn(condition.check(object), false);

        conditionControl.replay();
        innerValidatorControl.replay();
View Full Code Here

        person.setAge(-1);
        person.setEmail("uri@b");
        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals(3, errors.getFieldErrorCount());

    }
View Full Code Here

        person.setAge(-1);
        person.setEmail("uri@b");
        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals(4, errors.getFieldErrorCount());

    }
View Full Code Here

TOP

Related Classes of org.springframework.validation.BindException

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.