Search in sources :

Example 16 with AttentionSetInput

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");
}
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 17 with AttentionSetInput

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

Example 18 with AttentionSetInput

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

Example 19 with AttentionSetInput

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());
}
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 20 with AttentionSetInput

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");
}
Also used : Account(com.google.gerrit.entities.Account) Repo(com.google.gerrit.testing.InMemoryRepositoryManager.Repo) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) Change(com.google.gerrit.entities.Change) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) Test(org.junit.Test)

Aggregations

AttentionSetInput (com.google.gerrit.extensions.api.changes.AttentionSetInput)34 Test (org.junit.Test)34 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)32 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)31 AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)21 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)7 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)7 TestAccount (com.google.gerrit.acceptance.TestAccount)5 Change (com.google.gerrit.entities.Change)3 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)3 AttentionSetInfo (com.google.gerrit.extensions.common.AttentionSetInfo)3 Account (com.google.gerrit.entities.Account)2 DeleteReviewerInput (com.google.gerrit.extensions.api.changes.DeleteReviewerInput)2 Repo (com.google.gerrit.testing.InMemoryRepositoryManager.Repo)2 Result (com.google.gerrit.acceptance.PushOneCommit.Result)1 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)1 HashtagsInput (com.google.gerrit.extensions.api.changes.HashtagsInput)1 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)1 GroupInput (com.google.gerrit.extensions.api.groups.GroupInput)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1