@SpecAssertion(section = "8.1.1", id = "e"),
@SpecAssertion(section = "8.1.1", id = "a")
})
public void testEntityConfiguredViaAnnotationsAndXml() {
Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Package.class );
assertTrue( beanDescriptor.isBeanConstrained(), "The bean should be constrained" );
assertEquals(
beanDescriptor.getConstraintsForProperty( "maxWeight" ).getConstraintDescriptors().size(),
2,
"With xml configuration there should be two constraints."
);
Configuration<?> config = TestUtil.getConfigurationUnderTest();
config.ignoreXmlConfiguration();
validator = config.buildValidatorFactory().getValidator();
beanDescriptor = validator.getConstraintsForClass( Package.class );
assertTrue(
beanDescriptor.isBeanConstrained(),
"Without xml there should be only one constraint."
);
assertEquals(
beanDescriptor.getConstraintsForProperty( "maxWeight" ).getConstraintDescriptors().size(),
1,
"Without xml there should be only one constraint."
);
}