@Test public void addsBeanValidationInterceptorWithDefaultValidationMode() { Set<BapiInterceptor> interceptors = new HashSet<>(); final SessionManagerConfig config = new SessionManagerConfig(); TypeSafeActivator.activateBeanValidation(interceptors, config); assertThat(interceptors).hasSize(1); assertThat(interceptors.toArray()).hasAtLeastOneElementOfType(BeanValidationInterceptor.class); }
@SuppressWarnings("unused") static void activateBeanValidation(final Set<BapiInterceptor> bapiInterceptors, final SessionManagerConfig sessionManagerConfig) { try { ValidatorFactory factory = validatorFactoryFactory.buildValidatorFactory(); bapiInterceptors.add(new BeanValidationInterceptor(factory)); } catch (ValidationException e) { ValidationMode validationMode = sessionManagerConfig.getValidationMode(); if (validationMode == ValidationMode.AUTO) { LOGGER.warn("Bean Validation will not be used: Bean Validation API is in the classpath, " + "but default ValidatorFactory can not be built. " + "ValidationMode is AUTO, so startup will be continued.", e); } else { throw new HibersapException("Unable to build the default ValidatorFactory, ValidationMode is " + validationMode, e); } } }
TypeSafeActivator { @SuppressWarnings("unused") static void activateBeanValidation(final Set<BapiInterceptor> bapiInterceptors, final SessionManagerConfig sessionManagerConfig) { try { ValidatorFactory factory = validatorFactoryFactory.buildValidatorFactory(); bapiInterceptors.add(new BeanValidationInterceptor(factory)); } catch (ValidationException e) { ValidationMode validationMode = sessionManagerConfig.getValidationMode(); if (validationMode == ValidationMode.AUTO) { LOGGER.warn("Bean Validation will not be used: Bean Validation API is in the classpath, " + "but default ValidatorFactory can not be built. " + "ValidationMode is AUTO, so startup will be continued.", e); } else { throw new HibersapException("Unable to build the default ValidatorFactory, ValidationMode is " + validationMode, e); } } } }
TypeSafeActivator { @SuppressWarnings("unused") static void activateBeanValidation(final Set<BapiInterceptor> bapiInterceptors, final SessionManagerConfig sessionManagerConfig) { try { ValidatorFactory factory = validatorFactoryFactory.buildValidatorFactory(); bapiInterceptors.add(new BeanValidationInterceptor(factory)); } catch (ValidationException e) { ValidationMode validationMode = sessionManagerConfig.getValidationMode(); if (validationMode == ValidationMode.AUTO) { LOGGER.warn("Bean Validation will not be used: Bean Validation API is in the classpath, " + "but default ValidatorFactory can not be built. " + "ValidationMode is AUTO, so startup will be continued.", e); } else { throw new HibersapException("Unable to build the default ValidatorFactory, ValidationMode is " + validationMode, e); } } } private  TypeSafeActivator(); }
TypeSafeActivator { @SuppressWarnings("unused") static void activateBeanValidation(final Set<BapiInterceptor> bapiInterceptors, final SessionManagerConfig sessionManagerConfig) { try { ValidatorFactory factory = validatorFactoryFactory.buildValidatorFactory(); bapiInterceptors.add(new BeanValidationInterceptor(factory)); } catch (ValidationException e) { ValidationMode validationMode = sessionManagerConfig.getValidationMode(); if (validationMode == ValidationMode.AUTO) { LOGGER.warn("Bean Validation will not be used: Bean Validation API is in the classpath, " + "but default ValidatorFactory can not be built. " + "ValidationMode is AUTO, so startup will be continued.", e); } else { throw new HibersapException("Unable to build the default ValidatorFactory, ValidationMode is " + validationMode, e); } } } private  TypeSafeActivator();  }
TypeSafeActivator { @SuppressWarnings("unused") static void activateBeanValidation(final Set<BapiInterceptor> bapiInterceptors, final SessionManagerConfig sessionManagerConfig) { try { ValidatorFactory factory = validatorFactoryFactory.buildValidatorFactory(); bapiInterceptors.add(new BeanValidationInterceptor(factory)); } catch (ValidationException e) { ValidationMode validationMode = sessionManagerConfig.getValidationMode(); if (validationMode == ValidationMode.AUTO) { LOGGER.warn("Bean Validation will not be used: Bean Validation API is in the classpath, " + "but default ValidatorFactory can not be built. " + "ValidationMode is AUTO, so startup will be continued.", e); } else { throw new HibersapException("Unable to build the default ValidatorFactory, ValidationMode is " + validationMode, e); } } } private  TypeSafeActivator();   }