use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method ccsConsideredSameAsRemovedForExistingReviewers.
@Test
public void ccsConsideredSameAsRemovedForExistingReviewers() throws Exception {
PushOneCommit.Result r = createChange();
change(r).addReviewer(user.email());
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.state = ReviewerState.CC;
reviewerInput.reviewer = user.email();
change(r).addReviewer(reviewerInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer/Cc was removed");
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method addSelfAsReviewer.
@Test
@UseClockStep
public void addSelfAsReviewer() throws Exception {
PushOneCommit.Result r = createChange();
ChangeResource rsrc = parseResource(r);
String oldETag = rsrc.getETag();
Instant oldTs = rsrc.getChange().getLastUpdatedOn();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
requestScopeOperations.setApiUser(user.id());
gApi.changes().id(r.getChangeId()).addReviewer(in);
// There should be no email notification when adding self
assertThat(sender.getMessages()).isEmpty();
// Adding a reviewer records that user as reviewer.
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
// Ensure ETag and lastUpdatedOn are updated.
rsrc = parseResource(r);
assertThat(rsrc.getETag()).isNotEqualTo(oldETag);
assertThat(rsrc.getChange().getLastUpdatedOn()).isNotEqualTo(oldTs);
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method addReviewerViaPostReview.
@Test
@UseClockStep
public void addReviewerViaPostReview() throws Exception {
testAddReviewerViaPostReview((changeId, reviewer) -> {
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = reviewer;
ReviewInput reviewInput = new ReviewInput();
reviewInput.reviewers = ImmutableList.of(reviewerInput);
gApi.changes().id(changeId).current().review(reviewInput);
});
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method addReviewerThatIsInactiveByEmail.
@Test
public void addReviewerThatIsInactiveByEmail() throws Exception {
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
gApi.projects().name(project.get()).config(conf);
PushOneCommit.Result result = createChange();
String username = "user@domain.com";
Account.Id id = accountOperations.newAccount().username(username).inactive().create();
ReviewerInput in = new ReviewerInput();
in.reviewer = username;
in.state = ReviewerState.CC;
ReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
assertThat(r.input).isEqualTo(username);
assertThat(r.error).isNull();
assertThat(r.ccs).hasSize(1);
AccountInfo reviewer = r.ccs.get(0);
assertThat(reviewer._accountId).isEqualTo(id.get());
assertThat(reviewer.username).isEqualTo(username);
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class ChangeIT method removeCC.
@Test
public void removeCC() throws Exception {
PushOneCommit.Result result = createChange();
String changeId = result.getChangeId();
// Add a cc
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.state = CC;
reviewerInput.reviewer = user.id().toString();
gApi.changes().id(changeId).addReviewer(reviewerInput);
// Remove a cc
sender.clear();
gApi.changes().id(changeId).reviewer(user.id().toString()).remove();
assertThat(gApi.changes().id(changeId).get().reviewers).isEmpty();
// Make sure the email for removing a cc is correct.
assertThat(sender.getMessages()).hasSize(1);
Message message = sender.getMessages().get(0);
assertThat(message.body()).contains("Removed cc " + user.getNameEmail() + ".");
// Make sure the change message for removing a reviewer is correct.
assertThat(Iterables.getLast(gApi.changes().id(changeId).messages()).message).isEqualTo("Removed cc " + user.getNameEmail() + ".");
ChangeMessageInfo changeMessageInfo = Iterables.getLast(gApi.changes().id(changeId).get().messages);
assertThat(changeMessageInfo.message).isEqualTo("Removed cc " + AccountTemplateUtil.getAccountTemplate(user.id()) + ".");
assertThat(changeMessageInfo.accountsInMessage).containsExactly(getAccountInfo(user.id()));
}
Aggregations