use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class RecipeDaoTest method shouldNotCreateRecipeWhenSubscriberThrowsExceptionOnRecipeStoring.
@Test(dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingRecipe", expectedExceptions = NotFoundException.class)
public void shouldNotCreateRecipeWhenSubscriberThrowsExceptionOnRecipeStoring() throws Exception {
final RecipeImpl recipe = createRecipe(0);
CascadeEventSubscriber<RecipePersistedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ConflictException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, RecipePersistedEvent.class);
try {
recipeDao.create(recipe);
fail("RecipeDao#create had to throw conflict exception");
} catch (ConflictException ignored) {
}
eventService.unsubscribe(subscriber, RecipePersistedEvent.class);
recipeDao.getById(recipe.getId());
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class LocalVirtualFileTest 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) {
assertionHelper.assertThatIoFileDoesNotExist(conflictFolder.getPath().newPath(file.getName()));
assertionHelper.assertThatIoFileExists(folder.getPath());
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class LocalVirtualFileTest method failsCopyFolderWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled.
@Test
public void failsCopyFolderWhenTargetFolderContainsItemWithSameNameAndOverwritingIsDisabled() throws Exception {
VirtualFile folder = getRoot().createFolder(generateFolderName());
VirtualFile file = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile targetFolder = getRoot().createFolder(generateFolderName());
VirtualFile conflictFolder = targetFolder.createFolder(folder.getName());
try {
folder.copyTo(targetFolder);
thrown.expect(ConflictException.class);
} catch (ConflictException expected) {
assertionHelper.assertThatIoFileDoesNotExist(conflictFolder.getPath().newPath(file.getName()));
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class LocalVirtualFileTest 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) {
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
assertionHelper.assertThatMetadataIoFileHasContent(file.getPath(), serializeVirtualFileMetadata(ImmutableMap.of("property1", "value1")));
}
}
use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class LocalVirtualFileTest 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) {
assertionHelper.assertThatIoFileDoesNotExist(conflictFolder.getPath().newPath(file.getName()));
assertionHelper.assertThatIoFileExists(folder.getPath());
assertionHelper.assertThatIoFileHasContent(file.getPath(), DEFAULT_CONTENT_BYTES);
}
}
Aggregations