### Question:
NamePatternMatcher implements NameFilter { public static String[] tokenizePattern(String pattern) { if (pattern == null || pattern.isEmpty()) { return EMPTY_ARRAY; } String[] patterns = COMMA.split(pattern); if (patterns.length == 0) { return EMPTY_ARRAY; } for (int i = 0; i < patterns.length; i++) { patterns[i] = "^" + patterns[i].replaceAll("[*?]", ".$0") + "$"; } return patterns; } NamePatternMatcher(Pattern[] itemIncludeFilters, Pattern[] itemExcludeFilters); static NamePatternMatcher build(Logger logger, String includePattern, String excludePattern); static Pattern[] createPatterns(Logger logger, String patternString); static String[] tokenizePattern(String pattern); @Override boolean isIncluded(String string); static final NameFilter EXCLUDE_ALL; }### Answer:
@Test public void testTokenizer() { String[] nullFilters = NamePatternMatcher.tokenizePattern(null); assertEquals(0, nullFilters.length); String[] filters = NamePatternMatcher.tokenizePattern("billing_*,user?"); assertEquals(2, filters.length); assertEquals("^billing_.*$", filters[0]); assertEquals("^user.?$", filters[1]); }
@Test public void testTokenizerEntities() { String includePattern = "Organization,SecGroup,SecIndividual"; String[] filters = NamePatternMatcher.tokenizePattern(includePattern); assertEquals(3, filters.length); assertEquals("^Organization$", filters[0]); assertEquals("^SecGroup$", filters[1]); assertEquals("^SecIndividual$", filters[2]); }