@Test public void shouldNotEvaluateStringDoesNotMatchRegex() { String testTest = "not parsable as a number even though it contains 123 numbers"; String regex = "^\\d+$"; ComparisonResult comparisonResult = placeholderHandler.evaluate(testTest, regex); assertThat(comparisonResult, equalTo(ComparisonResult.DIFFERENT)); }
@Override public ComparisonResult evaluate(String testText, String... param) { if (param.length > 0 && param[0] != null && !param[0].equals("")) { try { final Pattern pattern = Pattern.compile(param[0].trim()); if (testText != null && evaluate(testText.trim(), pattern)) { return EQUAL; } } catch(PatternSyntaxException e) { throw new XMLUnitException(e.getMessage(), e); } } return DIFFERENT; }
MatchesRegexPlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(String testText, String... param) { if (param.length > 0 && param[0] != null && !param[0].equals("")) { try { final Pattern pattern = Pattern.compile(param[0].trim()); if (testText != null && evaluate(testText.trim(), pattern)) { return EQUAL; } } catch(PatternSyntaxException e) { throw new XMLUnitException(e.getMessage(), e); } } return DIFFERENT; } }
MatchesRegexPlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(String testText, String... param) { if (param.length > 0 && param[0] != null && !param[0].equals("")) { try { final Pattern pattern = Pattern.compile(param[0].trim()); if (testText != null && evaluate(testText.trim(), pattern)) { return EQUAL; } } catch(PatternSyntaxException e) { throw new XMLUnitException(e.getMessage(), e); } } return DIFFERENT; }  }
MatchesRegexPlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(String testText, String... param) { if (param.length > 0 && param[0] != null && !param[0].equals("")) { try { final Pattern pattern = Pattern.compile(param[0].trim()); if (testText != null && evaluate(testText.trim(), pattern)) { return EQUAL; } } catch(PatternSyntaxException e) { throw new XMLUnitException(e.getMessage(), e); } } return DIFFERENT; }  @Override String getKeyword(); @Override ComparisonResult evaluate(String testText, String... param); }
MatchesRegexPlaceholderHandler implements PlaceholderHandler { @Override public ComparisonResult evaluate(String testText, String... param) { if (param.length > 0 && param[0] != null && !param[0].equals("")) { try { final Pattern pattern = Pattern.compile(param[0].trim()); if (testText != null && evaluate(testText.trim(), pattern)) { return EQUAL; } } catch(PatternSyntaxException e) { throw new XMLUnitException(e.getMessage(), e); } } return DIFFERENT; }  @Override String getKeyword(); @Override ComparisonResult evaluate(String testText, String... param);  }