Search in sources :

Example 1 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class ZipArchiverTest method setUp.

@Before
public void setUp() throws Exception {
    File targetDir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getPath()).getParentFile();
    testDirectory = new File(targetDir, NameGenerator.generate("fs-", 4));
    assertTrue(testDirectory.mkdir());
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    Searcher searcher = mock(Searcher.class);
    VirtualFileSystem virtualFileSystem = new LocalVirtualFileSystem(testDirectory, mock(ArchiverFactory.class), searcherProvider, mock(AbstractVirtualFileSystemProvider.CloseCallback.class));
    when(searcherProvider.getSearcher(eq(virtualFileSystem), eq(true))).thenReturn(searcher);
    when(searcherProvider.getSearcher(eq(virtualFileSystem))).thenReturn(searcher);
    vfsRoot = virtualFileSystem.getRoot();
}
Also used : LocalVirtualFileSystem(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem) LocalVirtualFileSystem(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) File(java.io.File) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) Before(org.junit.Before)

Example 2 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class TarArchiverTest method setUp.

@Before
public void setUp() throws Exception {
    File targetDir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getPath()).getParentFile();
    testDirectory = new File(targetDir, NameGenerator.generate("fs-", 4));
    assertTrue(testDirectory.mkdir());
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    Searcher searcher = mock(Searcher.class);
    VirtualFileSystem virtualFileSystem = new LocalVirtualFileSystem(testDirectory, mock(ArchiverFactory.class), searcherProvider, mock(AbstractVirtualFileSystemProvider.CloseCallback.class));
    when(searcherProvider.getSearcher(eq(virtualFileSystem), eq(true))).thenReturn(searcher);
    when(searcherProvider.getSearcher(eq(virtualFileSystem))).thenReturn(searcher);
    vfsRoot = virtualFileSystem.getRoot();
}
Also used : LocalVirtualFileSystem(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem) LocalVirtualFileSystem(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) File(java.io.File) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) Before(org.junit.Before)

Example 3 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class LocalVirtualFileTest method setUp.

@Before
public void setUp() throws Exception {
    File targetDir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getPath()).getParentFile();
    testDirectory = new File(targetDir, NameGenerator.generate("fs-", 4));
    assertTrue(testDirectory.mkdir());
    assertionHelper = new LocalVirtualFileAssertionHelper(testDirectory);
    archiverFactory = mock(ArchiverFactory.class);
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    fileSystem = new LocalVirtualFileSystem(testDirectory, archiverFactory, searcherProvider, mock(AbstractVirtualFileSystemProvider.CloseCallback.class));
    searcher = mock(Searcher.class);
    when(searcherProvider.getSearcher(eq(fileSystem), eq(true))).thenReturn(searcher);
    when(searcherProvider.getSearcher(eq(fileSystem))).thenReturn(searcher);
}
Also used : Searcher(org.eclipse.che.api.vfs.search.Searcher) ArchiverFactory(org.eclipse.che.api.vfs.ArchiverFactory) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) File(java.io.File) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) AbstractVirtualFileSystemProvider(org.eclipse.che.api.vfs.AbstractVirtualFileSystemProvider) Before(org.junit.Before)

Example 4 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class LocalVirtualFileSystemTest method setUp.

@Before
public void setUp() throws Exception {
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    searcher = mock(Searcher.class);
    closeCallback = mock(AbstractVirtualFileSystemProvider.CloseCallback.class);
    File targetDir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getPath()).getParentFile();
    testDirectory = new File(targetDir, NameGenerator.generate("fs-", 4));
    fileSystem = new LocalVirtualFileSystem(testDirectory, mock(ArchiverFactory.class), searcherProvider, closeCallback);
    when(searcherProvider.getSearcher(eq(fileSystem), anyBoolean())).thenReturn(searcher);
    when(searcherProvider.getSearcher(eq(fileSystem))).thenReturn(searcher);
}
Also used : Searcher(org.eclipse.che.api.vfs.search.Searcher) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) File(java.io.File) Before(org.junit.Before)

Example 5 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class IndexedFileUpdateConsumer method accept.

@Override
public void accept(Path path) {
    try {
        VirtualFileSystem virtualFileSystem = vfsProvider.getVirtualFileSystem();
        SearcherProvider searcherProvider = virtualFileSystem.getSearcherProvider();
        Searcher searcher = searcherProvider.getSearcher(virtualFileSystem);
        Path innerPath = root.toPath().relativize(path);
        org.eclipse.che.api.vfs.Path vfsPath = org.eclipse.che.api.vfs.Path.of(innerPath.toString());
        VirtualFile child = virtualFileSystem.getRoot().getChild(vfsPath);
        if (child != null) {
            searcher.update(child);
        }
    } catch (ServerException e) {
        LOG.error("Issue happened during updating modified file in index", e);
    }
}
Also used : Path(java.nio.file.Path) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ServerException(org.eclipse.che.api.core.ServerException) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider)

Aggregations

Searcher (org.eclipse.che.api.vfs.search.Searcher)9 SearcherProvider (org.eclipse.che.api.vfs.search.SearcherProvider)9 Before (org.junit.Before)6 File (java.io.File)4 Path (java.nio.file.Path)3 ServerException (org.eclipse.che.api.core.ServerException)3 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)3 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)3 ArchiverFactory (org.eclipse.che.api.vfs.ArchiverFactory)2 LocalVirtualFileSystem (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem)2 AbstractVirtualFileSystemProvider (org.eclipse.che.api.vfs.AbstractVirtualFileSystemProvider)1