Search in sources :

Example 56 with ChangeInfo

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

the class ChangeReviewersIT method addReviewerToReviewerChangeInfo.

@Test
public void addReviewerToReviewerChangeInfo() throws Exception {
    PushOneCommit.Result r = createChange();
    String changeId = r.getChangeId();
    ReviewerInput in = new ReviewerInput();
    in.reviewer = user.email();
    in.state = CC;
    addReviewer(changeId, in);
    in.state = REVIEWER;
    addReviewer(changeId, in);
    gApi.changes().id(changeId).current().review(ReviewInput.dislike());
    requestScopeOperations.setApiUser(user.id());
    // By posting a review the user is added as reviewer.
    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.id().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
    reviewerChange = it.next();
    assertThat(reviewerChange.state).isEqualTo(REVIEWER);
    assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.id().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
    reviewerChange = it.next();
    assertThat(reviewerChange.state).isEqualTo(REMOVED);
    assertThat(reviewerChange.reviewer._accountId).isEqualTo(user.id().get());
    assertThat(reviewerChange.updatedBy._accountId).isEqualTo(admin.id().get());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) ReviewerUpdateInfo(com.google.gerrit.extensions.common.ReviewerUpdateInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 57 with ChangeInfo

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

the class ChangeReviewersIT method moveReviewerToCc.

@Test
public void moveReviewerToCc() throws Exception {
    // Allow everyone to approve changes.
    projectOperations.project(project).forUpdate().add(allowLabel(LabelId.CODE_REVIEW).ref("refs/heads/*").group(REGISTERED_USERS).range(-2, 2)).update();
    // Create a change and add 'user' as reviewer.
    String changeId = createChange().getChangeId();
    gApi.changes().id(changeId).addReviewer(user.id().toString());
    // Verify that 'user' is a reviewer on the change and that there are no CCs.
    ChangeInfo c = gApi.changes().id(changeId).get();
    Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
    assertThat(reviewers).isNotNull();
    assertThat(reviewers).hasSize(1);
    assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.id().get());
    assertThat(c.reviewers.get(CC)).isNull();
    // Let 'user' approve the change and verify that the change has the approval.
    requestScopeOperations.setApiUser(user.id());
    approve(changeId);
    c = gApi.changes().id(changeId).get();
    assertThat(c.labels.get(LabelId.CODE_REVIEW).approved._accountId).isEqualTo(user.id().get());
    // Move 'user' from reviewer to CC.
    requestScopeOperations.setApiUser(admin.id());
    ReviewerInput reviewerInput = new ReviewerInput();
    reviewerInput.reviewer = user.id().toString();
    reviewerInput.state = CC;
    gApi.changes().id(changeId).addReviewer(reviewerInput);
    // Verify that 'user' is a CC on the change now and that there are no reviewers.
    c = gApi.changes().id(changeId).get();
    Collection<AccountInfo> ccs = c.reviewers.get(CC);
    assertThat(ccs).isNotNull();
    assertThat(ccs).hasSize(1);
    assertThat(ccs.iterator().next()._accountId).isEqualTo(user.id().get());
    assertThat(c.reviewers.get(REVIEWER)).isNull();
    // Verify that the approval of 'user' is still there.
    assertThat(c.labels.get(LabelId.CODE_REVIEW).approved._accountId).isEqualTo(user.id().get());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) ReviewerInput(com.google.gerrit.extensions.api.changes.ReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 58 with ChangeInfo

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

the class SubmitByRebaseAlwaysIT method getCurrentCommit.

private RevCommit getCurrentCommit(PushOneCommit.Result change) throws Throwable {
    testRepo.git().fetch().setRemote("origin").call();
    ChangeInfo info = get(change.getChangeId(), CURRENT_REVISION);
    RevCommit c = testRepo.getRevWalk().parseCommit(ObjectId.fromString(info.currentRevision));
    testRepo.getRevWalk().parseBody(c);
    return c;
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 59 with ChangeInfo

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

the class ListChangesOptionsIT method currentRevision.

@Test
public void currentRevision() throws Exception {
    ChangeInfo c = get(changeId, CURRENT_REVISION);
    assertThat(c.currentRevision).isEqualTo(commitId(2));
    assertThat(c.revisions.keySet()).containsAtLeastElementsIn(ImmutableSet.of(commitId(2)));
    assertThat(c.revisions.get(commitId(2))._number).isEqualTo(3);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 60 with ChangeInfo

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

the class CreateChangeIT method createDefaultAuthor.

@Test
public void createDefaultAuthor() throws Exception {
    ChangeInput input = newChangeInput(ChangeStatus.NEW);
    ChangeInfo info = assertCreateSucceeds(input);
    GitPerson person = gApi.changes().id(info.id).current().commit(false).author;
    assertThat(person).email().isEqualTo(admin.email());
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) GitPerson(com.google.gerrit.extensions.common.GitPerson) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)504 Test (org.junit.Test)434 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)393 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)276 Change (com.google.gerrit.entities.Change)73 RevCommit (org.eclipse.jgit.revwalk.RevCommit)67 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)52 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)50 Project (com.google.gerrit.entities.Project)45 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)45 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)36 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)36 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)35 Repository (org.eclipse.jgit.lib.Repository)35 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)32 LabelInfo (com.google.gerrit.extensions.common.LabelInfo)32 TestRepository (org.eclipse.jgit.junit.TestRepository)32 ObjectId (org.eclipse.jgit.lib.ObjectId)30 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)29 List (java.util.List)29