use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest 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) {
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 unlocksFile.
@Test
public void unlocksFile() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
String lockToken = file.lock(0);
file.unlock(lockToken);
assertionHelper.assertThatLockIoFileDoesNotExist(file.getPath());
assertFalse(file.isLocked());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsMoveFileWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled.
@Test
public void failsMoveFileWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
Path filePath = file.getPath();
VirtualFile existedFile = targetFolder.createFile("existed_name", "existed content");
try {
file.moveTo(targetFolder, "existed_name", false, null);
thrown.expect(ConflictException.class);
} catch (ConflictException e) {
assertEquals(file, getRoot().getChild(filePath));
assertEquals("existed content", existedFile.getContentAsString());
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method updatesFolderInSearcherWhenItIsMoved.
@Test
public void updatesFolderInSearcherWhenItIsMoved() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFileName());
VirtualFile newParent = getRoot().createFolder(generateFolderName());
String oldPath = folder.getPath().toString();
Mockito.reset(searcher);
VirtualFile moved = folder.moveTo(newParent);
verify(searcher).add(moved);
verify(searcher).delete(oldPath, false);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsGetContentOfFolderAsString.
@Test
public void failsGetContentOfFolderAsString() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder(generateFolderName());
thrown.expect(ForbiddenException.class);
folder.getContentAsString();
}
Aggregations