QuerySuggestionSource implements SuggestionSource<SearchSuggestion> { public String getLastValue(String s) { if (s.matches("[^\"']\\S*")) { return s.replaceFirst("([^\"']\\S*).*", "$1"); } final String[] splitWithSingleQuotes = s.split(",(?=([^\']*\"[^\']*\')*[^\']*$)", -1); if (splitWithSingleQuotes.length > 1) { return splitWithSingleQuotes[1]; } final String[] splitWithDoubleQuotes = s.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); if (splitWithDoubleQuotes.length > 1) { return splitWithDoubleQuotes[1]; } return s; } QuerySuggestionSource(List<SuggestionQuery> history); @Override List<SearchSuggestion> getSuggestions(SuggestionQuery q); String getLastValue(String s); static void main(String[] args);  }
@Test(dataProvider = "lastValue", enabled = false) public void testLastValue(String s, String expected) { Assert.assertEquals(underTest.getLastValue(s), expected); }