use of org.apache.geode.cache.lucene.LuceneQueryFactory in project geode by apache.
the class LuceneSearchIndexFunctionJUnitTest method getMockLuceneService.
private InternalLuceneService getMockLuceneService(String resultKey, String resultValue, String resultScore) throws LuceneQueryException {
InternalLuceneService service = mock(InternalLuceneService.class);
LuceneQueryFactory mockQueryFactory = spy(LuceneQueryFactory.class);
LuceneQuery mockQuery = mock(LuceneQuery.class);
PageableLuceneQueryResults pageableLuceneQueryResults = mock(PageableLuceneQueryResults.class);
LuceneResultStruct<String, String> resultStruct = new LuceneResultStructImpl(resultKey, resultValue, Float.valueOf(resultScore));
List<LuceneResultStruct<String, String>> queryResults = new ArrayList<>();
queryResults.add(resultStruct);
doReturn(mock(LuceneIndex.class)).when(service).getIndex(anyString(), anyString());
doReturn(mockQueryFactory).when(service).createLuceneQueryFactory();
doReturn(mockQueryFactory).when(mockQueryFactory).setLimit(anyInt());
doReturn(mockQuery).when(mockQueryFactory).create(any(), any(), any(), any());
when(mockQuery.findPages()).thenReturn(pageableLuceneQueryResults);
when(pageableLuceneQueryResults.hasNext()).thenReturn(true).thenReturn(false);
when(pageableLuceneQueryResults.next()).thenReturn(queryResults);
return service;
}
Aggregations