@Override public boolean equal(T actual, T expected) { String actualString = actual.toString(); String expectedString = expected.toString(); try { Pattern pattern = isStaticPattern() ? expectedPattern : Pattern .compile(expectedString); if (!pattern.matcher(actualString).matches()) { throw new ValueMatcherException(getPatternType() + " expected pattern did not match value", pattern.toString(), actualString); } } catch (PatternSyntaxException e) { throw new ValueMatcherException(getPatternType() + " expected pattern invalid: " + e.getMessage(), e, expectedString, actualString); } return true; }
/** * Identify that the comparison failed * @param field Which field failed * @param exception exception containing details of match failure * @return result of comparision */ public JSONCompareResult fail(String field, ValueMatcherException exception) { fail(field + ": " + exception.getMessage(), exception.getExpected(), exception.getActual()); return this; }
/** * Identify that the comparison failed * @param field Which field failed * @param exception exception containing details of match failure * @return result of comparision */ public JSONCompareResult fail(String field, ValueMatcherException exception) { fail(field + ": " + exception.getMessage(), exception.getExpected(), exception.getActual()); return this; }
@Override public boolean equal(T actual, T expected) { String actualString = actual.toString(); String expectedString = expected.toString(); try { Pattern pattern = isStaticPattern() ? expectedPattern : Pattern .compile(expectedString); if (!pattern.matcher(actualString).matches()) { throw new ValueMatcherException(getPatternType() + " expected pattern did not match value", pattern.toString(), actualString); } } catch (PatternSyntaxException e) { throw new ValueMatcherException(getPatternType() + " expected pattern invalid: " + e.getMessage(), e, expectedString, actualString); } return true; }