IntegerValidator implements Validator<Integer> { @Override public void validate(String parameterName, Integer value) throws ValidationException { if (!range.contains(value)) { throw new ValidationException( "Expected value in " + range.toString() + " for parameter '" + parameterName + "' but value is " + value); } } IntegerValidator();  IntegerValidator(int minValue);  IntegerValidator(int minValue, int maxValue); @Override void validate(String parameterName, Integer value);  }
@Test public void testValidateGreaterThanOrEqualsValidInput1() throws ValidationException { new IntegerValidator(7).validate("param", 7); }
@Test public void testValidateGreaterThanOrEqualsValidInput2() throws ValidationException { new IntegerValidator(7).validate("param", 42); }
@Test(expected = ParameterException.class) public void testValidateBoundedInvalidInput1() throws ValidationException { new IntegerValidator(7, 10).validate("param", 6); }
@Test(expected = ParameterException.class) public void testValidateBoundedInvalidInput2() throws ValidationException { new IntegerValidator(7, 10).validate("param", 11); }
@Test public void testValidateBoundedValidInput1() throws ValidationException { new IntegerValidator(7, 10).validate("param", 7); }
@Test public void testValidateBoundedValidInput2() throws ValidationException { new IntegerValidator(7, 10).validate("param", 10); }
@Test public void testValidateAcceptAllIntegersValidInput() throws ValidationException { getInstance().validate("param", 42); }
@Test(expected = NullPointerException.class) public void testValidateAcceptAllIntegersInvalidInput() throws ValidationException { getInstance().validate("param", null); }
@Test(expected = ParameterException.class) public void testValidateGreaterThanOrEqualsInvalidInput() throws ValidationException { new IntegerValidator(7).validate("param", 6); }