use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method renamesLockedFileWithLockToken.
@Test
public void renamesLockedFileWithLockToken() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
Path filePath = file.getPath();
String lockToken = file.lock(0);
VirtualFile renamedFile = file.rename("new name", lockToken);
assertFalse(renamedFile.isLocked());
assertEquals(renamedFile, getRoot().getChild(renamedFile.getPath()));
assertEquals(DEFAULT_CONTENT, renamedFile.getContentAsString());
assertNull(getRoot().getChild(filePath));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method removesPropertyBySetValueToNull.
@Test
public void removesPropertyBySetValueToNull() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), "");
file.setProperty("property1", "value1");
Map<String, String> expected = ImmutableMap.of("property1", "value1");
assertEquals(expected, file.getProperties());
file.setProperty("property1", null);
assertTrue(file.getProperties().isEmpty());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method updatesFileInSearcherWhenContentUpdatedByString.
@Test
public void updatesFileInSearcherWhenContentUpdatedByString() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), "");
file.updateContent(DEFAULT_CONTENT);
verify(searcher).update(file);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method movesFileUnderNewNameAndOverwriteExistedFile.
@Test
public void movesFileUnderNewNameAndOverwriteExistedFile() throws Exception {
VirtualFile file = getRoot().createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
targetFolder.createFolder("new_name");
VirtualFile movedFile = file.moveTo(targetFolder, "new_name", true, null);
assertEquals(movedFile, getRoot().getChild(movedFile.getPath()));
assertEquals(ImmutableMap.of("property1", "value1"), movedFile.getProperties());
assertEquals(DEFAULT_CONTENT, movedFile.getContentAsString());
assertNull(getRoot().getChild(filePath));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class MemoryVirtualFileTest method updatesContentOfLockedFileByStreamWithLockToken.
@Test
public void updatesContentOfLockedFileByStreamWithLockToken() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
String lockToken = file.lock(0);
file.updateContent(new ByteArrayInputStream("updated content".getBytes()), lockToken);
assertEquals("updated content", file.getContentAsString());
}
Aggregations