public class InheritanceTest {
private static class Base {
@Min(5)
private final int i = 0;
}
private static class Sub extends Base {
private final int i = 0;
}
@Test
public void testInheritance() {
Set<ConstraintViolation<Sub>> violations = Validation
.buildDefaultValidatorFactory()
.getValidator()
.validate( new Sub() );
assertTrue(
violations.isEmpty(),
"There should be no violations as the constraints from the supertype field shouldn't apply."
);
}
}