use of org.eclipse.che.api.vfs.VirtualFileSystem 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.VirtualFileSystem in project che by eclipse.
the class FSLuceneSearcherTest method notifiesCallbackWhenSearcherClosed.
@Test
public void notifiesCallbackWhenSearcherClosed() throws Exception {
VirtualFileSystem virtualFileSystem = virtualFileSystem();
searcher.init(virtualFileSystem);
searcher.close();
verify(closeCallback).onClose();
}
use of org.eclipse.che.api.vfs.VirtualFileSystem 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);
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherProviderTest method doesNotCreateSearcherWhenItIsNotCreatedYetAndCreationIsNotRequested.
@Test
public void doesNotCreateSearcherWhenItIsNotCreatedYetAndCreationIsNotRequested() throws Exception {
VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
assertNull(memoryLuceneSearcherProvider.getSearcher(virtualFileSystem, false));
}
use of org.eclipse.che.api.vfs.VirtualFileSystem in project che by eclipse.
the class MemoryLuceneSearcherProviderTest method returnsSameInstanceOfSearcherOnceItWasCreated.
@Test
public void returnsSameInstanceOfSearcherOnceItWasCreated() throws Exception {
VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
Searcher searcher = memoryLuceneSearcherProvider.getSearcher(virtualFileSystem, true);
assertNotNull(searcher);
assertSame(searcher, memoryLuceneSearcherProvider.getSearcher(virtualFileSystem, false));
}
Aggregations