use of org.eclipse.che.api.vfs.search.QueryExpression 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.search.QueryExpression 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.search.QueryExpression 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);
}
use of org.eclipse.che.api.vfs.search.QueryExpression in project che by eclipse.
the class FSLuceneSearcherTest 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.search.QueryExpression in project che by eclipse.
the class FSLuceneSearcherTest method searchFileByName.
@Test(dataProvider = "searchByName")
public void searchFileByName(String fileName, String searchedFileName) throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
VirtualFile folder = virtualFileSystem.getRoot().createFolder("parent/child");
VirtualFile folder2 = virtualFileSystem.getRoot().createFolder("folder2");
folder.createFile(NameGenerator.generate(null, 10), TEST_CONTENT[3]);
folder.createFile(fileName, TEST_CONTENT[2]);
folder.createFile(NameGenerator.generate(null, 10), TEST_CONTENT[1]);
folder2.createFile(NameGenerator.generate(null, 10), TEST_CONTENT[2]);
folder2.createFile(NameGenerator.generate(null, 10), TEST_CONTENT[2]);
searcher.init(virtualFileSystem);
List<String> paths = searcher.search(new QueryExpression().setName(searchedFileName)).getFilePaths();
assertEquals(newArrayList("/parent/child/" + fileName), paths);
}
Aggregations