SolrSearchDao implements SearchDao { @Override public SearchResponse search(SearchRequest searchRequest) throws InvalidSearchException { return search(searchRequest, null); } SolrSearchDao(SolrClient client, AccessConfig accessConfig); @Override SearchResponse search(SearchRequest searchRequest); SearchResponse search(SearchRequest searchRequest, String fieldList); @Override GroupResponse group(GroupRequest groupRequest);  }
@Test public void searchShouldThrowInvalidSearchExceptionOnEmptyQuery() { InvalidSearchException e = assertThrows(InvalidSearchException.class, () -> solrSearchDao.search(new SearchRequest())); assertEquals("Search query is invalid: null", e.getMessage()); }
@Test public void searchShouldThrowInvalidSearchExceptionOnEmptyClient() { SearchRequest searchRequest = new SearchRequest(); searchRequest.setQuery("query"); InvalidSearchException e = assertThrows(InvalidSearchException.class, () -> new SolrSearchDao(null, accessConfig).search(searchRequest)); assertEquals("Uninitialized Dao! You must call init() prior to use.", e.getMessage()); }
@Test public void searchShouldThrowSearchResultSizeException() { when(accessConfig.getMaxSearchResults()).thenReturn(100); SearchRequest searchRequest = new SearchRequest(); searchRequest.setQuery("query"); searchRequest.setSize(200); InvalidSearchException e = assertThrows(InvalidSearchException.class, () -> solrSearchDao.search(searchRequest)); assertEquals("Search result size must be less than 100", e.getMessage()); }