use of com.google.gerrit.extensions.api.changes.AttentionSetInput 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.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AttentionSetIT method cannotRemoveNonExistingUser.
@Test
public void cannotRemoveNonExistingUser() throws Exception {
PushOneCommit.Result r = createChange();
BadRequestException exception = assertThrows(BadRequestException.class, () -> change(r).attention("INVALID USER").remove(new AttentionSetInput("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");
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class ChangeIT method rebaseAsUploaderInAttentionSet.
@Test
public void rebaseAsUploaderInAttentionSet() throws Exception {
// Create two changes both with the same parent
PushOneCommit.Result r = createChange();
testRepo.reset("HEAD~1");
PushOneCommit.Result r2 = createChange();
// Approve and submit the first change
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
revision.review(ReviewInput.approve());
revision.submit();
TestAccount admin2 = accountCreator.admin2();
requestScopeOperations.setApiUser(admin2.id());
amendChangeWithUploader(r2, project, admin2);
gApi.changes().id(r2.getChangeId()).addToAttentionSet(new AttentionSetInput(admin2.id().toString(), "manual update"));
gApi.changes().id(r2.getChangeId()).rebase();
}
use of com.google.gerrit.extensions.api.changes.AttentionSetInput 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.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method attentionSetStored.
@Test
public void attentionSetStored() throws Exception {
assume().that(getSchema().hasField(ChangeField.ATTENTION_SET_USERS)).isTrue();
TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChange(repo));
AttentionSetInput input = new AttentionSetInput(userId.toString(), "reason 1");
gApi.changes().id(change.getChangeId()).addToAttentionSet(input);
Account.Id user2Id = accountManager.authenticate(authRequestFactory.createForUser("anotheruser")).getAccountId();
// Add the second user as cc to ensure that user took part of the change and can be added to the
// attention set.
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = user2Id.toString();
reviewerInput.state = ReviewerState.CC;
gApi.changes().id(change.getChangeId()).addReviewer(reviewerInput);
input = new AttentionSetInput(user2Id.toString(), "reason 2");
gApi.changes().id(change.getChangeId()).addToAttentionSet(input);
List<ChangeInfo> result = newQuery("attention:" + user2Id.toString()).get();
assertThat(result).hasSize(1);
ChangeInfo changeInfo = Iterables.getOnlyElement(result);
assertThat(changeInfo.attentionSet).isNotNull();
assertThat(changeInfo.attentionSet.keySet()).containsExactly(userId.get(), user2Id.get());
assertThat(changeInfo.attentionSet.get(userId.get()).reason).isEqualTo("reason 1");
assertThat(changeInfo.attentionSet.get(user2Id.get()).reason).isEqualTo("reason 2");
}
Aggregations