use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method listReviewersByEmail.
@Test
public void listReviewersByEmail() throws Exception {
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
ReviewerInput input = new ReviewerInput();
input.reviewer = toRfcAddressString(acc);
input.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(input);
RestResponse restResponse = adminRestSession.get("/changes/" + r.getChangeId() + "/reviewers/");
restResponse.assertOK();
Type type = new TypeToken<List<ReviewerInfo>>() {
}.getType();
List<ReviewerInfo> reviewers = newGson().fromJson(restResponse.getReader(), type);
restResponse.consume();
assertThat(reviewers).hasSize(1);
ReviewerInfo reviewerInfo = Iterables.getOnlyElement(reviewers);
assertThat(reviewerInfo._accountId).isNull();
assertThat(reviewerInfo.name).isEqualTo(acc.name);
assertThat(reviewerInfo.email).isEqualTo(acc.email);
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method removingReviewerTriggersNotification.
@Test
public void removingReviewerTriggersNotification() throws Exception {
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
ReviewerInput addInput = new ReviewerInput();
addInput.reviewer = toRfcAddressString(acc);
addInput.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(addInput);
// Review change as user
ReviewInput reviewInput = new ReviewInput();
reviewInput.message = "I have a comment";
requestScopeOperations.setApiUser(user.id());
revision(r).review(reviewInput);
requestScopeOperations.setApiUser(admin.id());
sender.clear();
// Delete as admin
gApi.changes().id(r.getChangeId()).reviewer(addInput.reviewer).remove();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(Address.parse(addInput.reviewer), user.getNameEmail());
sender.clear();
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class Reviewers method display.
private void display(ChangeInfo info) {
Map<ReviewerState, List<AccountInfo>> reviewers = info.reviewers();
Map<Integer, AccountInfo> r = byAccount(reviewers, ReviewerState.REVIEWER);
Map<Integer, AccountInfo> cc = byAccount(reviewers, ReviewerState.CC);
for (Integer i : r.keySet()) {
cc.remove(i);
}
cc.remove(info.owner()._accountId());
Set<Integer> removable = info.removableReviewerIds();
Map<Integer, VotableInfo> votable = votable(info);
SafeHtml rHtml = Labels.formatUserList(style, r.values(), removable, null, votable);
SafeHtml ccHtml = Labels.formatUserList(style, cc.values(), removable, null, votable);
reviewersText.setInnerSafeHtml(rHtml);
ccText.setInnerSafeHtml(ccHtml);
if (Gerrit.isSignedIn()) {
int currentUser = Gerrit.getUserAccount()._accountId();
boolean showAddMeButton = info.owner()._accountId() != currentUser && !cc.containsKey(currentUser) && !r.containsKey(currentUser);
addMe.setVisible(showAddMeButton);
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class PostReviewIT method votingMakesCallerReviewer.
@Test
public void votingMakesCallerReviewer() throws Exception {
// Admin owns the change
PushOneCommit.Result r = createChange();
// User adds themselves and changes state
requestScopeOperations.setApiUser(user.id());
ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 1);
gApi.changes().id(r.getChangeId()).current().review(input);
Map<ReviewerState, Collection<AccountInfo>> reviewers = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers).hasSize(1);
AccountInfo reviewer = Iterables.getOnlyElement(reviewers.get(ReviewerState.REVIEWER));
assertThat(reviewer._accountId).isEqualTo(user.id().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class PostReviewIT method reviewerToCc.
@Test
public void reviewerToCc() throws Exception {
// Admin owns the change
PushOneCommit.Result r = createChange();
// User adds themselves and changes state
requestScopeOperations.setApiUser(user.id());
ReviewInput input = new ReviewInput().reviewer(user.id().toString());
gApi.changes().id(r.getChangeId()).current().review(input);
Map<ReviewerState, Collection<AccountInfo>> reviewers = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers).hasSize(1);
AccountInfo reviewer = Iterables.getOnlyElement(reviewers.get(ReviewerState.REVIEWER));
assertThat(reviewer._accountId).isEqualTo(user.id().get());
// Reviewer -> CC
ReviewInput input2 = new ReviewInput().reviewer(user.id().toString(), ReviewerState.CC, false);
gApi.changes().id(r.getChangeId()).current().review(input2);
Map<ReviewerState, Collection<AccountInfo>> reviewers2 = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers2).hasSize(1);
AccountInfo reviewer2 = Iterables.getOnlyElement(reviewers2.get(ReviewerState.CC));
assertThat(reviewer2._accountId).isEqualTo(user.id().get());
}
Aggregations