### Question:
SolrSettings extends AbstractSettings { public static List<String> getSearchTermFragments(String value) { if (value == null) { return null; } Matcher matcher = splitTermFragmentsRegex.matcher(value); List<String> fragments = new ArrayList<>(); while (matcher.find()) { if (matcher.groupCount() == 4) { boolean quoted = matcher.group(2) != null; String fragment = quoted ? matcher.group(2) : matcher.group(4); fragment = sanitize(fragment.replace("\\\"", "\"")); if (quoted || fragment.indexOf('\\') > -1) { fragment = '"' + fragment + '"'; } fragments.add(fragment); } } return fragments; } SolrSettings(); void setProperties(Properties properties); SolrClient getSolrClient(); static String sanitize(String value); static String escapeQueryChars(String s); static List<String> getSearchTermFragments(String value); String getPath(); void setPath(String path); String getCore(); void setCore(String core); String[] getRequiredFields(); void setRequiredFields(String requiredFields); int getSocketTimeout(); void setSocketTimeout(int socketTimeout); int getConnectionTimeout(); void setConnectionTimeout(int connectionTimeout); int getDefaultMaxConnectionsPerHost(); void setDefaultMaxConnectionsPerHost(int defaultMaxConnectionsPerHost); int getMaxConnections(); void setMaxConnections(int maxConnections); String getUrl(); void setUrl(String url); String toStringStatic(); String getFieldKey(String name); HashMap<String, String> getFieldNameToKey(); String getFieldName(String key); HashMap<String, String> getFieldNames(); void setFieldNames(HashMap<String, String> fieldNames); int getMaxRetries(); void setMaxRetries(int maxRetries);  }### Answer:
@Test public void tokenizeSearchTerms() { List<String> tokens = SolrSettings.getSearchTermFragments("hello world"); assertEquals("hello", tokens.get(0)); assertEquals("world", tokens.get(1)); assertEquals(2, tokens.size()); tokens = SolrSettings.getSearchTermFragments("hello:world"); assertEquals("\"hello\\:world\"", tokens.get(0)); assertEquals(1, tokens.size()); tokens = SolrSettings.getSearchTermFragments("\"hello world\""); assertEquals("\"hello\\ world\"", tokens.get(0)); assertEquals(1, tokens.size()); tokens = SolrSettings.getSearchTermFragments("\"hello world\" welcome"); assertEquals("\"hello\\ world\"", tokens.get(0)); assertEquals("welcome", tokens.get(1)); assertEquals(2, tokens.size()); tokens = SolrSettings.getSearchTermFragments("\"hello world\" wel*"); assertEquals("\"hello\\ world\"", tokens.get(0)); assertEquals("wel*", tokens.get(1)); assertEquals(2, tokens.size()); }
@Test public void tokenizeSearchTermsContainingQuote() { List<String> tokens = SolrSettings.getSearchTermFragments("\"Level 1, 0-6\\\" BS\""); assertEquals("\"Level\\ 1,\\ 0\\-6\\\"\\ BS\"", tokens.get(0)); assertEquals(1, tokens.size()); }