Search in sources :

Example 1 with VirtualFileSystemProvider

use of org.eclipse.che.api.vfs.VirtualFileSystemProvider in project che by eclipse.

the class CreateBaseProjectTypeHandlerTest method testCreateProject.

@Test
public void testCreateProject() throws Exception {
    Path path = Path.of("test");
    VirtualFileSystemProvider virtualFileSystemProvider = mock(VirtualFileSystemProvider.class);
    VirtualFileSystem virtualFileSystem = mock(VirtualFileSystem.class);
    VirtualFile base = mock(VirtualFile.class);
    when(base.isRoot()).thenReturn(false);
    VirtualFile root = mock(VirtualFile.class);
    when(root.isRoot()).thenReturn(true);
    when(root.createFolder(anyString())).thenReturn(base);
    when(virtualFileSystem.getRoot()).thenReturn(root);
    when(virtualFileSystemProvider.getVirtualFileSystem()).thenReturn(virtualFileSystem);
    when(virtualFileSystem.getRoot()).thenReturn(root);
    CreateBaseProjectTypeHandler createBaseProjectTypeHandler = new CreateBaseProjectTypeHandler(virtualFileSystemProvider);
    createBaseProjectTypeHandler.onCreateProject(path, null, null);
    verify(root).createFolder("test");
}
Also used : Path(org.eclipse.che.api.vfs.Path) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) VirtualFileSystemProvider(org.eclipse.che.api.vfs.VirtualFileSystemProvider) Test(org.testng.annotations.Test)

Example 2 with VirtualFileSystemProvider

use of org.eclipse.che.api.vfs.VirtualFileSystemProvider in project che by eclipse.

the class DefaultFileWatcherNotificationHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    File targetDir = new File(Thread.currentThread().getContextClassLoader().getResource(".").getPath()).getParentFile();
    testDirectory = new File(targetDir, NameGenerator.generate("watcher-notifications-", 4));
    virtualFileSystem = mock(LocalVirtualFileSystem.class, RETURNS_DEEP_STUBS);
    VirtualFileSystemProvider virtualFileSystemProvider = mock(VirtualFileSystemProvider.class);
    when(virtualFileSystemProvider.getVirtualFileSystem(true)).thenReturn(virtualFileSystem);
    notificationListener = mock(FileWatcherNotificationListener.class);
    notificationHandler = new DefaultFileWatcherNotificationHandler(virtualFileSystemProvider);
    notificationHandler.addNotificationListener(notificationListener);
    virtualFilePath = Path.of("/a/b/c");
    virtualFile = new LocalVirtualFile(testDirectory, virtualFilePath, virtualFileSystem);
    when(virtualFileSystem.getRoot().getChild(virtualFilePath)).thenReturn(virtualFile);
    when(notificationListener.shouldBeNotifiedFor(virtualFile)).thenReturn(true);
}
Also used : VirtualFileSystemProvider(org.eclipse.che.api.vfs.VirtualFileSystemProvider) File(java.io.File) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Before(org.junit.Before)

Example 3 with VirtualFileSystemProvider

use of org.eclipse.che.api.vfs.VirtualFileSystemProvider in project che by eclipse.

the class TestUtils method createVirtualFileSystem.

/**
     * Creates a virtual file system.
     *
     * @return the virtual file system
     * @throws Exception
     *         if anything goes wrong
     */
public static VirtualFileSystem createVirtualFileSystem() throws Exception {
    File rootDirectory = java.nio.file.Files.createTempDirectory(null).toFile();
    VirtualFileSystemProvider vfsProvider = new LocalVirtualFileSystemProvider(rootDirectory, null);
    return vfsProvider.getVirtualFileSystem();
}
Also used : VirtualFileSystemProvider(org.eclipse.che.api.vfs.VirtualFileSystemProvider) LocalVirtualFileSystemProvider(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider) LocalVirtualFileSystemProvider(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider) File(java.io.File)

Aggregations

VirtualFileSystemProvider (org.eclipse.che.api.vfs.VirtualFileSystemProvider)3 File (java.io.File)2 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)2 Path (org.eclipse.che.api.vfs.Path)1 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)1 LocalVirtualFileSystemProvider (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider)1 Before (org.junit.Before)1 Test (org.testng.annotations.Test)1