use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method copiesFolderAndReplaceExistedItem.
@Test
public void copiesFolderAndReplaceExistedItem() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
targetFolder.createFolder(folder.getName());
VirtualFile copiedFolder = folder.copyTo(targetFolder, null, true);
assertNotNull(getRoot().getChild(copiedFolder.getPath()));
VirtualFile copiedFile = copiedFolder.getChild(Path.of(file.getName()));
assertEquals(file.getContentAsString(), copiedFile.getContentAsString());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method failsDeleteLockedFileWithoutLockToken.
@Test
public void failsDeleteLockedFileWithoutLockToken() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
file.lock(0);
try {
file.delete();
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertEquals(file, getRoot().getChild(filePath));
assertTrue(file.isLocked());
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method getFileTreeAsList.
private List<VirtualFile> getFileTreeAsList(VirtualFile rootOfTree) throws Exception {
List<VirtualFile> list = newArrayList();
rootOfTree.accept(new VirtualFileVisitor() {
@Override
public void visit(VirtualFile virtualFile) throws ServerException {
list.add(virtualFile);
if (virtualFile.isFolder()) {
for (VirtualFile child : virtualFile.getChildren()) {
child.accept(this);
}
}
}
});
return list;
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method renamesFolder.
@Test
public void renamesFolder() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Path folderPath = folder.getPath();
folder.setProperty("property1", "value1");
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
String fileName = file.getName();
file.setProperty("property2", "value2");
VirtualFile renamed = folder.rename("new_name");
assertNotNull(getRoot().getChild(renamed.getPath()));
assertEquals(ImmutableMap.of("property1", "value1"), renamed.getProperties());
Path newFilePath = renamed.getPath().newPath(fileName);
assertEquals(DEFAULT_CONTENT, getRoot().getChild(newFilePath).getContentAsString());
assertEquals(ImmutableMap.of("property2", "value2"), getRoot().getChild(newFilePath).getProperties());
assertNull(getRoot().getChild(folderPath.newPath(fileName)));
assertNull(getRoot().getChild(folderPath));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method removesDeletedFolderFromSearcher.
@Test
public void removesDeletedFolderFromSearcher() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
String path = folder.getPath().toString();
folder.delete();
verify(searcher).delete(path, false);
}
Aggregations