Search in sources :

Example 16 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method getsEmptyPropertiesMapIfFileDoesNotHaveProperties.

@Test
public void getsEmptyPropertiesMapIfFileDoesNotHaveProperties() throws Exception {
    VirtualFile root = getRoot();
    VirtualFile file = root.createFile(generateFileName(), DEFAULT_CONTENT);
    assertionHelper.assertThatMetadataIoFileDoesNotExist(file.getPath());
    assertTrue(file.getProperties().isEmpty());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 17 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method doesNotAddNewlyCreatedFolderInSearcher.

@Test
public void doesNotAddNewlyCreatedFolderInSearcher() throws Exception {
    VirtualFile folder = getRoot().createFolder(generateFolderName());
    verify(searcher, never()).add(folder);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 18 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method updatesFileInSearcherWhenContentUpdatedByStream.

@Test
public void updatesFileInSearcherWhenContentUpdatedByStream() throws Exception {
    VirtualFile file = getRoot().createFile(generateFileName(), "");
    file.updateContent(new ByteArrayInputStream(DEFAULT_CONTENT_BYTES));
    verify(searcher).update(file);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 19 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method copiesFileUnderNewName.

@Test
public void copiesFileUnderNewName() 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, "new name", false);
    assertionHelper.assertThatIoFilesHaveSameContent(file.getPath(), copy.getPath());
    assertionHelper.assertThatMetadataIoFilesHaveSameContent(file.getPath(), copy.getPath());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Test(org.junit.Test)

Example 20 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class LocalVirtualFileTest method movesFolderUnderNewNameAndReplaceExistedItem.

@Test
public void movesFolderUnderNewNameAndReplaceExistedItem() throws Exception {
    VirtualFile folder = getRoot().createFolder(generateFolderName());
    VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
    Path folderPath = folder.getPath();
    VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
    targetFolder.createFolder("new_name");
    VirtualFile movedFolder = folder.moveTo(targetFolder, "new_name", true, null);
    VirtualFile movedFile = movedFolder.getChild(Path.of(file.getName()));
    assertionHelper.assertThatIoFileExists(movedFolder.getPath());
    assertionHelper.assertThatIoFileHasContent(movedFile.getPath(), DEFAULT_CONTENT_BYTES);
    assertionHelper.assertThatIoFileDoesNotExist(folderPath);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) Path(org.eclipse.che.api.vfs.Path) Test(org.junit.Test)

Aggregations

VirtualFile (org.eclipse.che.api.vfs.VirtualFile)321 Test (org.junit.Test)267 Path (org.eclipse.che.api.vfs.Path)62 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)54 ByteArrayInputStream (java.io.ByteArrayInputStream)32 ConflictException (org.eclipse.che.api.core.ConflictException)28 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)27 MemoryVirtualFileSystem (org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem)22 QueryExpression (org.eclipse.che.api.vfs.search.QueryExpression)22 ServerException (org.eclipse.che.api.core.ServerException)18 Test (org.testng.annotations.Test)18 File (java.io.File)17 Archiver (org.eclipse.che.api.vfs.Archiver)14 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 OutputStream (java.io.OutputStream)6 LockedFileFinder (org.eclipse.che.api.vfs.LockedFileFinder)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Map (java.util.Map)5