Search in sources :

Example 1 with ResolveConflictsWebLink

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

the class RevisionIT method commit.

@Test
public void commit() throws Exception {
    WebLinkInfo expectedPatchSetLinkInfo = new WebLinkInfo("foo", "imageUrl", "url");
    PatchSetWebLink patchSetLink = new PatchSetWebLink() {

        @Override
        public WebLinkInfo getPatchSetWebLink(String projectName, String commit, String commitMessage, String branchName) {
            return expectedPatchSetLinkInfo;
        }
    };
    WebLinkInfo expectedResolveConflictsLinkInfo = new WebLinkInfo("bar", "img", "resolve");
    ResolveConflictsWebLink resolveConflictsLink = new ResolveConflictsWebLink() {

        @Override
        public WebLinkInfo getResolveConflictsWebLink(String projectName, String commit, String commitMessage, String branchName) {
            return expectedResolveConflictsLinkInfo;
        }
    };
    try (Registration registration = extensionRegistry.newRegistration().add(patchSetLink).add(resolveConflictsLink)) {
        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 patchSetLinkInfo = Iterables.getOnlyElement(commitInfo.webLinks);
        assertThat(patchSetLinkInfo.name).isEqualTo(expectedPatchSetLinkInfo.name);
        assertThat(patchSetLinkInfo.imageUrl).isEqualTo(expectedPatchSetLinkInfo.imageUrl);
        assertThat(patchSetLinkInfo.url).isEqualTo(expectedPatchSetLinkInfo.url);
        assertThat(patchSetLinkInfo.target).isEqualTo(expectedPatchSetLinkInfo.target);
        assertThat(commitInfo.resolveConflictsWebLinks).hasSize(1);
        WebLinkInfo resolveCommentsLinkInfo = Iterables.getOnlyElement(commitInfo.resolveConflictsWebLinks);
        assertThat(resolveCommentsLinkInfo.name).isEqualTo(expectedResolveConflictsLinkInfo.name);
        assertThat(resolveCommentsLinkInfo.imageUrl).isEqualTo(expectedResolveConflictsLinkInfo.imageUrl);
        assertThat(resolveCommentsLinkInfo.url).isEqualTo(expectedResolveConflictsLinkInfo.url);
        assertThat(resolveCommentsLinkInfo.target).isEqualTo(expectedResolveConflictsLinkInfo.target);
    }
}
Also used : WebLinkInfo(com.google.gerrit.extensions.common.WebLinkInfo) ResolveConflictsWebLink(com.google.gerrit.extensions.webui.ResolveConflictsWebLink) Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) 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 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)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 ResolveConflictsWebLink (com.google.gerrit.extensions.webui.ResolveConflictsWebLink)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 Test (org.junit.Test)1