Search in sources :

Example 1 with PatchSetWebLink

use of com.google.gerrit.extensions.webui.PatchSetWebLink in project gerrit by GerritCodeReview.

the class RevisionIT method commit.

@Test
public void commit() throws Exception {
    WebLinkInfo expectedWebLinkInfo = new WebLinkInfo("foo", "imageUrl", "url");
    patchSetLinks.add(new PatchSetWebLink() {

        @Override
        public WebLinkInfo getPatchSetWebLink(String projectName, String commit) {
            return expectedWebLinkInfo;
        }
    });
    PushOneCommit.Result r = createChange();
    RevCommit c = r.getCommit();
    CommitInfo commitInfo = gApi.changes().id(r.getChangeId()).current().commit(false);
    assertThat(commitInfo.commit).isEqualTo(c.name());
    assertPersonIdent(commitInfo.author, c.getAuthorIdent());
    assertPersonIdent(commitInfo.committer, c.getCommitterIdent());
    assertThat(commitInfo.message).isEqualTo(c.getFullMessage());
    assertThat(commitInfo.subject).isEqualTo(c.getShortMessage());
    assertThat(commitInfo.parents).hasSize(1);
    assertThat(Iterables.getOnlyElement(commitInfo.parents).commit).isEqualTo(c.getParent(0).name());
    assertThat(commitInfo.webLinks).isNull();
    commitInfo = gApi.changes().id(r.getChangeId()).current().commit(true);
    assertThat(commitInfo.webLinks).hasSize(1);
    WebLinkInfo webLinkInfo = Iterables.getOnlyElement(commitInfo.webLinks);
    assertThat(webLinkInfo.name).isEqualTo(expectedWebLinkInfo.name);
    assertThat(webLinkInfo.imageUrl).isEqualTo(expectedWebLinkInfo.imageUrl);
    assertThat(webLinkInfo.url).isEqualTo(expectedWebLinkInfo.url);
    assertThat(webLinkInfo.target).isEqualTo(expectedWebLinkInfo.target);
}
Also used : WebLinkInfo(com.google.gerrit.extensions.common.WebLinkInfo) PatchSetWebLink(com.google.gerrit.extensions.webui.PatchSetWebLink) CommitInfo(com.google.gerrit.extensions.common.CommitInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)1 WebLinkInfo (com.google.gerrit.extensions.common.WebLinkInfo)1 PatchSetWebLink (com.google.gerrit.extensions.webui.PatchSetWebLink)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 Test (org.junit.Test)1