use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class CommentsIT method commentsOnRootCommitsAreIncludedInEmails.
@Test
public void commentsOnRootCommitsAreIncludedInEmails() throws Exception {
// Create a change in a new branch, making the patch-set commit a root commit.
ChangeInfo changeInfo = createChangeInNewBranch("newBranch");
Change.Id changeId = Change.Id.tryParse(Integer.toString(changeInfo._number)).get();
// Add a file.
gApi.changes().id(changeId.get()).edit().modifyFile("f1.txt", RawInputUtil.create("content"));
gApi.changes().id(changeId.get()).edit().publish();
email.clear();
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = admin.email();
gApi.changes().id(changeId.get()).addReviewer(reviewerInput);
changeInfo = gApi.changes().id(changeId.get()).get();
assertThat(email.getMessages()).hasSize(1);
Message message = email.getMessages().get(0);
assertThat(message.body()).contains("f1.txt");
email.clear();
// Send a comment. Make sure the email that is sent includes the comment text.
CommentInput c1 = CommentsUtil.newComment("f1.txt", Side.REVISION, /* line= */
1, /* message= */
"Comment text", /* unresolved= */
false);
CommentsUtil.addComments(gApi, changeId.toString(), changeInfo.currentRevision, c1);
assertThat(email.getMessages()).hasSize(1);
Message commentMessage = email.getMessages().get(0);
assertThat(commentMessage.body()).contains("Patch Set 2:\n" + "\n" + "(1 comment)\n" + "\n" + "File f1.txt:");
assertThat(commentMessage.body()).contains("PS2, Line 1: content\n" + "Comment text");
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class CustomLabelIT method customLabelAnyWithBlock_Addreviewer_ZeroVote.
@Test
public void customLabelAnyWithBlock_Addreviewer_ZeroVote() throws Exception {
TestListener testListener = new TestListener();
try (Registration registration = extensionRegistry.newRegistration().add(testListener)) {
saveLabelConfig(P.toBuilder().setFunction(ANY_WITH_BLOCK));
PushOneCommit.Result r = createChange();
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
gApi.changes().id(r.getChangeId()).addReviewer(in);
ReviewInput input = new ReviewInput().label(P_LABEL_NAME, 0);
input.message = "foo";
revision(r).review(input);
ChangeInfo c = getWithLabels(r);
LabelInfo q = c.labels.get(P_LABEL_NAME);
assertThat(q.all).hasSize(1);
assertThat(q.approved).isNull();
assertThat(q.recommended).isNull();
assertThat(q.disliked).isNull();
assertThat(q.rejected).isNull();
assertThat(q.blocking).isNull();
assertThat(testListener.lastCommentAddedEvent.getComment()).isEqualTo("Patch Set 1:\n\n" + input.message);
}
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method suggestReviewerAsCc.
@Test
public void suggestReviewerAsCc() throws Exception {
requestScopeOperations.setApiUser(user.id());
String changeId = createChangeFromApi();
String changeIdReviewed = createChangeFromApi();
String name = name("foo");
TestAccount foo1 = accountCreator.create(name + "-1");
reviewChange(changeIdReviewed, foo1);
TestAccount foo2 = accountCreator.create(name + "-2");
reviewChange(changeIdReviewed, foo2);
assertReviewers(suggestCcs(changeId, name), ImmutableList.of(foo1, foo2), ImmutableList.of());
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = foo2.id().toString();
reviewerInput.state = ReviewerState.REVIEWER;
gApi.changes().id(changeId).addReviewer(reviewerInput);
assertReviewers(suggestCcs(changeId, name), ImmutableList.of(foo1, foo2), ImmutableList.of());
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class SuggestReviewersIT method suggestCcAsReviewer.
@Test
public void suggestCcAsReviewer() throws Exception {
requestScopeOperations.setApiUser(user.id());
String changeId = createChangeFromApi();
String changeIdReviewed = createChangeFromApi();
String name = name("foo");
TestAccount foo1 = accountCreator.create(name + "-1");
reviewChange(changeIdReviewed, foo1);
TestAccount foo2 = accountCreator.create(name + "-2");
reviewChange(changeIdReviewed, foo2);
assertReviewers(suggestReviewers(changeId, name), ImmutableList.of(foo1, foo2), ImmutableList.of());
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = foo2.id().toString();
reviewerInput.state = ReviewerState.CC;
gApi.changes().id(changeId).addReviewer(reviewerInput);
assertReviewers(suggestReviewers(changeId, name), ImmutableList.of(foo1, foo2), ImmutableList.of());
}
use of com.google.gerrit.extensions.api.changes.ReviewerInput in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method reviewerin.
@Test
public void reviewerin() throws Exception {
Account.Id user1 = accountManager.authenticate(authRequestFactory.createForUser("user1")).getAccountId();
Account.Id user2 = accountManager.authenticate(authRequestFactory.createForUser("user2")).getAccountId();
Account.Id user3 = accountManager.authenticate(authRequestFactory.createForUser("user3")).getAccountId();
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
Change change3 = insert(repo, newChange(repo));
ReviewerInput rin = new ReviewerInput();
rin.reviewer = user1.toString();
rin.state = ReviewerState.REVIEWER;
gApi.changes().id(change1.getId().get()).addReviewer(rin);
rin = new ReviewerInput();
rin.reviewer = user2.toString();
rin.state = ReviewerState.REVIEWER;
gApi.changes().id(change2.getId().get()).addReviewer(rin);
rin = new ReviewerInput();
rin.reviewer = user3.toString();
rin.state = ReviewerState.CC;
gApi.changes().id(change3.getId().get()).addReviewer(rin);
String group = gApi.groups().create("foo").get().name;
gApi.groups().id(group).addMembers(user2.toString(), user3.toString());
List<String> members = gApi.groups().id(group).members().stream().map(a -> a._accountId.toString()).collect(toList());
assertThat(members).contains(user2.toString());
assertQuery("reviewerin:\"Registered Users\"", change2, change1);
assertQuery("reviewerin:" + group, change2);
gApi.changes().id(change2.getId().get()).current().review(ReviewInput.approve());
gApi.changes().id(change2.getId().get()).current().submit();
assertQuery("reviewerin:" + group, change2);
assertQuery("project:repo reviewerin:" + group, change2);
assertQuery("status:merged reviewerin:" + group, change2);
}
Aggregations