use of com.google.gerrit.extensions.api.changes.AttentionSetInput 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.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method cannotRemoveIrrelevantUserToAttentionSet.
@Test
public void cannotRemoveIrrelevantUserToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).attention(user.email()).remove(new AttentionSetInput("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 canModifyAttentionSetForInvisibleUsersOnVisibleChanges.
@Test
@GerritConfig(name = "accounts.visibility", value = "NONE")
public void canModifyAttentionSetForInvisibleUsersOnVisibleChanges() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
// admin is invisible to the user, but they can still add them to the attention set since they
// see the change.
change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.ADD);
// admin is invisible to the user, but they can still remove them to the attention set since
// they see the change.
change(r).attention(admin.id().toString()).remove(new AttentionSetInput("removed"));
assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.REMOVE);
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method reviewRemovesUserFromAttentionSet.
@Test
public void reviewRemovesUserFromAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
ReviewInput reviewInput = new ReviewInput();
change(r).current().review(reviewInput);
AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
assertThat(attentionSet).hasReasonThat().isEqualTo("removed on reply");
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method cannotAddNonExistingUserToAttentionSet.
@Test
public void cannotAddNonExistingUserToAttentionSet() throws Exception {
PushOneCommit.Result r = createChange();
BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).addToAttentionSet(new AttentionSetInput("INVALID USER", "reason")));
assertThat(exception.getMessage()).isEqualTo("INVALID USER 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");
}
Aggregations