AsteriskRegularExpression { public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't use null instances as input."); } List<String> result = new LinkedList<String>(); for (String word : words) { if (matchAsteriskRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); }  String[] evaluate(String[] words, String pattern);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullInstancesAsInput() { asteriskRegularExpression.evaluate(null, null); }
@Test public void shouldReturnAnEmptyArrayIfTheArrayIsEmpty() { String pattern = "p*d"; String[] words = { }; String[] result = asteriskRegularExpression.evaluate(words, pattern); assertEquals(0, result.length); }
@Test public void shouldReturnAnEmptyArrayIfPatternDoesNotMatch() { String pattern = "p*d"; String[] words = { "ana", "test1", "test2" }; String[] result = asteriskRegularExpression.evaluate(words, pattern); assertEquals(0, result.length); }
@Test public void shouldReturnAnArrayWithMatches() { String pattern = "p*d"; String[] words = { "pod", "pid", "pat", "por", "pwd" }; String[] result = asteriskRegularExpression.evaluate(words, pattern); String[] expectedResult = { "pod", "pid", "pwd" }; assertArrayEquals(expectedResult, result); }