use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewAddsAllUsersInCommentThreadWhenOriginalCommentIsARobotComment.
@Test
public void reviewAddsAllUsersInCommentThreadWhenOriginalCommentIsARobotComment() throws Exception {
PushOneCommit.Result result = createChange();
testCommentHelper.addRobotComment(result.getChangeId(), TestCommentHelper.createRobotCommentInputWithMandatoryFields(Patch.COMMIT_MSG));
requestScopeOperations.setApiUser(user.id());
// Reply to the robot comment.
change(result).current().review(reviewInReplyToComment(Iterables.getOnlyElement(gApi.changes().id(result.getChangeId()).current().robotCommentsAsList()).id));
requestScopeOperations.setApiUser(admin.id());
// Reply to the human comment. which was a reply to the robot comment.
change(result).current().review(reviewInReplyToComment(Iterables.getOnlyElement(gApi.changes().id(result.getChangeId()).current().commentsAsList()).id));
// The user which replied to the robot comment was added to the attention set.
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(result, user));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("Someone else replied on a comment you posted");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewersAddedAsReviewersAgainAreNotAddedToAttentionSet.
@Test
public void reviewersAddedAsReviewersAgainAreNotAddedToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
change(r).addReviewer(user.id().toString());
change(r).attention(user.id().toString()).remove(new AttentionSetInput("removed and not re-added when re-adding as reviewer"));
change(r).addReviewer(user.id().toString());
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(attentionSet).hasReasonThat().isEqualTo("removed and not re-added when re-adding as reviewer");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method repliesAddsOwner.
@Test
public void repliesAddsOwner() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
ReviewInput reviewInput = new ReviewInput();
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("Someone else replied on the change");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class ReceiveCommitsCommentValidationIT method attentionSetNotUpdatedWhenNoCommentsPublished.
@Test
public void attentionSetNotUpdatedWhenNoCommentsPublished() throws Exception {
PushOneCommit.Result result = createChange();
String changeId = result.getChangeId();
gApi.changes().id(changeId).addReviewer(user.email());
gApi.changes().id(changeId).attention(user.email()).remove(new AttentionSetInput("removed"));
ImmutableSet<AttentionSetUpdate> attentionSet = result.getChange().attentionSet();
Result amendResult = amendChange(changeId, "refs/for/master%publish-comments", admin, testRepo);
assertThat(attentionSet).isEqualTo(amendResult.getChange().attentionSet());
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class ReceiveCommitsCommentValidationIT method publishCommentsAddsAllUsersInCommentThread.
@Test
public void publishCommentsAddsAllUsersInCommentThread() throws Exception {
PushOneCommit.Result result = createChange();
String changeId = result.getChangeId();
String revId = result.getCommit().getName();
requestScopeOperations.setApiUser(user.id());
DraftInput comment = testCommentHelper.newDraft(COMMENT_TEXT);
testCommentHelper.addDraft(changeId, revId, comment);
ReviewInput reviewInput = new ReviewInput().blockAutomaticAttentionSetRules();
reviewInput.drafts = ReviewInput.DraftHandling.PUBLISH;
change(result).current().review(reviewInput);
requestScopeOperations.setApiUser(admin.id());
comment = testCommentHelper.newDraft(COMMENT_TEXT, Iterables.getOnlyElement(gApi.changes().id(changeId).current().commentsAsList()).id);
testCommentHelper.addDraft(changeId, revId, comment);
Result amendResult = amendChange(changeId, "refs/for/master%publish-comments", admin, testRepo);
AttentionSetUpdate attentionSetUpdate = Iterables.getOnlyElement(amendResult.getChange().attentionSet());
assertThat(attentionSetUpdate.account()).isEqualTo(user.id());
assertThat(attentionSetUpdate.reason()).isEqualTo("Someone else replied on a comment you posted");
assertThat(attentionSetUpdate.operation()).isEqualTo(AttentionSetUpdate.Operation.ADD);
}
Aggregations