use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherTest 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 MemoryLuceneSearcherTest method updatesSingleFileInIndex.
@Test
public void updatesSingleFileInIndex() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile file = virtualFileSystem.getRoot().createFolder("aaa").createFile("aaa.txt", TEST_CONTENT[2]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("should")).getFilePaths();
assertTrue(paths.isEmpty());
file.updateContent(TEST_CONTENT[1]);
searcher.update(file);
paths = searcher.search(new QueryExpression().setText("should")).getFilePaths();
assertEquals(newArrayList(file.getPath().toString()), paths);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherTest method searchesByTextAndFileName.
@Test
public void searchesByTextAndFileName() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
folder.createFile("xxx.txt", TEST_CONTENT[2]);
folder.createFile("zzz.txt", TEST_CONTENT[2]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("be").setName("xxx.txt")).getFilePaths();
assertEquals(newArrayList("/folder/xxx.txt"), paths);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherTest method searchesByTextAndPath.
@Test
public void searchesByTextAndPath() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder1 = virtualFileSystem.getRoot().createFolder("folder1/a/b");
VirtualFile folder2 = virtualFileSystem.getRoot().createFolder("folder2");
folder1.createFile("xxx.txt", TEST_CONTENT[2]);
folder2.createFile("zzz.txt", TEST_CONTENT[2]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setText("be").setPath("/folder1")).getFilePaths();
assertEquals(newArrayList("/folder1/a/b/xxx.txt"), paths);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherTest method notifiesCallbackWhenSearcherClosed.
@Test
public void notifiesCallbackWhenSearcherClosed() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
searcher.init(virtualFileSystem);
searcher.close();
verify(closeCallback).onClose();
}
Aggregations