use of com.google.gerrit.extensions.api.changes.ReviewerInput 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.api.changes.ReviewerInput 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.api.changes.ReviewerInput 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.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method removeCCWithoutPermissionFails.
@Test
public void removeCCWithoutPermissionFails() throws Exception {
PushOneCommit.Result r = createChange();
TestAccount newUser = createAccounts(1, name("foo")).get(0);
ReviewerInput input = new ReviewerInput();
input.reviewer = user.email();
input.state = ReviewerState.CC;
gApi.changes().id(r.getChangeId()).addReviewer(input);
requestScopeOperations.setApiUser(newUser.id());
assertThat(gApi.changes().id(r.getChangeId()).get().removableReviewers).isEmpty();
AuthException thrown = assertThrows(AuthException.class, () -> gApi.changes().id(r.getChangeId()).reviewer(user.email()).remove());
assertThat(thrown).hasMessageThat().contains("remove reviewer not permitted");
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addExistingCcShortCircuits.
@Test
public void addExistingCcShortCircuits() throws Exception {
PushOneCommit.Result r = createChange();
ReviewerInput input = new ReviewerInput();
input.reviewer = user.email();
input.state = ReviewerState.CC;
ReviewerResult result = gApi.changes().id(r.getChangeId()).addReviewer(input);
assertThat(result.ccs).hasSize(1);
AccountInfo info = result.ccs.get(0);
assertThat(info._accountId).isEqualTo(user.id().get());
assertThat(gApi.changes().id(r.getChangeId()).addReviewer(input).ccs).isEmpty();
}
Aggregations