MatchRule { public boolean matches(Transaction transaction) { checkNotNull(transaction); return pattern().matcher(transaction.getDescription()).find(); } private  MatchRule(String regex); static MatchRule withPattern(String pattern); static MatchRule withPatternFromText(String matchDescription); boolean matches(Transaction transaction); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void matches() { MatchRule matchRule = MatchRule.withPattern("abc"); assertMatches(matchRule, "123 abc def"); assertMatches(matchRule, "abc"); assertMatches(matchRule, "ABC"); assertMatches(matchRule, "ABc"); assertMatches(matchRule, "1234abcfsdf"); assertNoMatches(matchRule, "absdfc"); }