### Question:
XWikiDismaxQParserPlugin extends ExtendedDismaxQParserPlugin { public Set<String> extractFieldNames(String query) { Set<String> fieldNames = new HashSet<String>(); Matcher matcher = FIELD_PATTERN.matcher(query); while (matcher.find()) { fieldNames.add(matcher.group(1)); } return fieldNames; }  @Override QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req); SolrParams withFieldAliases(String query, SolrParams parameters); Set<String> extractFieldNames(String query);  }### Answer:
@Test public void extractFieldNames() { assertEquals(Collections.emptySet(), plugin.extractFieldNames("")); assertEquals(Collections.emptySet(), plugin.extractFieldNames("text")); assertEquals(Collections.emptySet(), plugin.extractFieldNames("+(^:text")); assertEquals(Collections.emptySet(), plugin.extractFieldNames("foo :bar")); assertEquals(Collections.singleton("foo"), plugin.extractFieldNames("foo:bar")); assertEquals(Collections.singleton("both"), plugin.extractFieldNames("both:(one two)")); assertEquals(Collections.singleton("title__"), plugin.extractFieldNames("title__:text")); assertEquals(Collections.singleton("title_zh_TW"), plugin.extractFieldNames("title_zh_TW:text")); assertEquals(Collections.singleton("property.Blog.BlogPostClass.title"), plugin.extractFieldNames("property.Blog.BlogPostClass.title:value")); assertEquals(Collections.singleton("property.Blog.Blog..Post$5EClass.title"), plugin.extractFieldNames("property.Blog.Blog..Post$5EClass.title:value")); assertEquals( new HashSet<String>(Arrays.asList("abc", "g_h.i", "m$n-o", "_\u0103\u00EE\u00E2\u0219\u021B\u00E8\u00E9\u00EA\u00EB")), plugin.extractFieldNames("+abc:def AND -g_h.i:jkl AND (m$n-o:pqr OR " + "_\u0103\u00EE\u00E2\u0219\u021B\u00E8\u00E9\u00EA\u00EB:stu^3)")); }