IsNumberValidationMatcher implements ValidationMatcher { public void validate(String fieldName, String value, List<String> controlParameters, TestContext context) throws ValidationException { Double dValue; try { dValue = Double.parseDouble(value); } catch (Exception e) { throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'. Received value is '" + value + "' and is not a number", e); } if (dValue.isNaN() || dValue.isInfinite()) { throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'. Received value is '" + value + "' and not a number"); } }  void validate(String fieldName, String value, List<String> controlParameters, TestContext context);  }
@Test public void testValidateSuccess() { matcher.validate("field", "2", Arrays.asList("3"), context); matcher.validate("field", "-1", Arrays.asList("1"), context); matcher.validate("field", "-0.000000001", Arrays.asList("0"), context); matcher.validate("field", "0", Arrays.asList("aaa"), context); matcher.validate("field", "1E+07", Arrays.asList("aaa"), context); matcher.validate("field", "1E-7", Arrays.asList("aaa"), context); }