@SpecAssertion(section = "6.2", id = "d"),
@SpecAssertion(section = "6.2", id = "f")
})
public void testDeclaredOn() {
Validator validator = TestUtil.getValidatorUnderTest();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( SubClass.class );
assertNotNull( beanDescriptor );
Set<ConstraintDescriptor<?>> descriptors = beanDescriptor.getConstraintsForProperty( "myField" )
.findConstraints()
.lookingAt( Scope.HIERARCHY )
.declaredOn( ElementType.TYPE )
.getConstraintDescriptors();
assertTrue( descriptors.size() == 0 );
descriptors = beanDescriptor.getConstraintsForProperty( "myField" )
.findConstraints()
.lookingAt( Scope.HIERARCHY )
.declaredOn( ElementType.METHOD )
.getConstraintDescriptors();
assertTrue( descriptors.size() == 0 );
descriptors = beanDescriptor.getConstraintsForProperty( "myField" )
.findConstraints()
.lookingAt( Scope.HIERARCHY )
.declaredOn( ElementType.FIELD )
.getConstraintDescriptors();
assertTrue( descriptors.size() == 2 );