use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method locksFile.
@Test
public void locksFile() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
file.lock(0);
assertTrue(file.isLocked());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method checksIsRoot.
@Test
public void checksIsRoot() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile folder = root.createFolder(generateFolderName());
assertFalse(file.isRoot());
assertFalse(folder.isRoot());
assertTrue(root.isRoot());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method deletesLockedFileWithLockToken.
@Test
public void deletesLockedFileWithLockToken() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
String lockToken = file.lock(0);
file.delete(lockToken);
assertionHelper.assertThatIoFileDoesNotExist(filePath);
assertionHelper.assertThatMetadataIoFileDoesNotExist(filePath);
assertionHelper.assertThatLockIoFileDoesNotExist(filePath);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method unzipsInFolder.
@Test
public void unzipsInFolder() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Archiver archiver = mock(Archiver.class);
when(archiverFactory.createArchiver(eq(folder), eq("zip"))).thenReturn(archiver);
folder.unzip(new ByteArrayInputStream(new byte[0]), false, 0);
verify(archiver).extract(any(InputStream.class), eq(false), eq(0));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method getsChildrenWithFilter.
@Test
public void getsChildrenWithFilter() throws Exception {
VirtualFile root = getRoot();
root.createFolder(generateFolderName());
VirtualFile file1 = root.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile file2 = root.createFile(generateFileName(), DEFAULT_CONTENT);
List<VirtualFile> expectedResult = newArrayList(file1, file2);
Collections.sort(expectedResult);
List<VirtualFile> children = root.getChildren(file -> file.equals(file1) || file.equals(file2));
assertEquals(expectedResult, children);
}
Aggregations