use of org.apache.geode.cache.lucene.internal.StringQueryProvider in project geode by apache.
the class LuceneQueryFunctionJUnitTest method createMocksAndCommonObjects.
@Before
public void createMocksAndCommonObjects() throws Exception {
mockContext = mock(InternalRegionFunctionContext.class);
mockResultSender = mock(ResultSender.class);
mockRegion = mock(Region.class);
mockRepoManager = mock(RepositoryManager.class);
mockRepository1 = mock(IndexRepository.class, "repo1");
mockRepository2 = mock(IndexRepository.class, "repo2");
mockCollector = mock(IndexResultCollector.class);
mockStats = mock(LuceneIndexStats.class);
repos = new ArrayList<IndexRepository>();
repos.add(mockRepository1);
repos.add(mockRepository2);
mockIndex = mock(LuceneIndexImpl.class);
mockService = mock(InternalLuceneService.class);
mockCache = mock(InternalCache.class);
Analyzer analyzer = new StandardAnalyzer();
Mockito.doReturn(analyzer).when(mockIndex).getAnalyzer();
queryProvider = new StringQueryProvider("gemfire:lucene", DEFAULT_FIELD);
searchArgs = new LuceneFunctionContext<IndexResultCollector>(queryProvider, "indexName");
when(mockRegion.getCache()).thenReturn(mockCache);
when(mockRegion.getFullPath()).thenReturn(regionPath);
when(mockCache.getService(any())).thenReturn(mockService);
when(mockService.getIndex(eq("indexName"), eq(regionPath))).thenReturn(mockIndex);
when(mockIndex.getRepositoryManager()).thenReturn(mockRepoManager);
when(mockIndex.getFieldNames()).thenReturn(new String[] { "gemfire" });
when(mockIndex.getIndexStats()).thenReturn(mockStats);
query = queryProvider.getQuery(mockIndex);
}
use of org.apache.geode.cache.lucene.internal.StringQueryProvider in project geode by apache.
the class LuceneQueryFunctionContextJUnitTest method testSerialization.
@Test
public void testSerialization() {
LuceneServiceImpl.registerDataSerializables();
LuceneQueryProvider provider = new StringQueryProvider("text", DEFAULT_FIELD);
CollectorManager<TopEntriesCollector> manager = new TopEntriesCollectorManager("test");
LuceneFunctionContext<TopEntriesCollector> context = new LuceneFunctionContext<>(provider, "testIndex", manager, 123);
LuceneFunctionContext<TopEntriesCollector> copy = CopyHelper.deepCopy(context);
assertEquals(123, copy.getLimit());
assertNotNull(copy.getQueryProvider());
assertEquals("text", ((StringQueryProvider) copy.getQueryProvider()).getQueryString());
assertEquals(TopEntriesCollectorManager.class, copy.getCollectorManager().getClass());
assertEquals("test", ((TopEntriesCollectorManager) copy.getCollectorManager()).getId());
assertEquals("testIndex", copy.getIndexName());
}
Aggregations