use of com.google.gerrit.extensions.common.AccountInfo 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.common.AccountInfo 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.common.AccountInfo 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.common.AccountInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method moveCcToReviewer.
@Test
public void moveCcToReviewer() throws Exception {
// Create a change and add 'user' as CC.
String changeId = createChange().getChangeId();
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = user.email();
reviewerInput.state = ReviewerState.CC;
gApi.changes().id(changeId).addReviewer(reviewerInput);
// Verify that 'user' is a CC on the change and that there are no reviewers.
ChangeInfo c = gApi.changes().id(changeId).get();
Collection<AccountInfo> ccs = c.reviewers.get(CC);
assertThat(ccs).isNotNull();
assertThat(ccs).hasSize(1);
assertThat(ccs.iterator().next()._accountId).isEqualTo(user.id().get());
assertThat(c.reviewers.get(REVIEWER)).isNull();
// Move 'user' from CC to reviewer.
gApi.changes().id(changeId).addReviewer(user.id().toString());
// Verify that 'user' is a reviewer on the change now and that there are no CCs.
c = gApi.changes().id(changeId).get();
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
assertThat(c.reviewers.get(CC)).isNull();
}
use of com.google.gerrit.extensions.common.AccountInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method removeByEmail.
@Test
public void removeByEmail() 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);
gApi.changes().id(r.getChangeId()).reviewer(acc.email).remove();
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
assertThat(info.reviewers).isEmpty();
}
}
Aggregations