@Test public void shouldReturnAnArrayWithMatches() { String pattern = "p.d"; String[] words = { "pod", "pid", "pat", "por", "pwd" }; String[] result = dotRegularExpression.evaluate(words, pattern); String[] expectedResult = { "pod", "pid", "pwd" }; assertArrayEquals(expectedResult, result); }
public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't pass null objects as input."); } List<String> result = new ArrayList<String>(); for (String word : words) { if (matchDotRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); }
DotRegularExpression { public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't pass null objects as input."); } List<String> result = new ArrayList<String>(); for (String word : words) { if (matchDotRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); } }
DotRegularExpression { public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't pass null objects as input."); } List<String> result = new ArrayList<String>(); for (String word : words) { if (matchDotRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); }  }
DotRegularExpression { public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't pass null objects as input."); } List<String> result = new ArrayList<String>(); for (String word : words) { if (matchDotRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); }  String[] evaluate(String[] words, String pattern); }
DotRegularExpression { public String[] evaluate(String[] words, String pattern) { if (words == null || pattern == null) { throw new IllegalArgumentException("You can't pass null objects as input."); } List<String> result = new ArrayList<String>(); for (String word : words) { if (matchDotRegularExpression(word, pattern)) { result.add(word); } } return result.toArray(new String[result.size()]); }  String[] evaluate(String[] words, String pattern);  }