use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class MemoryVirtualFileTest method failsCreateFileWhenNameOfNewFileConflictsWithExistedFile.
@Test
public void failsCreateFileWhenNameOfNewFileConflictsWithExistedFile() throws Exception {
VirtualFile file = getRoot().createFile("file", DEFAULT_CONTENT);
file.setProperty("property1", "value1");
try {
getRoot().createFile("file", "xxx");
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
assertEquals(ImmutableMap.of("property1", "value1"), file.getProperties());
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class MemoryVirtualFileTest 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.core.ConflictException in project che by eclipse.
the class MemoryVirtualFileTest method failsRenameFolderWhenParentContainsItemWithSameName.
@Test
public void failsRenameFolderWhenParentContainsItemWithSameName() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile conflictFolder = getRoot().createFolder("new_name");
try {
folder.rename("new_name");
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertNull(getRoot().getChild(conflictFolder.getPath().newPath(file.getName())));
assertNotNull(getRoot().getChild(folder.getPath()));
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class MemoryVirtualFileTest method failsMoveFolderUnderNewNameWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled.
@Test
public void failsMoveFolderUnderNewNameWhenTargetFolderContainsItemWithTheSameNameAndOverwritingIsDisabled() 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.moveTo(targetFolder, "new_name", false, null);
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertNull(getRoot().getChild(conflictFolder.getPath().newPath(file.getName())));
assertNotNull(getRoot().getChild(folder.getPath()));
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class MemoryVirtualFileTest 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) {
assertEquals("xxx", conflictFile.getContentAsString());
assertEquals(DEFAULT_CONTENT, file.getContentAsString());
}
}
Aggregations