HerdSearchQueryHelper { public boolean determineNegationTermsPresent(final IndexSearchRequest indexSearchRequest) { final Matcher regexMatcher = getNegationTermMatcher(indexSearchRequest); return regexMatcher.find(); }  boolean determineNegationTermsPresent(final IndexSearchRequest indexSearchRequest); List<String> extractNegationTerms(final IndexSearchRequest indexSearchRequest); String extractSearchPhrase(final IndexSearchRequest indexSearchRequest);  }
@Test public void determineNegationTermsPresent() throws Exception { IndexSearchRequest indexSearchRequest = new IndexSearchRequest(); indexSearchRequest.setSearchTerm(" -foo"); Assert.assertTrue(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); indexSearchRequest.setSearchTerm("foo -bar foobar"); Assert.assertTrue(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); indexSearchRequest.setSearchTerm(" "); Assert.assertFalse(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); indexSearchRequest.setSearchTerm("-bar"); Assert.assertFalse(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); indexSearchRequest.setSearchTerm("foo bar"); Assert.assertFalse(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); indexSearchRequest.setSearchTerm("foo-bar"); Assert.assertFalse(herdSearchQueryHelper.determineNegationTermsPresent(indexSearchRequest)); }