use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherProviderTest method resetsSearcherInProviderAfterClosingSearcher.
@Test
public void resetsSearcherInProviderAfterClosingSearcher() throws Exception {
VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
Searcher searcher = fsLuceneSearcherProvider.getSearcher(virtualFileSystem, true);
assertNotNull(searcher);
searcher.close();
assertNull(fsLuceneSearcherProvider.getSearcher(virtualFileSystem, false));
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherProviderTest method returnsSameInstanceOfSearcherOnceItWasCreated.
@Test
public void returnsSameInstanceOfSearcherOnceItWasCreated() throws Exception {
VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
Searcher searcher = fsLuceneSearcherProvider.getSearcher(virtualFileSystem, true);
assertNotNull(searcher);
assertSame(searcher, fsLuceneSearcherProvider.getSearcher(virtualFileSystem, true));
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherTest method addsFileTreeInIndex.
@Test
public void addsFileTreeInIndex() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
searcher.init(virtualFileSystem);
VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
folder.createFile("xxx.txt", TEST_CONTENT[2]);
folder.createFile("zzz.txt", TEST_CONTENT[1]);
searcher.add(virtualFileSystem.getRoot());
List<String> paths = searcher.search(new QueryExpression().setText("be")).getFilePaths();
assertEquals(newArrayList("/folder/xxx.txt"), paths);
paths = searcher.search(new QueryExpression().setText("should")).getFilePaths();
assertEquals(newArrayList("/folder/zzz.txt"), paths);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherTest method excludesFilesFromIndexWithFilter.
@Test
public void excludesFilesFromIndexWithFilter() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
folder.createFile("xxx.txt", TEST_CONTENT[2]);
folder.createFile("yyy.txt", TEST_CONTENT[2]);
folder.createFile("zzz.txt", TEST_CONTENT[2]);
when(filter.accept(withName("yyy.txt"))).thenReturn(true);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("be")).getFilePaths();
assertEquals(newArrayList("/folder/xxx.txt", "/folder/zzz.txt"), paths);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherTest method searchesByWordFragment.
@Test
public void searchesByWordFragment() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
folder.createFile("xxx.txt", TEST_CONTENT[0]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("*stone*")).getFilePaths();
assertEquals(newArrayList("/folder/xxx.txt"), paths);
}
Aggregations