use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewAddsAllUsersInCommentThreadWhenPostedAsDraft.
@Test
public void reviewAddsAllUsersInCommentThreadWhenPostedAsDraft() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
change(r).current().review(reviewWithComment());
requestScopeOperations.setApiUser(admin.id());
testCommentHelper.addDraft(r.getChangeId(), testCommentHelper.newDraft("message", Iterables.getOnlyElement(gApi.changes().id(r.getChangeId()).current().commentsAsList()).id));
ReviewInput reviewInput = new ReviewInput();
reviewInput.drafts = ReviewInput.DraftHandling.PUBLISH;
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, 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 reviewAddsAllUsersInCommentThread.
@Test
public void reviewAddsAllUsersInCommentThread() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
change(r).current().review(reviewWithComment());
TestAccount user2 = accountCreator.user2();
requestScopeOperations.setApiUser(user2.id());
change(r).current().review(reviewInReplyToComment(Iterables.getOnlyElement(gApi.changes().id(r.getChangeId()).current().commentsAsList()).id));
change(r).attention(user.email()).remove(new AttentionSetInput("removal"));
requestScopeOperations.setApiUser(admin.id());
change(r).current().review(reviewInReplyToComment(gApi.changes().id(r.getChangeId()).current().commentsAsList().get(1).id));
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, 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");
attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user2));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user2.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 readyForReviewWhileRemovingReviewerRemovesThemToAttentionSet.
@Test
public void readyForReviewWhileRemovingReviewerRemovesThemToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
change(r).setWorkInProgress();
change(r).addReviewer(user.email());
ReviewInput reviewInput = ReviewInput.create().setReady(true);
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.state = ReviewerState.CC;
reviewerInput.reviewer = user.email();
reviewInput.reviewers = ImmutableList.of(reviewerInput);
change(r).addToAttentionSet(new AttentionSetInput(user.email(), "reason"));
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
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.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method robotAddingAReviewerChangeAttentionSet.
@Test
public void robotAddingAReviewerChangeAttentionSet() throws Exception {
TestAccount robot = accountCreator.create("robot2", "robot2@example.com", "Ro Bot", "Ro", ServiceUserClassifier.SERVICE_USERS);
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(robot.id());
change(r).addReviewer(user.id().toString());
// Bots can still change the attention set, just not when replying.
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
}
use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.
the class AttentionSetIT method readyForReviewWhileAddingReviewerAddsThemToAttentionSet.
@Test
public void readyForReviewWhileAddingReviewerAddsThemToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
change(r).setWorkInProgress();
ReviewInput reviewInput = ReviewInput.create().setReady(true).reviewer(user.email());
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
}
Aggregations