public IntegrationTest() { final DefaultConstraintMapping mapping = new DefaultConstraintMapping(); mapping.constraintDefinition(UniqueProperty.class).validatedBy(UniqnenessValidator.class); final ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class).configure() .addMapping(mapping).buildValidatorFactory(); validator = validatorFactory.getValidator(); }
public ValidatorFactoryImpl513(ConfigurationState configurationState) { this.messageInterpolator = configurationState.getMessageInterpolator(); this.traversableResolver = configurationState.getTraversableResolver(); this.parameterNameProvider = configurationState.getParameterNameProvider(); this.beanMetaDataManagerMap = Collections .synchronizedMap(new IdentityHashMap<ParameterNameProvider, BeanMetaDataManager513>()); this.constraintHelper = new ConstraintHelper(); this.typeResolutionHelper = new TypeResolutionHelper(); this.executableHelper = new ExecutableHelper(typeResolutionHelper); // HV-302; don't load XmlMappingParser if not necessary if (configurationState.getMappingStreams().isEmpty()) { this.xmlMetaDataProvider = null; } else { this.xmlMetaDataProvider = new XmlMetaDataProvider(constraintHelper, parameterNameProvider, configurationState.getMappingStreams()); } Map<String, String> properties = configurationState.getProperties(); boolean tmpFailFast = false; List<ValidatedValueUnwrapper<?>> tmpValidatedValueHandlers = newArrayList(5); Set<DefaultConstraintMapping> tmpConstraintMappings = newHashSet(); if (configurationState instanceof ConfigurationImpl) { ConfigurationImpl hibernateSpecificConfig = (ConfigurationImpl) configurationState; if (hibernateSpecificConfig.getProgrammaticMappings().size() > 0) { tmpConstraintMappings.addAll(hibernateSpecificConfig.getProgrammaticMappings()); } // check whether fail fast is programmatically enabled tmpFailFast = hibernateSpecificConfig.getFailFast(); tmpValidatedValueHandlers.addAll(hibernateSpecificConfig.getValidatedValueHandlers()); } this.constraintMappings = Collections.unmodifiableSet(tmpConstraintMappings); tmpFailFast = checkPropertiesForFailFast(properties, tmpFailFast); this.failFast = tmpFailFast; tmpValidatedValueHandlers.addAll(getPropertyConfiguredValidatedValueHandlers(properties)); this.validatedValueHandlers = Collections.unmodifiableList(tmpValidatedValueHandlers); this.constraintValidatorManager = new ConstraintValidatorManager( configurationState.getConstraintValidatorFactory()); }
public ProgrammaticMetaDataProvider513(ConstraintHelper constraintHelper, ParameterNameProvider parameterNameProvider, Set<DefaultConstraintMapping> constraintMappings) { super(constraintHelper, parameterNameProvider, constraintMappings); }