use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method addsFolderThatCopiedFromOtherFolderInSearcher.
@Test
public void addsFolderThatCopiedFromOtherFolderInSearcher() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile newParent = getRoot().createFolder(generateFolderName());
VirtualFile copy = folder.copyTo(newParent);
verify(searcher).add(copy);
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method failsCopyFileWhenItemWithTheSameNameExistsInTargetFolderAndOverwritingIsDisabled.
@Test
public void failsCopyFileWhenItemWithTheSameNameExistsInTargetFolderAndOverwritingIsDisabled() throws Exception {
VirtualFile root = getRoot();
VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = root.createFolder(generateFolderName());
VirtualFile conflictFile = targetFolder.createFile("existed_name", "xxx");
try {
file.copyTo(targetFolder, "existed_name", false);
thrown.expect(ConflictException.class);
} catch (ConflictException e) {
assertionHelper.assertThatIoFileHasContent(conflictFile.getPath(), "xxx".getBytes());
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
}
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method createsFileWithStreamContent.
@Test
public void createsFileWithStreamContent() throws Exception {
VirtualFile folder = getRoot().createFolder("a/b/c");
VirtualFile file = folder.createFile("new_file", new ByteArrayInputStream(DEFAULT_CONTENT_BYTES));
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
assertEquals(file, folder.getChild(Path.of("new_file")));
assertEquals("/a/b/c/new_file", file.getPath().toString());
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method compressFolderToTarArchive.
@Test
public void compressFolderToTarArchive() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
Archiver archiver = mock(Archiver.class);
when(archiverFactory.createArchiver(eq(folder), eq("tar"))).thenReturn(archiver);
folder.tar();
verify(archiver).compress(any(OutputStream.class), any(VirtualFileFilter.class));
}
use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.
the class LocalVirtualFileTest method renamesFile.
@Test
public void renamesFile() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
file.setProperty("property1", "value1");
Path filePath = file.getPath();
VirtualFile renamedFile = file.rename("new name");
assertionHelper.assertThatIoFileHasContent(renamedFile.getPath(), DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatMetadataIoFileHasContent(renamedFile.getPath(), serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
assertionHelper.assertThatIoFileDoesNotExist(filePath);
assertionHelper.assertThatMetadataIoFileDoesNotExist(filePath);
}
Aggregations