Source:
public void testDigitsConstraint() { Validator validator = TestUtil.getValidatorUnderTest(); DigitsDummyEntity dummy = new DigitsDummyEntity(); dummy.intPrimitive = 42; dummy.longPrimitive = 42; dummy.bytePrimitive = 42; dummy.shortPrimitive = 42; Set<ConstraintViolation<DigitsDummyEntity>> constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 4 ); assertCorrectPropertyPaths( constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" ); dummy.intPrimitive = 1; dummy.longPrimitive = 1; dummy.bytePrimitive = 1; dummy.shortPrimitive = 1; dummy.intObject = Integer.valueOf( "102" ); dummy.longObject = Long.valueOf( "12345" ); dummy.byteObject = Byte.parseByte( "111" ); dummy.shortObject = Short.parseShort( "1234" ); dummy.bigDecimal = BigDecimal.valueOf( 102 ); dummy.bigInteger = BigInteger.valueOf( 102 ); constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 6 ); assertCorrectPropertyPaths( constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" ); dummy.intObject = Integer.valueOf( "1" ); dummy.longObject = Long.valueOf( "1" ); dummy.byteObject = Byte.parseByte( "1" ); dummy.shortObject = Short.parseShort( "1" ); dummy.bigDecimal = BigDecimal.valueOf( 1.93 ); dummy.bigInteger = BigInteger.valueOf( 5 ); constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 0 ); }

Target:
public void testDigitsConstraint() { Validator validator = TestUtil.getValidatorUnderTest(); DigitsDummyEntity dummy = new DigitsDummyEntity(); dummy.intPrimitive = 42; dummy.longPrimitive = 42; dummy.bytePrimitive = 42; dummy.shortPrimitive = 42; Set<ConstraintViolation<DigitsDummyEntity>> constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 4 ); assertThat( constraintViolations ).containsOnlyPaths( pathWith() .property( "bytePrimitive" ), pathWith() .property( "intPrimitive" ), pathWith() .property( "longPrimitive" ), pathWith() .property( "shortPrimitive" ) ); dummy.intPrimitive = 1; dummy.longPrimitive = 1; dummy.bytePrimitive = 1; dummy.shortPrimitive = 1; dummy.intObject = Integer.valueOf( "102" ); dummy.longObject = Long.valueOf( "12345" ); dummy.byteObject = Byte.parseByte( "111" ); dummy.shortObject = Short.parseShort( "1234" ); dummy.bigDecimal = BigDecimal.valueOf( 102 ); dummy.bigInteger = BigInteger.valueOf( 102 ); constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 6 ); assertThat( constraintViolations ).containsOnlyPaths( pathWith() .property( "byteObject" ), pathWith() .property( "intObject" ), pathWith() .property( "longObject" ), pathWith() .property( "shortObject" ), pathWith() .property( "bigDecimal" ), pathWith() .property( "bigInteger" ) ); dummy.intObject = Integer.valueOf( "1" ); dummy.longObject = Long.valueOf( "1" ); dummy.byteObject = Byte.parseByte( "1" ); dummy.shortObject = Short.parseShort( "1" ); dummy.bigDecimal = BigDecimal.valueOf( 1.93 ); dummy.bigInteger = BigInteger.valueOf( 5 ); constraintViolations = validator.validate( dummy ); assertNumberOfViolations( constraintViolations, 0 ); }