use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addByEmailAndById.
@Test
public void addByEmailAndById() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
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();
AddReviewerInput inputByEmail = new AddReviewerInput();
inputByEmail.reviewer = toRfcAddressString(byEmail);
inputByEmail.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(inputByEmail);
AddReviewerInput inputById = new AddReviewerInput();
inputById.reviewer = user.email;
inputById.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(inputById);
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(EnumSet.of(ListChangesOption.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).isEqualTo(ImmutableList.of(byId, byEmail));
}
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method reviewerAndCCReceiveSameEmail.
@Test
public void reviewerAndCCReceiveSameEmail() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
PushOneCommit.Result r = createChange();
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
for (int i = 0; i < 10; i++) {
AddReviewerInput input = new AddReviewerInput();
input.reviewer = String.format("%s-%s@gerritcodereview.com", state, i);
input.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(input);
}
}
// Also add user as a regular reviewer
AddReviewerInput input = new AddReviewerInput();
input.reviewer = user.email;
input.state = ReviewerState.REVIEWER;
gApi.changes().id(r.getChangeId()).addReviewer(input);
sender.clear();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
// Assert that only one email was sent out to everyone
assertThat(sender.getMessages()).hasSize(1);
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method removeByEmail.
@Test
public void removeByEmail() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
AddReviewerInput addInput = new AddReviewerInput();
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(EnumSet.of(ListChangesOption.DETAILED_LABELS));
assertThat(info.reviewers).isEmpty();
}
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addedReviewersGetNotified.
@Test
public void addedReviewersGetNotified() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
AddReviewerInput input = new AddReviewerInput();
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.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method reviewerAndCCReceiveRegularNotification.
@Test
public void reviewerAndCCReceiveRegularNotification() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();
AccountInfo acc = new AccountInfo("Foo Bar", "foo.bar@gerritcodereview.com");
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
PushOneCommit.Result r = createChange();
AddReviewerInput input = new AddReviewerInput();
input.reviewer = toRfcAddressString(acc);
input.state = state;
gApi.changes().id(r.getChangeId()).addReviewer(input);
sender.clear();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
if (state == ReviewerState.CC) {
assertNotifyCc(Address.parse(input.reviewer));
} else {
assertNotifyTo(Address.parse(input.reviewer));
}
}
}
Aggregations