use of org.eclipse.che.api.vfs.search.SearchResult in project che by eclipse.
the class FSLuceneSearcherTest method generatesQueryExpressionForRetrievingNextPageOfResults.
@Test
public void generatesQueryExpressionForRetrievingNextPageOfResults() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
for (int i = 0; i < 100; i++) {
virtualFileSystem.getRoot().createFile(String.format("file%02d", i), TEST_CONTENT[i % TEST_CONTENT.length]);
}
searcher.init(virtualFileSystem);
SearchResult result = searcher.search(new QueryExpression().setText("spaceflight").setMaxItems(7));
assertEquals(25, result.getTotalHits());
Optional<QueryExpression> optionalNextPageQueryExpression = result.getNextPageQueryExpression();
assertTrue(optionalNextPageQueryExpression.isPresent());
QueryExpression nextPageQueryExpression = optionalNextPageQueryExpression.get();
assertEquals("spaceflight", nextPageQueryExpression.getText());
assertEquals(7, nextPageQueryExpression.getSkipCount());
assertEquals(7, nextPageQueryExpression.getMaxItems());
}
use of org.eclipse.che.api.vfs.search.SearchResult in project che by eclipse.
the class FSLuceneSearcherTest method limitsNumberOfSearchResultsWhenMaxItemIsSet.
@Test
public void limitsNumberOfSearchResultsWhenMaxItemIsSet() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
for (int i = 0; i < 100; i++) {
virtualFileSystem.getRoot().createFile(String.format("file%02d", i), TEST_CONTENT[i % TEST_CONTENT.length]);
}
searcher.init(virtualFileSystem);
SearchResult result = searcher.search(new QueryExpression().setText("mission").setMaxItems(5));
assertEquals(25, result.getTotalHits());
assertEquals(5, result.getFilePaths().size());
}
Aggregations