use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method locksFile.
@Test
public void locksFile() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
file.lock(0);
assertionHelper.assertThatLockIoFileExists(file.getPath());
assertTrue(file.isLocked());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsCopyFolderUnderNewNameWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled.
@Test
public void failsCopyFolderUnderNewNameWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile conflictFolder = targetFolder.createFolder("new_name");
try {
folder.copyTo(targetFolder, "new_name", false);
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertionHelper.assertThatIoFileDoesNotExist(conflictFolder.getPath().newPath(file.getName()));
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsDeleteLockedFileWhenLockTokenIsInvalid.
@Test
public void failsDeleteLockedFileWhenLockTokenIsInvalid() 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();
String invalidLockToken = invalidateLockToken(file.lock(0));
try {
file.delete(invalidLockToken);
thrown.expect(ForbiddenException.class);
} catch (ForbiddenException e) {
assertionHelper.assertThatIoFileHasContent(filePath, DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatMetadataIoFileHasContent(file.getPath(), serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
assertionHelper.assertThatLockIoFileExists(filePath);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method createFileTree.
private void createFileTree(VirtualFile rootOfTree, int depth) throws Exception {
if (depth > 0) {
VirtualFile folder = rootOfTree.createFolder(generateFolderName());
for (int i = 0; i < 3; i++) {
folder.createFile(generateFileName(), DEFAULT_CONTENT);
}
createFileTree(folder, depth - 1);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method updatesFileInSearcherWhenItIsMoved.
@Test
public void updatesFileInSearcherWhenItIsMoved() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile newParent = getRoot().createFolder(generateFolderName());
String oldPath = file.getPath().toString();
Mockito.reset(searcher);
VirtualFile moved = file.moveTo(newParent);
verify(searcher).add(moved);
verify(searcher).delete(oldPath, true);
}
Aggregations