Search in sources :

Example 21 with AttentionSetInput

use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.

the class AbstractSubmit method submitThatAddsUsersAsReviewersEnsuresTheyAreNotAddedToAttentionSet.

@Test
public void submitThatAddsUsersAsReviewersEnsuresTheyAreNotAddedToAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange("refs/heads/master", "file1", "content");
    // Someone else approves, because if admin reviews, they will be added to the reviewers (and the
    // bug won't be reproduced).
    requestScopeOperations.setApiUser(accountCreator.admin2().id());
    change(r).current().review(ReviewInput.approve().addUserToAttentionSet(user.email(), "reason"));
    requestScopeOperations.setApiUser(admin.id());
    change(r).attention(admin.email()).remove(new AttentionSetInput("remove"));
    change(r).current().submit();
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin));
    assertThat(attentionSet.account()).isEqualTo(admin.id());
    assertThat(attentionSet.operation()).isEqualTo(AttentionSetUpdate.Operation.REMOVE);
    assertThat(attentionSet.reason()).isEqualTo("remove");
}
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 22 with AttentionSetInput

use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.

the class AttentionSetIT method addUser.

@Test
public void addUser() throws Exception {
    PushOneCommit.Result r = createChange();
    requestScopeOperations.setApiUser(user.id());
    int accountId = change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "first"))._accountId;
    assertThat(accountId).isEqualTo(admin.id().get());
    AttentionSetUpdate expectedAttentionSetUpdate = AttentionSetUpdate.createFromRead(fakeClock.now(), admin.id(), AttentionSetUpdate.Operation.ADD, "first");
    assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
    // Second add is ignored.
    accountId = change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "second"))._accountId;
    assertThat(accountId).isEqualTo(admin.id().get());
    assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
    // Only one email since the second add was ignored.
    String emailBody = Iterables.getOnlyElement(sender.getMessages()).body();
    assertThat(emailBody).contains(String.format("%s requires the attention of %s to this change.\n The reason is: first.", user.fullName(), admin.fullName()));
}
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 23 with AttentionSetInput

use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.

the class AttentionSetIT method attentionSetStillChangesWithIgnoreAutomaticAttentionSetRulesWithInputList.

@Test
public void attentionSetStillChangesWithIgnoreAutomaticAttentionSetRulesWithInputList() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
    change(r).current().review(ReviewInput.create().removeUserFromAttentionSet(admin.email(), "removed").blockAutomaticAttentionSetRules());
    // Admin is still removed although we block default attention set rules, since we remove
    // the admin manually.
    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");
}
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 24 with AttentionSetInput

use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.

the class AttentionSetIT method reviewRemoveFromAttentionSetWhileMarkingReadyForReviewJustRemovesUser.

@Test
public void reviewRemoveFromAttentionSetWhileMarkingReadyForReviewJustRemovesUser() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).setWorkInProgress();
    change(r).addReviewer(user.email());
    change(r).addToAttentionSet(new AttentionSetInput(user.email(), "reason"));
    ReviewInput reviewInput = ReviewInput.create().setReady(true).removeUserFromAttentionSet(user.email(), "reason");
    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.REMOVE);
    assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 25 with AttentionSetInput

use of com.google.gerrit.extensions.api.changes.AttentionSetInput in project gerrit by GerritCodeReview.

the class AttentionSetIT method repliesAddsOwnerAndUploader.

@Test
public void repliesAddsOwnerAndUploader() throws Exception {
    // Create change with owner: admin
    PushOneCommit.Result r = createChange();
    r = amendChangeWithUploader(r, project, user);
    TestAccount user2 = accountCreator.user2();
    requestScopeOperations.setApiUser(user2.id());
    change(r).attention(user.email()).remove(new AttentionSetInput("reason"));
    ReviewInput reviewInput = new ReviewInput();
    change(r).current().review(reviewInput);
    reviewInput = new ReviewInput();
    change(r).current().review(reviewInput);
    // Uploader added
    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 the change");
    // Owner added
    attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin));
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Someone else replied on the change");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) TestAccount(com.google.gerrit.acceptance.TestAccount) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) 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