@Test @SpecAssertion(section = "8.2", id = "a") public void testValidBeanValidation11Mapping() { Validator validator = TestUtil.getConfigurationUnderTest() .addMapping(Version11InMappingXmlTest.class.getResourceAsStream(MAPPING_FILE)) .buildValidatorFactory() .getValidator(); assertFalse(validator.getConstraintsForClass(TestEntity.class).isBeanConstrained()); }
@Test @SpecAssertion(section = "7", id = "b") public void testXmlConfiguredValidatorConfigurationHasPrecedence() { Configuration<?> config = TestUtil.getConfigurationUnderTest(); InputStream in = getInputStreamForPath( "org/hibernate/beanvalidation/tck/tests/constraints/builtinconstraints/builtin-constraints-override.xml"); config.addMapping(in); Validator validator = config.buildValidatorFactory().getValidator(); DummyEntity dummy = new DummyEntity(); Set<ConstraintViolation<DummyEntity>> violations = validator.validate(dummy); assertCorrectNumberOfViolations(violations, 0); dummy.dummyProperty = "foobar"; violations = validator.validate(dummy); assertCorrectNumberOfViolations(violations, 1); }