WildcardHelper { public boolean matches(String string, String expression) { if (expression.startsWith(WILDCARD_TOKEN)) { return string.endsWith(expression.substring(WILDCARD_TOKEN.length())); } return Objects.equals(expression, string); }  boolean matches(String string, String expression); static final String WILDCARD_TOKEN; }
@Test public void testMatchesAssertReturnTrueWhenMatches() { assertTrue(wildcardHelper.matches("ab", "*b")); }
@Test public void testMatchesAssertReturnFalseWhenDoesNotMatch() { assertFalse(wildcardHelper.matches("ab", "*c")); }
@Test public void testMatchesAssertDoesStringEqualWhenExpressionDoesNotStartWithWildcard() { assertTrue(wildcardHelper.matches("a*", "a*")); assertFalse(wildcardHelper.matches("ab", "a*")); }
@Test public void testMatchesAssertDoesStringEqualWhenExpressionDoesNotContainWildcard() { assertFalse(wildcardHelper.matches("a*", "ab")); assertTrue(wildcardHelper.matches("ab", "ab")); }
@Test public void testMatchesAssertWildcardOnlyMatchesAll() { assertTrue(wildcardHelper.matches("ab", "*")); assertTrue(wildcardHelper.matches("bc", "*")); assertTrue(wildcardHelper.matches("", "*")); }
@Test public void testMatchesAssertConsecutiveWildcardsOnlyMatchFirstWildcard() { assertFalse(wildcardHelper.matches("ab", "**")); assertTrue(wildcardHelper.matches("ab*", "**")); }