use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method movesFileUnderNewName.
@Test
public void movesFileUnderNewName() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile movedFile = file.moveTo(targetFolder, "new_name", false, null);
assertionHelper.assertThatMetadataIoFileHasContent(movedFile.getPath(), serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
assertionHelper.assertThatIoFileHasContent(movedFile.getPath(), DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatIoFileDoesNotExist(filePath);
assertionHelper.assertThatMetadataIoFileDoesNotExist(filePath);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method copiesFile.
@Test
public void copiesFile() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
VirtualFile targetFolder = root.createFolder(generateFolderName());
VirtualFile copy = file.copyTo(targetFolder);
assertionHelper.assertThatIoFilesHaveSameContent(file.getPath(), copy.getPath());
assertionHelper.assertThatMetadataIoFilesHaveSameContent(file.getPath(), copy.getPath());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method copiesLockedFile.
@Test
public void copiesLockedFile() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
file.lock(0);
VirtualFile targetFolder = root.createFolder(generateFolderName());
VirtualFile copy = file.copyTo(targetFolder);
assertFalse(copy.isLocked());
assertionHelper.assertThatIoFilesHaveSameContent(file.getPath(), copy.getPath());
assertionHelper.assertThatLockIoFileDoesNotExist(copy.getPath());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method copiesFolderUnderNewName.
@Test
public void copiesFolderUnderNewName() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile copiedFolder = folder.copyTo(targetFolder, "new_name", false);
VirtualFile copiedFile = copiedFolder.getChild(Path.of(file.getName()));
assertionHelper.assertThatIoFileExists(copiedFolder.getPath());
assertionHelper.assertThatIoFilesHaveSameContent(file.getPath(), copiedFile.getPath());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsMoveLockedFileWhenLockTokenIsInvalid.
@Test
public void failsMoveLockedFileWhenLockTokenIsInvalid() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
String invalidLockToken = invalidateLockToken(file.lock(0));
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
Path movedFilePath = targetFolder.getPath().newPath(file.getName());
try {
file.moveTo(targetFolder, null, false, invalidLockToken);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertionHelper.assertThatIoFileDoesNotExist(movedFilePath);
assertionHelper.assertThatLockIoFileDoesNotExist(movedFilePath);
assertionHelper.assertThatMetadataIoFileDoesNotExist(movedFilePath);
assertionHelper.assertThatIoFileHasContent(filePath, DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatMetadataIoFileHasContent(filePath, serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
assertionHelper.assertThatLockIoFileExists(filePath);
}
}
Aggregations