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");
}
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);
}
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();
}
Aggregations