Search in sources :

Example 26 with AttentionSetUpdate

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");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 27 with AttentionSetUpdate

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");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 28 with AttentionSetUpdate

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");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 29 with AttentionSetUpdate

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());
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 30 with AttentionSetUpdate

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);
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) DraftInput(com.google.gerrit.extensions.api.changes.DraftInput) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Result(com.google.gerrit.acceptance.PushOneCommit.Result) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)65 Test (org.junit.Test)61 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)52 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)51 AttentionSetInput (com.google.gerrit.extensions.api.changes.AttentionSetInput)21 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)21 Change (com.google.gerrit.entities.Change)12 TestAccount (com.google.gerrit.acceptance.TestAccount)9 Account (com.google.gerrit.entities.Account)4 ImmutableList (com.google.common.collect.ImmutableList)3 Operation (com.google.gerrit.entities.AttentionSetUpdate.Operation)3 DeleteReviewerInput (com.google.gerrit.extensions.api.changes.DeleteReviewerInput)3 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)3 AttentionSetInfo (com.google.gerrit.extensions.common.AttentionSetInfo)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 Result (com.google.gerrit.acceptance.PushOneCommit.Result)2 LabelId (com.google.gerrit.entities.LabelId)2 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)2 SubmitRecord (com.google.gerrit.entities.SubmitRecord)2 Inject (com.google.inject.Inject)2