HerdSearchQueryHelper { public String extractSearchPhrase(final IndexSearchRequest indexSearchRequest) { final Matcher regexMatcher = getNegationTermMatcher(indexSearchRequest); String searchPhrase = indexSearchRequest.getSearchTerm(); while (regexMatcher.find()) { searchPhrase = searchPhrase.replace(regexMatcher.group(), StringUtils.EMPTY); } return searchPhrase.trim(); }  boolean determineNegationTermsPresent(final IndexSearchRequest indexSearchRequest); List<String> extractNegationTerms(final IndexSearchRequest indexSearchRequest); String extractSearchPhrase(final IndexSearchRequest indexSearchRequest);  }
@Test public void extractSearchPhrase() throws Exception { IndexSearchRequest indexSearchRequest = new IndexSearchRequest(); indexSearchRequest.setSearchTerm("foo -foo bar -bar foobar"); Assert.assertEquals("foo bar foobar", herdSearchQueryHelper.extractSearchPhrase(indexSearchRequest)); }