Search in sources :

Example 6 with RelatedChangeAndCommitInfo

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

the class GetRelatedIT method stateOfRelatedChangesMatchesDocumentedValues.

@Test
public void stateOfRelatedChangesMatchesDocumentedValues() throws Exception {
    // Set up three related changes, one new, the other abandoned, and the third merged.
    RevCommit commit1 = commitBuilder().add("a.txt", "File content 1").message("Subject 1").create();
    RevCommit commit2 = commitBuilder().add("b.txt", "File content 2").message("Subject 2").create();
    RevCommit commit3 = commitBuilder().add("c.txt", "File content 3").message("Subject 3").create();
    pushHead(testRepo, "refs/for/master", false);
    Change change1 = getChange(commit1).change();
    Change change2 = getChange(commit2).change();
    Change change3 = getChange(commit3).change();
    gApi.changes().id(change1.getChangeId()).current().review(ReviewInput.approve());
    gApi.changes().id(change1.getChangeId()).current().submit();
    gApi.changes().id(change2.getChangeId()).abandon();
    List<RelatedChangeAndCommitInfo> relatedChanges = gApi.changes().id(change3.getChangeId()).current().related().changes;
    // Ensure that our REST API returns the states exactly as documented (and required by the
    // frontend).
    assertThat(relatedChanges).comparingElementsUsing(getRelatedChangeToStatusCorrespondence()).containsExactly("NEW", "ABANDONED", "MERGED");
}
Also used : RelatedChangeAndCommitInfo(com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo) Change(com.google.gerrit.entities.Change) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 7 with RelatedChangeAndCommitInfo

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

the class GetRelatedIT method changeAndCommit.

private RelatedChangeAndCommitInfo changeAndCommit(PatchSet.Id psId, ObjectId commitId, int currentRevisionNum) {
    RelatedChangeAndCommitInfo result = new RelatedChangeAndCommitInfo();
    result.project = project.get();
    result._changeNumber = psId.changeId().get();
    result.commit = new CommitInfo();
    result.commit.commit = commitId.name();
    result._revisionNumber = psId.get();
    result._currentRevisionNumber = currentRevisionNum;
    result.status = "NEW";
    return result;
}
Also used : RelatedChangeAndCommitInfo(com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) RelatedChangeAndCommitInfo(com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo)

Aggregations

RelatedChangeAndCommitInfo (com.google.gerrit.extensions.api.changes.RelatedChangeAndCommitInfo)7 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)3 PatchSet (com.google.gerrit.entities.PatchSet)3 Test (org.junit.Test)3 Change (com.google.gerrit.entities.Change)2 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)2 ArrayList (java.util.ArrayList)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 Account (com.google.gerrit.entities.Account)1 AccountGroup (com.google.gerrit.entities.AccountGroup)1 RebaseInput (com.google.gerrit.extensions.api.changes.RebaseInput)1 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)1 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)1 RelatedChangesSorter (com.google.gerrit.server.change.RelatedChangesSorter)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1