use of com.google.gerrit.testing.GerritJUnit.ThrowingRunnable in project gerrit by GerritCodeReview.
the class GroupsIT method pushToGroupBranchForReviewAndSubmit.
private void pushToGroupBranchForReviewAndSubmit(Project.NameKey project, String groupRef, String expectedError) throws Throwable {
projectOperations.project(project).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref(RefNames.REFS_GROUPS + "*").group(REGISTERED_USERS).range(-2, 2)).add(allow(Permission.SUBMIT).ref(RefNames.REFS_GROUPS + "*").group(REGISTERED_USERS)).update();
TestRepository<InMemoryRepository> repo = cloneProject(project);
fetch(repo, groupRef + ":groupRef");
repo.reset("groupRef");
PushOneCommit.Result r = pushFactory.create(admin.newIdent(), repo, "Update group config", "group.config", "some content").to(MagicBranch.NEW_CHANGE + groupRef);
r.assertOkStatus();
assertThat(r.getChange().change().getDest().branch()).isEqualTo(groupRef);
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
ThrowingRunnable submit = () -> gApi.changes().id(r.getChangeId()).current().submit();
if (expectedError != null) {
Throwable thrown = assertThrows(ResourceConflictException.class, submit);
assertThat(thrown).hasMessageThat().contains("group update not allowed");
} else {
submit.run();
}
}
use of com.google.gerrit.testing.GerritJUnit.ThrowingRunnable in project gerrit by GerritCodeReview.
the class AbstractSubmit method submit.
protected void submit(String changeId, SubmitInput input, @Nullable Class<? extends RestApiException> expectedExceptionType, String expectedExceptionMsg) throws Throwable {
approve(changeId);
if (expectedExceptionType == null) {
assertSubmittable(changeId);
} else {
requireNonNull(expectedExceptionMsg);
}
ThrowingRunnable submit = () -> gApi.changes().id(changeId).current().submit(input);
if (expectedExceptionType != null) {
RestApiException thrown = assertThrows(expectedExceptionType, submit);
assertThat(thrown).hasMessageThat().isEqualTo(expectedExceptionMsg);
return;
}
submit.run();
ChangeInfo change = gApi.changes().id(changeId).info();
assertMerged(change.changeId);
}
Aggregations