use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeIT method getReviewerState.
private Optional<ReviewerState> getReviewerState(String changeId, Account.Id accountId) throws Exception {
ChangeInfo c = gApi.changes().id(changeId).get(DETAILED_LABELS);
Set<ReviewerState> states = c.reviewers.entrySet().stream().filter(e -> e.getValue().stream().anyMatch(a -> a._accountId == accountId.get())).map(Map.Entry::getKey).collect(toSet());
assertWithMessage(states.toString()).that(states.size()).isAtMost(1);
return states.stream().findFirst();
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addByEmailAndById.
@Test
public void addByEmailAndById() throws Exception {
AccountInfo byEmail = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
AccountInfo byId = new AccountInfo(user.id().get());
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
ReviewerInput inputByEmail = new ReviewerInput();
inputByEmail.reviewer = toRfcAddressString(byEmail);
inputByEmail.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(inputByEmail);
ReviewerInput inputById = new ReviewerInput();
inputById.reviewer = user.email();
inputById.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(inputById);
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
assertThat(info.reviewers).isEqualTo(ImmutableMap.of(state, ImmutableList.of(byId, byEmail)));
// All reviewers (both by id and by email) should be removable
assertThat(info.removableReviewers).containsExactly(byId, byEmail);
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addedReviewersGetNotified.
@Test
public void addedReviewersGetNotified() 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);
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
assertThat(messages.get(0).rcpt()).containsExactly(Address.parse(input.reviewer));
sender.clear();
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method reviewersByEmailAreServedFromIndex.
@Test
public void reviewersByEmailAreServedFromIndex() 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);
try (AutoCloseable ignored = disableNoteDb()) {
ChangeInfo info = Iterables.getOnlyElement(gApi.changes().query(r.getChangeId()).withOption(DETAILED_LABELS).get());
assertThat(info.reviewers).isEqualTo(ImmutableMap.of(state, ImmutableList.of(acc)));
}
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addingMultipleReviewersAndCCsAtOnceSendsOnlyOneEmail.
@Test
public void addingMultipleReviewersAndCCsAtOnceSendsOnlyOneEmail() throws Exception {
PushOneCommit.Result r = createChange();
ReviewInput reviewInput = new ReviewInput();
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
for (int i = 0; i < 10; i++) {
reviewInput.reviewer(String.format("%s-%s@gerritcodereview.com", state, i), state, true);
}
}
assertThat(reviewInput.reviewers).hasSize(20);
sender.clear();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(reviewInput);
assertThat(sender.getMessages()).hasSize(1);
}
Aggregations