Search in sources :

Example 96 with ValidatorFactory

use of javax.validation.ValidatorFactory in project tutorials by eugenp.

the class ContainerValidationIntegrationTest method setup.

@Before
public void setup() {
    ValidatorFactory factory = Validation.byDefaultProvider().configure().addValueExtractor(new ProfileValueExtractor()).buildValidatorFactory();
    validator = factory.getValidator();
}
Also used : ProfileValueExtractor(org.baeldung.valueextractors.ProfileValueExtractor) ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 97 with ValidatorFactory

use of javax.validation.ValidatorFactory in project tutorials by eugenp.

the class ValidationIntegrationTest method setup.

@Before
public void setup() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    validator = factory.getValidator();
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 98 with ValidatorFactory

use of javax.validation.ValidatorFactory in project tutorials by eugenp.

the class ValidationIntegrationTest method getExecutableValidator.

@Before
public void getExecutableValidator() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    this.executableValidator = factory.getValidator().forExecutables();
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) Before(org.junit.Before)

Example 99 with ValidatorFactory

use of javax.validation.ValidatorFactory in project service-authorization by reportportal.

the class AbstractLdapConfigTest method checkValidation.

@Test
public void checkValidation() {
    ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
    Validator validator = vf.getValidator();
    LdapConfig cfg = new LdapConfig();
    cfg.setEnabled(true);
    cfg.setBaseDn("someDN");
    cfg.setUrl("ldaps://localhost");
    Set<ConstraintViolation<LdapConfig>> violations = validator.validate(cfg);
    if (!violations.isEmpty()) {
        LOGGER.error("Violations found: " + Joiner.on("\n").join(violations));
    }
    Assert.assertThat(violations, Matchers.empty());
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) ConstraintViolation(javax.validation.ConstraintViolation) Validator(javax.validation.Validator) Test(org.junit.Test)

Example 100 with ValidatorFactory

use of javax.validation.ValidatorFactory in project service-authorization by reportportal.

the class AbstractAuthSequenceProviderTest method setUp.

@BeforeClass
public static void setUp() {
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    validator = factory.getValidator();
}
Also used : ValidatorFactory(javax.validation.ValidatorFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

ValidatorFactory (javax.validation.ValidatorFactory)106 Validator (javax.validation.Validator)31 Before (org.junit.Before)28 ConstraintViolation (javax.validation.ConstraintViolation)25 Test (org.junit.Test)17 BeforeClass (org.junit.BeforeClass)13 ConstraintViolationException (javax.validation.ConstraintViolationException)7 HibernateValidatorConfiguration (org.hibernate.validator.HibernateValidatorConfiguration)6 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)6 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 BeanManager (javax.enterprise.inject.spi.BeanManager)5 InitialContext (javax.naming.InitialContext)5 ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)5 HashSet (java.util.HashSet)4 NamingException (javax.naming.NamingException)4 ConstraintValidatorFactory (javax.validation.ConstraintValidatorFactory)4 ValidatorContext (javax.validation.ValidatorContext)4 HibernateValidator (org.hibernate.validator.HibernateValidator)4