Package javax.validation

Examples of javax.validation.Validator.validateValue()


        Set<ConstraintViolation<Author>> iv = v.validateProperty(author, propPath);
        Assert.assertEquals(1, iv.size());
        country.setISO2Code("23");
        iv = v.validateProperty(author, propPath);
        Assert.assertEquals(0, iv.size());
        iv = v.validateValue(Author.class, propPath, "345");
        Assert.assertEquals(1, iv.size());
        iv = v.validateValue(Author.class, propPath, "34");
        Assert.assertEquals(0, iv.size());
    }
View Full Code Here


        country.setISO2Code("23");
        iv = v.validateProperty(author, propPath);
        Assert.assertEquals(0, iv.size());
        iv = v.validateValue(Author.class, propPath, "345");
        Assert.assertEquals(1, iv.size());
        iv = v.validateValue(Author.class, propPath, "34");
        Assert.assertEquals(0, iv.size());
    }

    public void testMetadataAPI() {
        Validator bookValidator = getValidator();
View Full Code Here

     * <code>null</code> class.
     */
    public void testValidateValueOnNullClass() {
        Validator validator = getValidator();
        try {
            validator.validateValue(null, "class", Object.class);
            Assert.fail("No exception thrown when passing null as group array");
        } catch (IllegalArgumentException e) {
            // Correct
        }
    }
View Full Code Here

    public void testValidateValueInvalidPropertyName() {
        Validator validator = getValidator();

        // Null propertyName
        try {
            validator.validateValue(Person.class, null, "John");
        } catch (IllegalArgumentException e) {
            // Correct
        }

        // Empty propertyName
View Full Code Here

            // Correct
        }

        // Empty propertyName
        try {
            validator.validateValue(Person.class, "", "John");
        } catch (IllegalArgumentException e) {
            // Correct
        }

        // Invalid propertyName
View Full Code Here

            // Correct
        }

        // Invalid propertyName
        try {
            validator.validateValue(Person.class, "unexistant", "John");
        } catch (IllegalArgumentException e) {
            // Correct
        }
    }
View Full Code Here

     */
    public void testValidateValueNullGroup() {
        Validator validator = getValidator();
        try {
            Class<?>[] groups = null;
            validator.validateValue(Person.class, "name", "John", groups);
            Assert.fail("No exception thrown when passing null as group array");
        } catch (IllegalArgumentException e) {
            // Correct
        }
    }
View Full Code Here

    }

    public void testValidateValue() {
        Validator validator = getValidator();
        assertTrue(
              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
View Full Code Here

    public void testValidateValue() {
        Validator validator = getValidator();
        assertTrue(
              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
        // tests for issue 22: validation of unknown field cause ValidationException
View Full Code Here

              validator.validateValue(Book.class, "subtitle", "123456789098765432").isEmpty());
        assertFalse(validator.validateValue(Book.class, "subtitle",
              "123456789098765432123412345678909876543212341234564567890987654321234",
              Second.class).isEmpty());
        // tests for issue 22: validation of a field without any constraints
        assertEquals(0, validator.validateValue(Book.class, "unconstraintField", 4).size());
        // tests for issue 22: validation of unknown field cause ValidationException
        try {
            validator.validateValue(Book.class, "unknownProperty", 4);
            fail("unknownProperty not detected");
        } catch (IllegalArgumentException ex) {
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.