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);
}
}
Aggregations