Search in sources :

Example 1 with ReviewerUpdateInfo

use of com.google.gerrit.extensions.common.ReviewerUpdateInfo in project gerrit by GerritCodeReview.

the class ChangeJson method reviewerUpdates.

private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws OrmException {
    List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
    List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
    for (ReviewerStatusUpdate c : reviewerUpdates) {
        ReviewerUpdateInfo change = new ReviewerUpdateInfo();
        change.updated = c.date();
        change.state = c.state().asReviewerState();
        change.updatedBy = accountLoader.get(c.updatedBy());
        change.reviewer = accountLoader.get(c.reviewer());
        result.add(change);
    }
    return result;
}
Also used : ReviewerUpdateInfo(com.google.gerrit.extensions.common.ReviewerUpdateInfo) ReviewerStatusUpdate(com.google.gerrit.server.ReviewerStatusUpdate) ArrayList(java.util.ArrayList)

Example 2 with ReviewerUpdateInfo

use of com.google.gerrit.extensions.common.ReviewerUpdateInfo in project gerrit by GerritCodeReview.

the class ChangeReviewersIT method noteDbAddReviewerToReviewerChangeInfo.

@Test
public void noteDbAddReviewerToReviewerChangeInfo() throws Exception {
    assume().that(notesMigration.readChanges()).isTrue();
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = user.email;
    in.state = CC;
    addReviewer(changeId, in);
    in.state = REVIEWER;
    addReviewer(changeId, in);
    gApi.changes().id(changeId).current().review(ReviewInput.dislike());
    setApiUser(user);
    // NoteDb adds reviewer to a change on every review.
    gApi.changes().id(changeId).current().review(ReviewInput.dislike());
    deleteReviewer(changeId, user).assertNoContent();
    ChangeInfo c = gApi.changes().id(changeId).get();
    assertThat(c.reviewerUpdates).isNotNull();
    assertThat(c.reviewerUpdates).hasSize(3);
    Iterator<ReviewerUpdateInfo> it = c.reviewerUpdates.iterator();
    ReviewerUpdateInfo reviewerChange = it.next();
    assertThat(reviewerChange.state).isEqualTo(CC);
    assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.getId().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.getId().get());
    reviewerChange = it.next();
    assertThat(reviewerChange.state).isEqualTo(REVIEWER);
    assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.getId().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.getId().get());
    reviewerChange = it.next();
    assertThat(reviewerChange.state).isEqualTo(REMOVED);
    assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.getId().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.getId().get());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewerUpdateInfo(com.google.gerrit.extensions.common.ReviewerUpdateInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ReviewerUpdateInfo (com.google.gerrit.extensions.common.ReviewerUpdateInfo)2 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 ReviewerStatusUpdate (com.google.gerrit.server.ReviewerStatusUpdate)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1