use of com.google.gerrit.extensions.api.changes.DeleteReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method testRemoveReviewer.
private void testRemoveReviewer(boolean notify) throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
gApi.changes().id(changeId).revision(r.getCommit().name()).review(ReviewInput.approve());
requestScopeOperations.setApiUser(user.id());
gApi.changes().id(changeId).revision(r.getCommit().name()).review(ReviewInput.recommend());
Collection<AccountInfo> reviewers = gApi.changes().id(changeId).get().reviewers.get(REVIEWER);
assertThat(reviewers).hasSize(2);
Iterator<AccountInfo> reviewerIt = reviewers.iterator();
assertThat(reviewerIt.next()._accountId).isEqualTo(admin.id().get());
assertThat(reviewerIt.next()._accountId).isEqualTo(user.id().get());
sender.clear();
requestScopeOperations.setApiUser(admin.id());
DeleteReviewerInput input = new DeleteReviewerInput();
if (!notify) {
input.notify = NotifyHandling.NONE;
}
gApi.changes().id(changeId).reviewer(user.id().toString()).remove(input);
if (notify) {
assertThat(sender.getMessages()).hasSize(1);
Message message = sender.getMessages().get(0);
assertThat(message.body()).contains("Removed reviewer " + user.getNameEmail() + " with the following votes");
assertThat(message.body()).contains("* Code-Review+1 by " + user.getNameEmail());
ChangeMessageInfo changeMessageInfo = Iterables.getLast(gApi.changes().id(changeId).messages());
assertThat(changeMessageInfo.message).contains("Removed reviewer " + user.getNameEmail() + " with the following votes");
assertThat(changeMessageInfo.message).contains("* Code-Review+1 by " + user.getNameEmail());
changeMessageInfo = Iterables.getLast(gApi.changes().id(changeId).get().messages);
assertThat(changeMessageInfo.message).contains("Removed reviewer " + AccountTemplateUtil.getAccountTemplate(user.id()) + " with the following votes");
assertThat(changeMessageInfo.message).contains("* Code-Review+1 by " + AccountTemplateUtil.getAccountTemplate(user.id()));
assertThat(changeMessageInfo.accountsInMessage).containsExactly(getAccountInfo(user.id()));
} else {
assertThat(sender.getMessages()).isEmpty();
}
reviewers = gApi.changes().id(changeId).get().reviewers.get(REVIEWER);
assertThat(reviewers).hasSize(1);
reviewerIt = reviewers.iterator();
assertThat(reviewerIt.next()._accountId).isEqualTo(admin.id().get());
eventRecorder.assertReviewerDeletedEvents(changeId, user.email());
}
use of com.google.gerrit.extensions.api.changes.DeleteReviewerInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewDoesNotAddUsersInACommentThreadThatAreNotActiveInTheChange.
@Test
public void reviewDoesNotAddUsersInACommentThreadThatAreNotActiveInTheChange() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
change(r).current().review(reviewWithComment());
change(r).reviewer(user.id().toString()).remove(new DeleteReviewerInput());
requestScopeOperations.setApiUser(admin.id());
change(r).current().review(reviewInReplyToComment(Iterables.getOnlyElement(gApi.changes().id(r.getChangeId()).current().commentsAsList()).id));
// The user was to be added, but was not added since that user is no longer a
// reviewer/cc/owner/uploader.
assertThat(getAttentionSetUpdatesForUser(r, user)).isEmpty();
}
Aggregations