use of com.google.gerrit.extensions.client.ReviewerState 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();
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method reviewerAndCCReceiveRegularNotification.
@Test
public void reviewerAndCCReceiveRegularNotification() 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);
sender.clear();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
assertNotifyCc(Address.parse(input.reviewer));
}
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method reviewerAndCCReceiveSameEmail.
@Test
public void reviewerAndCCReceiveSameEmail() throws Exception {
PushOneCommit.Result r = createChange();
for (ReviewerState state : ImmutableList.of(ReviewerState.CC, ReviewerState.REVIEWER)) {
for (int i = 0; i < 10; i++) {
ReviewerInput input = new ReviewerInput();
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
ReviewerInput input = new ReviewerInput();
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.client.ReviewerState in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method restorePendingReviewers.
@Test
public void restorePendingReviewers() throws Exception {
Project.NameKey project = Project.nameKey("repo");
TestRepository<Repo> repo = createProject(project.get());
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
gApi.projects().name(project.get()).config(conf);
Change change1 = insert(repo, newChangeWorkInProgress(repo));
Account.Id user1 = createAccount("user1");
Account.Id user2 = createAccount("user2");
String email1 = "email1@example.com";
String email2 = "email2@example.com";
ReviewInput in = ReviewInput.noScore().reviewer(user1.toString()).reviewer(user2.toString(), ReviewerState.CC, false).reviewer(email1).reviewer(email2, ReviewerState.CC, false);
gApi.changes().id(change1.getId().get()).current().review(in);
List<ChangeInfo> changeInfos = assertQuery(newQuery("is:wip").withOption(DETAILED_LABELS), change1);
assertThat(changeInfos).isNotEmpty();
Map<ReviewerState, Collection<AccountInfo>> pendingReviewers = changeInfos.get(0).pendingReviewers;
assertThat(pendingReviewers).isNotNull();
assertReviewers(pendingReviewers.get(ReviewerState.REVIEWER), user1.toString(), email1);
assertReviewers(pendingReviewers.get(ReviewerState.CC), user2.toString(), email2);
assertReviewers(pendingReviewers.get(ReviewerState.REMOVED));
// Pending reviewers may also be presented in the REMOVED state. Toggle the
// change to ready and then back to WIP and remove reviewers to produce.
assertThat(pendingReviewers.get(ReviewerState.REMOVED)).isNull();
gApi.changes().id(change1.getId().get()).setReadyForReview();
gApi.changes().id(change1.getId().get()).setWorkInProgress();
gApi.changes().id(change1.getId().get()).reviewer(user1.toString()).remove();
gApi.changes().id(change1.getId().get()).reviewer(user2.toString()).remove();
gApi.changes().id(change1.getId().get()).reviewer(email1).remove();
gApi.changes().id(change1.getId().get()).reviewer(email2).remove();
changeInfos = assertQuery(newQuery("is:wip").withOption(DETAILED_LABELS), change1);
assertThat(changeInfos).isNotEmpty();
pendingReviewers = changeInfos.get(0).pendingReviewers;
assertThat(pendingReviewers).isNotNull();
assertReviewers(pendingReviewers.get(ReviewerState.REVIEWER));
assertReviewers(pendingReviewers.get(ReviewerState.CC));
assertReviewers(pendingReviewers.get(ReviewerState.REMOVED), user1.toString(), user2.toString(), email1, email2);
}
Aggregations