Examples of validateProperty()


Examples of javax.validation.Validator.validateProperty()

        author.getAddresses().add(adr);
        Country country = new Country();
        adr.setCountry(country);
        country.setISO2Code("too_long");

        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");
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

        country.setISO2Code("too_long");

        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

Examples of javax.validation.Validator.validateProperty()

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

        // Null propertyName
        try {
            validator.validateProperty(new Person(), null);
        } catch (IllegalArgumentException e) {
            // Correct
        }

        // Empty propertyName
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

            // Correct
        }

        // Empty propertyName
        try {
            validator.validateProperty(new Person(), "");
        } catch (IllegalArgumentException e) {
            // Correct
        }

        // Invalid propertyName
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

            // Correct
        }

        // Invalid propertyName
        try {
            validator.validateProperty(new Person(), "surname");
        } catch (IllegalArgumentException e) {
            // Correct
        }

    }
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

     * validate a property on a null object.
     */
    public void testValidatePropertyOnNullBean() {
        Validator validator = getValidator();
        try {
            validator.validateProperty(null, "class");
        } catch (IllegalArgumentException e) {
            // Correct
        }
    }

View Full Code Here

Examples of javax.validation.Validator.validateProperty()

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

Examples of javax.validation.Validator.validateProperty()

        Validator validator = getValidator();
        Car car = new Car("USd-298");
        assertEquals(car.getLicensePlateNumber(), PropertyAccess.getProperty(car, "licensePlateNumber"));

        Set<ConstraintViolation<Car>> violations =
            validator.validateProperty(car, "licensePlateNumber", First.class,
                org.apache.bval.jsr303.example.Second.class);
        assertCorrectNumberOfViolations(violations, 1);

        car.setLicensePlateNumber("USD-298");
        violations =
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

                org.apache.bval.jsr303.example.Second.class);
        assertCorrectNumberOfViolations(violations, 1);

        car.setLicensePlateNumber("USD-298");
        violations =
            validator.validateProperty(car, "licensePlateNumber", First.class,
                org.apache.bval.jsr303.example.Second.class);
        assertCorrectNumberOfViolations(violations, 0);
    }

    class Car {
View Full Code Here

Examples of javax.validation.Validator.validateProperty()

      throws Exception {
    Validator validator = getValidator();
    Car car = new Car("USd-298");
    assertEquals(car.getLicensePlateNumber(), PropertyAccess.getProperty(car, "licensePlateNumber"));

    Set<ConstraintViolation<Car>> violations = validator.validateProperty(
        car, "licensePlateNumber", First.class, org.apache.bval.jsr303.example.Second.class
    );
    assertCorrectNumberOfViolations(violations, 1);

    car.setLicensePlateNumber("USD-298");
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.