Skip to content

Extended comments API to also fetch orphaned/outdated pull request co… #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/com/cdancy/bitbucket/rest/features/CommentsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ Comments get(@PathParam("project") String project,
@PathParam("pullRequestId") int pullRequestId,
@PathParam("commentId") int commentId);

@Deprecated
@Named("comments:file-comments-deprecated")
@Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45888278617264"})
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{project}/repos/{repo}/pull-requests/{pullRequestId}/comments")
@Fallback(CommentPageOnError.class)
@GET
CommentPage fileComments(@PathParam("project") String project,
@PathParam("repo") String repo,
@PathParam("pullRequestId") int pullRequestId,
@QueryParam("path") String pathToFile,
@Nullable @QueryParam("start") Integer start,
@Nullable @QueryParam("limit") Integer limit);

@Named("comments:file-comments")
@Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45888278617264"})
@Consumes(MediaType.APPLICATION_JSON)
Expand All @@ -98,6 +112,10 @@ CommentPage fileComments(@PathParam("project") String project,
@PathParam("repo") String repo,
@PathParam("pullRequestId") int pullRequestId,
@QueryParam("path") String pathToFile,
@Nullable @QueryParam("anchorState") String anchorState,
@Nullable @QueryParam("diffType") String diffType,
@Nullable @QueryParam("fromHash") String fromHash,
@Nullable @QueryParam("toHash") String toHash,
@Nullable @QueryParam("start") Integer start,
@Nullable @QueryParam("limit") Integer limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public void testGetFileCommentPage() throws Exception {
final List<Comments> allComments = Lists.newArrayList();
Integer start = null;
while (true) {
final CommentPage comm = api().fileComments(project, repo, prId, this.filePath, start, 100);
final CommentPage comm = api().fileComments(project, repo, prId, this.filePath, null, null, null, null,
start, 100);
assertThat(comm.errors().isEmpty()).isTrue();
allComments.addAll(comm.values());
start = comm.nextPageStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public void testGetPullRequestComments() throws Exception {
server.enqueue(new MockResponse().setBody(payloadFromResource("/pull-request-comments.json")).setResponseCode(200));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {

final CommentPage pcr = baseApi.commentsApi().fileComments("project", "repo", 101, hejKeyword, 0, 100);
final CommentPage pcr = baseApi.commentsApi().fileComments("project", "repo", 101, hejKeyword, null, null,
null, null, 0, 100);
assertThat(pcr).isNotNull();
assertThat(pcr.errors()).isEmpty();
assertThat(pcr.values()).hasSize(2);
Expand Down Expand Up @@ -165,7 +166,8 @@ public void testGetPullRequestCommentsOnError() throws Exception {
server.enqueue(new MockResponse().setBody(payloadFromResource("/commit-error.json")).setResponseCode(404));
try (final BitbucketApi baseApi = api(server.getUrl("/"))) {

final CommentPage pcr = baseApi.commentsApi().fileComments("project", "repo", 101, hejKeyword, 0, 100);
final CommentPage pcr = baseApi.commentsApi().fileComments("project", "repo", 101, hejKeyword, null, null,
null, null, 0, 100);
assertThat(pcr).isNotNull();
assertThat(pcr.errors()).isNotEmpty();

Expand Down