Package de.huepattl.playground.validation.validator

Examples of de.huepattl.playground.validation.validator.SimpleConstraintValidator.validate()


        /*
         * Validate and report.
         */
        SimpleConstraintValidator defaultValidator = new SimpleConstraintValidator();
        Set<ConstraintViolation<Object>> validationResult = defaultValidator.validate(employee);

        super.printValidationMessages(validationResult);
        assertTrue(validationResult.isEmpty());
    }

View Full Code Here


        /*
         * Validate and report.
         */
        SimpleConstraintValidator defaultValidator = new SimpleConstraintValidator();
        Set<ConstraintViolation<Object>> validationResult = defaultValidator.validate(employee);

        super.printValidationMessages(validationResult);
        assertFalse(validationResult.isEmpty());
    }

View Full Code Here

        /*
         * Validate with implicit default group.
         * Expecting NotNull to raise error.
         */
        employee.setStricterValueThanOthers(null);
        validationResult = defaultValidator.validate(employee);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.size() == 1);

        /*
         * Validate with implicit default group.
View Full Code Here

         * Validate with implicit default group.
         * Expecting no issue because value is not null. However, the value is too short but will not be thrown
         * because that constraint is only active for the StricterValidationGroup, which is not active here.
         */
        employee.setStricterValueThanOthers("A");
        validationResult = defaultValidator.validate(employee);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.isEmpty());

        /*
         * Validate with explicit default StricterValidationGroup group.
View Full Code Here

        /*
         * Validate with explicit default StricterValidationGroup group.
         * Expecting error because value is too short.
         */
        employee.setStricterValueThanOthers("A");
        validationResult = defaultValidator.validate(employee, StricterValidationGroup.class);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.size() == 1);

        /*
         *  Validate with explicit default StricterValidationGroup group.
View Full Code Here

        /*
         *  Validate with explicit default StricterValidationGroup group.
         *  Expecting no error because value os long enough.
         */
        employee.setStricterValueThanOthers("ABC");
        validationResult = defaultValidator.validate(employee, StricterValidationGroup.class);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.isEmpty());

        /*
         * Validate with explicit default StricterValidationGroup group.
View Full Code Here

         * Validate with explicit default StricterValidationGroup group.
         * Expecting NotNull NOT to fire because it is in the default group
         * and thus does not apply.
         */
        employee.setStricterValueThanOthers(null); //notnull does not apply!
        validationResult = defaultValidator.validate(employee, StricterValidationGroup.class);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.isEmpty());

        /*
         * Validate with default and StricterValidationGroup groups.
View Full Code Here

        /*
         * Validate with default and StricterValidationGroup groups.
         * Expecintg NotNull to apply because we now took the default group back into the game.
         */
        employee.setStricterValueThanOthers(null); //notnull does not apply!
        validationResult = defaultValidator.validate(employee, Default.class, StricterValidationGroup.class);
        super.printValidationMessages(validationResult);
        assertTrue(validationResult.size() == 1);
    }

    /**
 
View Full Code Here

        Employee employee = super.newValidBean();
        employee.setUsingSeverity("A"); // too short
        boolean foundWarning = false;

        SimpleConstraintValidator defaultValidator = new SimpleConstraintValidator();
        Set<ConstraintViolation<Object>> validationResult = defaultValidator.validate(employee);

        for (final ConstraintViolation cv : validationResult) {
            foundWarning = cv.getConstraintDescriptor().getPayload().contains(Severity.WARNING.class);
        }
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.