LuceneServer implements IContentServer, ILuceneServer { protected SearcherHandle getSearcherHandleByShard(String shardName) { SearcherHandle handle = _searcherHandlesByShard.get(shardName); if (handle == null) { throw new IllegalStateException("no index-server for shard '" + shardName + "' found - probably undeployed"); } return handle; } LuceneServer();  LuceneServer(String name, ISeacherFactory seacherFactory, float timeoutPercentage); @Override long getProtocolVersion(final String protocol, final long clientVersion); @Override void init(String nodeName, NodeConfiguration nodeConfiguration); String getNodeName(); float getTimeoutPercentage(); long getCollectorTiemout(long clientTimeout); @Override void addShard(final String shardName, final File shardDir); @Override void removeShard(final String shardName); @Override Collection<String> getShards(); @Override Map<String, String> getShardMetaData(String shardName); @Override void shutdown(); @Override HitsMapWritable search(QueryWritable query, DocumentFrequencyWritable freqs, String[] shardNames, long timeout); @Override HitsMapWritable search(final QueryWritable query, final DocumentFrequencyWritable freqs,
          final String[] shards, final long timeout, final int count); @Override HitsMapWritable search(QueryWritable query, DocumentFrequencyWritable freqs, String[] shards,
          final long timeout, int count, SortWritable sortWritable); @Override HitsMapWritable search(QueryWritable query, DocumentFrequencyWritable freqs, String[] shards,
          final long timeout, int count, FilterWritable filterWritable); @Override HitsMapWritable search(QueryWritable query, DocumentFrequencyWritable freqs, String[] shards,
          final long timeout, int count, SortWritable sortWritable, FilterWritable filterWritable); @Override DocumentFrequencyWritable getDocFreqs(final QueryWritable input, final String[] shards); @Override MapWritable getDetails(final String[] shards, final int docId); @Override MapWritable getDetails(final String[] shards, final int docId, final String[] fieldNames); @Override int getResultCount(final QueryWritable query, final String[] shards, long timeout); @Override int getResultCount(final QueryWritable query, FilterWritable filter, final String[] shards, long timeout); final static String CONF_KEY_SEARCHER_FACTORY_CLASS; final static String CONF_KEY_COLLECTOR_TIMOUT_PERCENTAGE; final static String CONF_KEY_COLLECTOR_TRACK_DOC_SCORES_ON_FIELD_SORT; final static String CONF_KEY_SEARCHER_THREADPOOL_CORESIZE; final static String CONF_KEY_SEARCHER_THREADPOOL_MAXSIZE; final static String CONF_KEY_FILTER_CACHE_ENABLED; }
@Test public void testSearchCall_EmptyIndex() throws Exception { IndexSearcher searcher = mock(IndexSearcher.class); when(searcher.maxDoc()).thenReturn(0); Weight weight = mock(Weight.class); LuceneServer server = mock(LuceneServer.class); when(server.getSearcherHandleByShard("testShard")).thenReturn(new SearcherHandle(searcher)); LuceneServer.SearchCall searchCall = server.new SearchCall("testShard", weight, 10, null, 1000, 1, null); LuceneServer.SearchResult result = searchCall.call(); assertThat(result._totalHits).as("results").isEqualTo(0); }