Search in sources :

Example 61 with AttentionSetUpdate

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

the class OpenRepoTest method addToAttentionSet.

private void addToAttentionSet(ChangeUpdate update) {
    AttentionSetUpdate attentionSetUpdate = AttentionSetUpdate.createForWrite(otherUser.getAccountId(), AttentionSetUpdate.Operation.ADD, "test");
    update.addToPlannedAttentionSetUpdates(ImmutableSet.of(attentionSetUpdate));
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate)

Example 62 with AttentionSetUpdate

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

the class AttentionSetIT method addUsersAsReviewerAndAttentionSetInPrivateChanges.

@Test
public void addUsersAsReviewerAndAttentionSetInPrivateChanges() throws Exception {
    PushOneCommit.Result r = createChange();
    change(r).setPrivate(true);
    change(r).current().review(new ReviewInput().reviewer(user.email()));
    AttentionSetUpdate attentionSet = Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, user));
    assertThat(attentionSet).hasAccountIdThat().isEqualTo(user.id());
    assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD);
    assertThat(attentionSet).hasReasonThat().isEqualTo("Reviewer was added");
}
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 63 with AttentionSetUpdate

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

the class ChangeNotesTest method DoesNotFilterLatestAttentionSetUpdates.

@Test
public void DoesNotFilterLatestAttentionSetUpdates() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    AttentionSetUpdate firstAttentionSetUpdate = AttentionSetUpdate.createForWrite(changeOwner.getAccountId(), Operation.ADD, "test");
    update.addToPlannedAttentionSetUpdates(ImmutableSet.of(firstAttentionSetUpdate));
    update.commit();
    update = newUpdate(c, changeOwner);
    firstAttentionSetUpdate = addTimestamp(firstAttentionSetUpdate, c);
    AttentionSetUpdate secondAttentionSetUpdate = AttentionSetUpdate.createForWrite(changeOwner.getAccountId(), Operation.REMOVE, "test");
    update.addToPlannedAttentionSetUpdates(ImmutableSet.of(secondAttentionSetUpdate));
    update.commit();
    secondAttentionSetUpdate = addTimestamp(secondAttentionSetUpdate, c);
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getAttentionSetUpdates()).containsExactly(secondAttentionSetUpdate, firstAttentionSetUpdate);
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 64 with AttentionSetUpdate

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

the class ChangeNotesTest method addAttentionStatusForMultipleUsers.

@Test
public void addAttentionStatusForMultipleUsers() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    // put the user as cc to ensure that the user took part in this change.
    update.putReviewer(otherUser.getAccount().id(), CC);
    AttentionSetUpdate attentionSetUpdate0 = AttentionSetUpdate.createForWrite(changeOwner.getAccountId(), Operation.ADD, "test");
    AttentionSetUpdate attentionSetUpdate1 = AttentionSetUpdate.createForWrite(otherUser.getAccountId(), Operation.ADD, "test");
    update.addToPlannedAttentionSetUpdates(ImmutableSet.of(attentionSetUpdate0, attentionSetUpdate1));
    update.commit();
    ChangeNotes notes = newNotes(c);
    assertThat(notes.getAttentionSet()).containsExactly(addTimestamp(attentionSetUpdate0, c), addTimestamp(attentionSetUpdate1, c));
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) Change(com.google.gerrit.entities.Change) Test(org.junit.Test)

Example 65 with AttentionSetUpdate

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

the class ChangeNotesTest method addAttentionStatus_rejectIfSameUserTwice.

@Test
public void addAttentionStatus_rejectIfSameUserTwice() throws Exception {
    Change c = newChange();
    ChangeUpdate update = newUpdate(c, changeOwner);
    AttentionSetUpdate attentionSetUpdate0 = AttentionSetUpdate.createForWrite(changeOwner.getAccountId(), Operation.ADD, "test 0");
    AttentionSetUpdate attentionSetUpdate1 = AttentionSetUpdate.createForWrite(changeOwner.getAccountId(), Operation.ADD, "test 1");
    IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> update.addToPlannedAttentionSetUpdates(ImmutableSet.of(attentionSetUpdate0, attentionSetUpdate1)));
    assertThat(thrown).hasMessageThat().contains("must not specify multiple updates for single user");
}
Also used : AttentionSetUpdate(com.google.gerrit.entities.AttentionSetUpdate) Change(com.google.gerrit.entities.Change) 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