HandlerPatterns { public static List<String> getNames(String nameList) { String[] names = nameList.split(","); List<String> results = new LinkedList<>(); for ( String p : names) { String configName = p.trim(); if ( configName.length() > 0) { results.add(configName); } } return results; }  static Map<String,String> getNamesWithAliases(String nameList); static List<String> getNames(String nameList); static final String namePermittedChars; static final String namePattern; static final String nameListPattern; }
@Test public void testICanMatchAProcessNameListWithTabsAndExtraWhiteSpace() throws Exception { Pattern p = Pattern.compile(HandlerPatterns.nameListPattern); String listOfProcessNames = "processOne, processTwo, processThree"; assertTrue(p.matcher(listOfProcessNames).matches()); List<String> allProcessNames = HandlerPatterns.getNames(listOfProcessNames); assertEquals(Arrays.asList("processOne", "processTwo", "processThree"), allProcessNames); }