use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewAddToAttentionSetWhileMarkingWorkInProgressJustAddsUser.
@Test
public void reviewAddToAttentionSetWhileMarkingWorkInProgressJustAddsUser() throws Exception {
PushOneCommit.Result r = createChange();
change(r).addReviewer(user.email());
ReviewInput reviewInput = ReviewInput.create().setWorkInProgress(true).addUserToAttentionSet(user.email(), "reason");
change(r).attention(user.email()).remove(new AttentionSetInput("removal"));
change(r).current().review(reviewInput);
// Attention set updates that relate to the admin (the person who replied) are filtered out.
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method cannotAddIrrelevantUserToAttentionSet.
@Test
public void cannotAddIrrelevantUserToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).addToAttentionSet(new AttentionSetInput(user.email(), "reason")));
assertThat(exception.getMessage()).isEqualTo(String.format("%s doesn't exist or is not active on the change as an owner, uploader, reviewer, " + "or cc so they can't be added to the attention set", user.email()));
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method abandonRemovesUsers.
@Test
public void abandonRemovesUsers() throws Exception {
PushOneCommit.Result r = createChange();
// implictly adds the user to the attention set when adding as reviewer
change(r).addReviewer(user.email());
change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "admin"));
change(r).abandon();
AttentionSetUpdate userUpdate = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
assertThat(userUpdate).hasAccountIdThat().isEqualTo(user.id());
assertThat(userUpdate).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(userUpdate).hasReasonThat().isEqualTo("Change was abandoned");
AttentionSetUpdate adminUpdate = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin));
assertThat(adminUpdate).hasAccountIdThat().isEqualTo(admin.id());
assertThat(adminUpdate).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(adminUpdate).hasReasonThat().isEqualTo("Change was abandoned");
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method attentionSetUnchangedWithIgnoreAutomaticAttentionSetRules.
@Test
public void attentionSetUnchangedWithIgnoreAutomaticAttentionSetRules() throws Exception {
PushOneCommit.Result r = createChange();
change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
change(r).current().review(ReviewInput.create().reviewer(admin.email(), ReviewerState.CC, false).blockAutomaticAttentionSetRules());
// admin is still in the attention set, although replies remove from attention set, and removing
// from reviewer also should remove from attention set.
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput 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");
}
Aggregations