Search in sources :

Example 51 with AttentionSetUpdate

use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.

the class AttentionSetIT method workInProgressHasNoEffectOnWorkInProgressChanges.

@Test
public void workInProgressHasNoEffectOnWorkInProgressChanges() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).current().review(ReviewInput.create().reviewer(user.email()).setWorkInProgress(true).addUserToAttentionSet(user.email(), /* reason= */
    "reason"));
    change(r).current().review(ReviewInput.create().setWorkInProgress(true));
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
    change(r).current().review(ReviewInput.create().setReady(false));
    attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("reason");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 52 with AttentionSetUpdate

use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.

the class AttentionSetIT method reviewWhileAddingThemselvesAsReviewerStillRemovesThem.

@Test
public void reviewWhileAddingThemselvesAsReviewerStillRemovesThem() throws Exception {
    PushOneCommit.Result r = createChange();
    requestScopeOperations.setApiUser(user.id());
    // add the user to the attention set.
    change(r).current().review(ReviewInput.create().reviewer(user.email(), ReviewerState.CC, true).addUserToAttentionSet(user.email(), "reason"));
    // add the user as reviewer but still be removed on reply.
    ReviewInput reviewInput = ReviewInput.create().reviewer(user.email());
    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("removed on reply");
}
Also used : 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 53 with AttentionSetUpdate

use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.

the class AttentionSetIT method removeUser.

@Test
public void removeUser() throws Exception {
    PushOneCommit.Result r = createChange();
    // implictly adds the user to the attention set when adding as reviewer
    change(r).addReviewer(user.email());
    sender.clear();
    requestScopeOperations.setApiUser(user.id());
    fakeClock.advance(Duration.ofSeconds(42));
    change(r).attention(user.id().toString()).remove(new AttentionSetInput("removed"));
    AttentionSetUpdate expectedAttentionSetUpdate = AttentionSetUpdate.createFromRead(fakeClock.now(), user.id(), AttentionSetUpdate.Operation.REMOVE, "removed");
    assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
    // The removal also shows up in AttentionSetInfo.
    AttentionSetInfo attentionSetInfo = Iterables.getOnlyElement(change(r).get().removedFromAttentionSet.values());
    assertThat(attentionSetInfo.reason).isEqualTo("removed");
    assertThat(attentionSetInfo.account).isEqualTo(getAccountInfo(user.id()));
    // Second removal is ignored.
    fakeClock.advance(Duration.ofSeconds(42));
    change(r).attention(user.id().toString()).remove(new AttentionSetInput("removed again"));
    assertThat(r.getChange().attentionSet()).containsExactly(expectedAttentionSetUpdate);
    // Only one email since the second remove was ignored.
    String emailBody = Iterables.getOnlyElement(sender.getMessages()).body();
    assertThat(emailBody).contains(user.fullName() + " removed themselves from the attention set of this change.\n" + " The reason is: removed.");
}
Also used : AttentionSetInput(com.google.gerrit.extensions.api.changes.AttentionSetInput) AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AttentionSetInfo(com.google.gerrit.extensions.common.AttentionSetInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 54 with AttentionSetUpdate

use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.

the class AttentionSetIT method reviewersAddedAndRemovedFromAttentionSet.

@Test
public void reviewersAddedAndRemovedFromAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    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.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
    change(r).reviewer(user.email()).remove();
    attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer/Cc was removed");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 55 with AttentionSetUpdate

use of com.google.gerrit.entities.AttentionSetUpdate in project gerrit by GerritCodeReview.

the class AttentionSetIT method reviewersAddedAndRemovedByEmailFromAttentionSet.

@Test
public void reviewersAddedAndRemovedByEmailFromAttentionSet() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).addReviewer(user.email());
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
    change(r).reviewer(user.email()).remove();
    attentionSet = Iterables.getOnlyElement(r.getChange().attentionSet());
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.REMOVE);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer/Cc was removed");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AttentionSetUpdate (com.google.gerrit.entities.AttentionSetUpdate)65 Test (org.junit.Test)61 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)52 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)51 AttentionSetInput (com.google.gerrit.extensions.api.changes.AttentionSetInput)21 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)21 Change (com.google.gerrit.entities.Change)12 TestAccount (com.google.gerrit.acceptance.TestAccount)9 Account (com.google.gerrit.entities.Account)4 ImmutableList (com.google.common.collect.ImmutableList)3 Operation (com.google.gerrit.entities.AttentionSetUpdate.Operation)3 DeleteReviewerInput (com.google.gerrit.extensions.api.changes.DeleteReviewerInput)3 ReviewerInput (com.google.gerrit.extensions.api.changes.ReviewerInput)3 AttentionSetInfo (com.google.gerrit.extensions.common.AttentionSetInfo)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 Result (com.google.gerrit.acceptance.PushOneCommit.Result)2 LabelId (com.google.gerrit.entities.LabelId)2 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)2 SubmitRecord (com.google.gerrit.entities.SubmitRecord)2 Inject (com.google.inject.Inject)2