use of com.google.gerrit.extensions.restapi.ResourceConflictException in project gerrit by GerritCodeReview.
the class PushAccountIT method pushAccountConfigToUserBranchForReviewIsRejectedOnSubmitIfConfigIsInvalid.
@Test
public void pushAccountConfigToUserBranchForReviewIsRejectedOnSubmitIfConfigIsInvalid() throws Exception {
AccountIndexedCounter accountIndexedCounter = new AccountIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(accountIndexedCounter)) {
String userRef = RefNames.refsUsers(admin.id());
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, userRef + ":userRef");
allUsersRepo.reset("userRef");
PushOneCommit.Result r = pushFactory.create(admin.newIdent(), allUsersRepo, "Update account config", AccountProperties.ACCOUNT_CONFIG, "invalid config").to(MagicBranch.NEW_CHANGE + userRef);
r.assertOkStatus();
accountIndexedCounter.assertNoReindex();
assertThat(r.getChange().change().getDest().branch()).isEqualTo(userRef);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(r.getChangeId()).current().submit());
assertThat(thrown).hasMessageThat().contains(String.format("invalid account configuration: commit '%s' has an invalid '%s' file for account" + " '%s': Invalid config file %s in project %s in branch %s in commit %s", r.getCommit().name(), AccountProperties.ACCOUNT_CONFIG, admin.id(), AccountProperties.ACCOUNT_CONFIG, allUsers.get(), userRef, r.getCommit().name()));
}
}
use of com.google.gerrit.extensions.restapi.ResourceConflictException in project gerrit by GerritCodeReview.
the class DeleteBranchesIT method deleteMultiBranchesWithoutPermissionForbidden.
@Test
public void deleteMultiBranchesWithoutPermissionForbidden() throws Exception {
DeleteBranchesInput input = new DeleteBranchesInput();
input.branches = BRANCHES;
requestScopeOperations.setApiUser(user.id());
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> project().deleteBranches(input));
assertThat(thrown).hasMessageThat().isEqualTo(errorMessageForBranches(BRANCHES));
requestScopeOperations.setApiUser(admin.id());
assertBranches(BRANCHES);
}
use of com.google.gerrit.extensions.restapi.ResourceConflictException in project gerrit by GerritCodeReview.
the class DeleteBranchesIT method deleteBranchesNotFound.
@Test
public void deleteBranchesNotFound() throws Exception {
DeleteBranchesInput input = new DeleteBranchesInput();
List<String> branches = Lists.newArrayList(BRANCHES);
branches.add("refs/heads/does-not-exist");
input.branches = branches;
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> project().deleteBranches(input));
assertThat(thrown).hasMessageThat().isEqualTo(errorMessageForBranches(ImmutableList.of("refs/heads/does-not-exist")));
assertBranchesDeleted(BRANCHES);
}
use of com.google.gerrit.extensions.restapi.ResourceConflictException in project gerrit by GerritCodeReview.
the class DeleteTagsIT method deleteTagsNotFoundContinue.
@Test
public void deleteTagsNotFoundContinue() throws Exception {
// If it fails on the first tag in the input, it should still
// continue to process the remaining tags.
DeleteTagsInput input = new DeleteTagsInput();
List<String> tags = Lists.newArrayList("refs/tags/does-not-exist");
tags.addAll(TAGS);
input.tags = tags;
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> project().deleteTags(input));
assertThat(thrown).hasMessageThat().isEqualTo(errorMessageForTags(ImmutableList.of("refs/tags/does-not-exist")));
assertTagsDeleted();
}
use of com.google.gerrit.extensions.restapi.ResourceConflictException in project gerrit by GerritCodeReview.
the class CreateLabelIT method cannotCreateLabelWithNameThatIsAlreadyInUse.
@Test
public void cannotCreateLabelWithNameThatIsAlreadyInUse() throws Exception {
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.projects().name(allProjects.get()).label(LabelId.CODE_REVIEW).create(new LabelDefinitionInput()));
assertThat(thrown).hasMessageThat().contains("label Code-Review already exists");
}
Aggregations