Package javax.validation

Examples of javax.validation.Validator.validate()


        assertEquals(author.getCompany(), constraintViolation.getInvalidValue());
        assertEquals("author.company", constraintViolation.getPropertyPath().toString());

        author.setCompany("apache");

        constraintViolations = validator.validate(book, First.class, Second.class, Last.class);
        assertEquals(0, constraintViolations.size());
    }

    public void testGroupSequence() {
        Validator validator = getValidator();
View Full Code Here


        author.setFirstName("");
        Book book = new Book();
        book.setAuthor(author);

        Set<ConstraintViolation<Book>> constraintViolations =
              validator.validate(book, Book.All.class);
        assertEquals(2, constraintViolations.size());

        author.setFirstName("Kelvin");
        author.setLastName("Cline");
View Full Code Here

        assertEquals(2, constraintViolations.size());

        author.setFirstName("Kelvin");
        author.setLastName("Cline");

        constraintViolations = validator.validate(book, Book.All.class);
        ConstraintViolation constraintViolation = constraintViolations.iterator().next();
        assertEquals(1, constraintViolations.size());
        assertEquals("may not be null", constraintViolation.getMessage());
        assertEquals(book, constraintViolation.getRootBean());
        assertEquals(book.getTitle(), constraintViolation.getInvalidValue());
View Full Code Here

    public void testAccessStrategies_field_method() {
        AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
        AccessTestBusinessObjectSub o2 = new AccessTestBusinessObjectSub("3");
        Validator validator = getValidator();
        Set<ConstraintViolation<AccessTestBusinessObject>> errors =
              validator.validate(o1);
        assertTrue(errors.isEmpty());
        Set<ConstraintViolation<AccessTestBusinessObjectSub>> errors2 =
              validator.validate(o2);
        assertTrue(errors2.isEmpty());
View Full Code Here

        assertEquals("title", constraintViolation.getPropertyPath().toString());

        book.setTitle("247307892430798789024389798789");
        book.setSubtitle("f43u rlök fjöq3liu opiur ölw3kj rölkj d");

        constraintViolations = validator.validate(book, Book.All.class);
        assertEquals(1, constraintViolations.size());
    }

   
    /**
 
View Full Code Here

        Validator validator = getValidator();
        Set<ConstraintViolation<AccessTestBusinessObject>> errors =
              validator.validate(o1);
        assertTrue(errors.isEmpty());
        Set<ConstraintViolation<AccessTestBusinessObjectSub>> errors2 =
              validator.validate(o2);
        assertTrue(errors2.isEmpty());

        o2 = new AccessTestBusinessObjectSub("1");
        errors2 = validator.validate(o2);
        assertEquals(1, errors2.size());
View Full Code Here

        Set<ConstraintViolation<AccessTestBusinessObjectSub>> errors2 =
              validator.validate(o2);
        assertTrue(errors2.isEmpty());

        o2 = new AccessTestBusinessObjectSub("1");
        errors2 = validator.validate(o2);
        assertEquals(1, errors2.size());

        // assert, that getvar2() and getVar2() are both validated with their getter method
        o2 = new AccessTestBusinessObjectSub("3");
        o2.setVar2("1");
View Full Code Here

        // assert, that getvar2() and getVar2() are both validated with their getter method
        o2 = new AccessTestBusinessObjectSub("3");
        o2.setVar2("1");
        o2.setvar2("2");
        errors2 = validator.validate(o2);
        assertEquals(2, errors2.size());

        o2.setvar2("5");
        o2.setVar2("6");
        errors2 = validator.validate(o2);
View Full Code Here

        errors2 = validator.validate(o2);
        assertEquals(2, errors2.size());

        o2.setvar2("5");
        o2.setVar2("6");
        errors2 = validator.validate(o2);
        assertEquals(0, errors2.size());

        o2.setvar2("5");
        o2.setVar2("-1");
        errors2 = validator.validate(o2);
View Full Code Here

        errors2 = validator.validate(o2);
        assertEquals(0, errors2.size());

        o2.setvar2("5");
        o2.setVar2("-1");
        errors2 = validator.validate(o2);
        assertEquals(1, errors2.size());
    }

    public void testAccessStrategies_on_children() {
        AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
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.