use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class RevertIT method revertSubmissionPreservesReviewersAndCcs.
@Test
public void revertSubmissionPreservesReviewersAndCcs() throws Exception {
String change = createChange("first change", "a.txt", "message").getChangeId();
ReviewInput in = ReviewInput.approve();
in.reviewer(user.email());
in.reviewer(accountCreator.user2().email(), ReviewerState.CC, true);
// Add user as reviewer that will create the revert
in.reviewer(accountCreator.admin2().email());
gApi.changes().id(change).current().review(in);
gApi.changes().id(change).current().submit();
// expect both the original reviewers and CCs to be preserved
// original owner should be added as reviewer, user requesting the revert (new owner) removed
requestScopeOperations.setApiUser(accountCreator.admin2().id());
Map<ReviewerState, Collection<AccountInfo>> result = getChangeApis(gApi.changes().id(change).revertSubmission()).get(0).get().reviewers;
assertThat(result).containsKey(ReviewerState.REVIEWER);
List<Integer> reviewers = result.get(ReviewerState.REVIEWER).stream().map(a -> a._accountId).collect(toList());
assertThat(result).containsKey(ReviewerState.CC);
List<Integer> ccs = result.get(ReviewerState.CC).stream().map(a -> a._accountId).collect(toList());
assertThat(ccs).containsExactly(accountCreator.user2().id().get());
assertThat(reviewers).containsExactly(user.id().get(), admin.id().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class RevertIT method revertPreservesReviewersAndCcs.
@Test
public void revertPreservesReviewersAndCcs() throws Exception {
PushOneCommit.Result r = createChange();
ReviewInput in = ReviewInput.approve();
in.reviewer(user.email());
in.reviewer(accountCreator.user2().email(), ReviewerState.CC, true);
// Add user as reviewer that will create the revert
in.reviewer(accountCreator.admin2().email());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(in);
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
// expect both the original reviewers and CCs to be preserved
// original owner should be added as reviewer, user requesting the revert (new owner) removed
requestScopeOperations.setApiUser(accountCreator.admin2().id());
Map<ReviewerState, Collection<AccountInfo>> result = gApi.changes().id(r.getChangeId()).revert().get().reviewers;
assertThat(result).containsKey(ReviewerState.REVIEWER);
List<Integer> reviewers = result.get(ReviewerState.REVIEWER).stream().map(a -> a._accountId).collect(toList());
assertThat(result).containsKey(ReviewerState.CC);
List<Integer> ccs = result.get(ReviewerState.CC).stream().map(a -> a._accountId).collect(toList());
assertThat(ccs).containsExactly(accountCreator.user2().id().get());
assertThat(reviewers).containsExactly(user.id().get(), admin.id().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class PostReviewIT method ccToReviewer.
@Test
public void ccToReviewer() throws Exception {
PushOneCommit.Result r = createChange();
// User adds themselves and changes state
requestScopeOperations.setApiUser(user.id());
ReviewInput input = new ReviewInput().reviewer(user.id().toString(), ReviewerState.CC, false);
gApi.changes().id(r.getChangeId()).current().review(input);
Map<ReviewerState, Collection<AccountInfo>> reviewers = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers).hasSize(1);
AccountInfo reviewer = Iterables.getOnlyElement(reviewers.get(ReviewerState.CC));
assertThat(reviewer._accountId).isEqualTo(user.id().get());
// CC -> Reviewer
ReviewInput input2 = new ReviewInput().reviewer(user.id().toString());
gApi.changes().id(r.getChangeId()).current().review(input2);
Map<ReviewerState, Collection<AccountInfo>> reviewers2 = gApi.changes().id(r.getChangeId()).get().reviewers;
assertThat(reviewers2).hasSize(1);
AccountInfo reviewer2 = Iterables.getOnlyElement(reviewers2.get(ReviewerState.REVIEWER));
assertThat(reviewer2._accountId).isEqualTo(user.id().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickKeepReviewers.
@Test
public void cherryPickKeepReviewers() throws Exception {
createBranch(BranchNameKey.create(project, "stable"));
// Change is created by 'admin'.
PushOneCommit.Result r = createChange();
// Change is approved by 'admin2'. Change is CC'd to 'user'.
requestScopeOperations.setApiUser(accountCreator.admin2().id());
ReviewInput in = ReviewInput.approve();
in.reviewer(user.email(), ReviewerState.CC, true);
gApi.changes().id(r.getChangeId()).current().review(in);
// Change is cherrypicked by 'user2'.
requestScopeOperations.setApiUser(accountCreator.user2().id());
CherryPickInput cin = new CherryPickInput();
cin.message = "this need to go to stable";
cin.destination = "stable";
cin.keepReviewers = true;
Map<ReviewerState, Collection<AccountInfo>> result = gApi.changes().id(r.getChangeId()).current().cherryPick(cin).get().reviewers;
// 'admin' should be a reviewer as the old owner.
// 'admin2' should be a reviewer as the old reviewer.
// 'user' should be on CC.
assertThat(result).containsKey(ReviewerState.REVIEWER);
List<Integer> reviewers = result.get(ReviewerState.REVIEWER).stream().map(a -> a._accountId).collect(toList());
assertThat(result).containsKey(ReviewerState.CC);
List<Integer> ccs = result.get(ReviewerState.CC).stream().map(a -> a._accountId).collect(toList());
assertThat(ccs).containsExactly(user.id().get());
assertThat(reviewers).containsExactly(admin.id().get(), accountCreator.admin2().id().get());
}
use of com.google.gerrit.extensions.client.ReviewerState in project gerrit by GerritCodeReview.
the class ChangeReviewersByEmailIT method addByEmail.
@Test
public void addByEmail() 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);
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(DETAILED_LABELS);
assertThat(info.reviewers).containsExactly(state, ImmutableList.of(acc));
// All reviewers added by email should be removable
assertThat(info.removableReviewers).containsExactly(acc);
}
}
Aggregations