Search in sources :

Example 16 with VirtualFileSystem

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);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) MemoryVirtualFileSystem(org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem) QueryExpression(org.eclipse.che.api.vfs.search.QueryExpression) Test(org.testng.annotations.Test)

Example 17 with VirtualFileSystem

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();
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) MemoryVirtualFileSystem(org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem) Test(org.testng.annotations.Test)

Example 18 with VirtualFileSystem

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);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) MemoryVirtualFileSystem(org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem) QueryExpression(org.eclipse.che.api.vfs.search.QueryExpression) Test(org.testng.annotations.Test)

Example 19 with VirtualFileSystem

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));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Test(org.junit.Test)

Example 20 with VirtualFileSystem

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));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) Test(org.junit.Test)

Aggregations

VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)63 MemoryVirtualFileSystem (org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem)32 Test (org.junit.Test)29 QueryExpression (org.eclipse.che.api.vfs.search.QueryExpression)28 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)27 Test (org.testng.annotations.Test)18 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)9 Searcher (org.eclipse.che.api.vfs.search.Searcher)7 SearchResult (org.eclipse.che.api.vfs.search.SearchResult)6 ServerException (org.eclipse.che.api.core.ServerException)5 Path (java.nio.file.Path)3 SearcherProvider (org.eclipse.che.api.vfs.search.SearcherProvider)3 IOException (java.io.IOException)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 File (java.io.File)1 InputStream (java.io.InputStream)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ProjectImporter (org.eclipse.che.api.project.server.importer.ProjectImporter)1