From 8c17971e50f885b18bcb276ea81b38ced76b9a24 Mon Sep 17 00:00:00 2001 From: Jonatan Dahl Date: Fri, 30 May 2025 18:27:17 -0400 Subject: [PATCH 1/2] parse nodeId to PullRequestItem --- .../github/v3/prs/PullRequestItem.java | 12 +++-- .../PullRequestReviewCommentEventTest.java | 47 +++++++++++++++++++ .../pull_request_review_comment_event.json | 1 + 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java diff --git a/src/main/java/com/spotify/github/v3/prs/PullRequestItem.java b/src/main/java/com/spotify/github/v3/prs/PullRequestItem.java index 469b8c87..f334919f 100644 --- a/src/main/java/com/spotify/github/v3/prs/PullRequestItem.java +++ b/src/main/java/com/spotify/github/v3/prs/PullRequestItem.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -122,6 +122,12 @@ public interface PullRequestItem extends PartialPullRequestItem { @JsonProperty("requested_teams") List requestedTeams(); - /** @Deprecated the merge commit sha. */ + /** + * @Deprecated the merge commit sha. + */ Optional mergeCommitSha(); + + /** Node ID. */ + @Nullable + String nodeId(); } diff --git a/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java b/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java new file mode 100644 index 00000000..2ddd0885 --- /dev/null +++ b/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java @@ -0,0 +1,47 @@ +/*- + * -\-\- + * github-client + * -- + * Copyright (C) 2016 - 2020 Spotify AB + * -- + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -/-/- + */ + +package com.spotify.github.v3.activity.events; + +import static com.google.common.io.Resources.getResource; +import static java.nio.charset.Charset.defaultCharset; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import com.google.common.io.Resources; +import com.spotify.github.jackson.Json; +import java.io.IOException; +import org.junit.jupiter.api.Test; + +public class PullRequestReviewCommentEventTest { + @Test + public void testDeserialization() throws IOException { + String fixture = + Resources.toString( + getResource(this.getClass(), "fixtures/pull_request_review_comment_event.json"), + defaultCharset()); + final PullRequestReviewCommentEvent event = + Json.create().fromJson(fixture, PullRequestReviewCommentEvent.class); + assertThat(event.action(), is("created")); + assertThat(event.comment().id(), is(29724692L)); + assertThat(event.pullRequest().nodeId(), is("abc123")); + assertThat(event.comment().body(), is("Maybe you should use more emojji on this line.")); + } +} diff --git a/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json b/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json index a89b6b54..88cf407d 100644 --- a/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json +++ b/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json @@ -48,6 +48,7 @@ "pull_request": { "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", "id": 34778301, + "node_id": "abc123", "html_url": "https://github.com/baxterthehacker/public-repo/pull/1", "diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff", "patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch", From f43625ebcda77520607505ed32764b9119191e76 Mon Sep 17 00:00:00 2001 From: Jonatan Dahl Date: Fri, 30 May 2025 19:56:51 -0400 Subject: [PATCH 2/2] add nodeId to prs.comment as well --- src/main/java/com/spotify/github/v3/prs/Comment.java | 8 ++++++-- .../events/PullRequestReviewCommentEventTest.java | 8 +++++--- .../fixtures/pull_request_review_comment_event.json | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/spotify/github/v3/prs/Comment.java b/src/main/java/com/spotify/github/v3/prs/Comment.java index 0c890408..02a2819c 100644 --- a/src/main/java/com/spotify/github/v3/prs/Comment.java +++ b/src/main/java/com/spotify/github/v3/prs/Comment.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -94,4 +94,8 @@ public interface Comment extends UpdateTracking { @Nullable @JsonProperty("_links") CommentLinks links(); + + /** Node ID */ + @Nullable + String nodeId(); } diff --git a/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java b/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java index 2ddd0885..79d8feb5 100644 --- a/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java +++ b/src/test/java/com/spotify/github/v3/activity/events/PullRequestReviewCommentEventTest.java @@ -20,15 +20,16 @@ package com.spotify.github.v3.activity.events; -import static com.google.common.io.Resources.getResource; +import java.io.IOException; import static java.nio.charset.Charset.defaultCharset; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; +import org.junit.jupiter.api.Test; import com.google.common.io.Resources; +import static com.google.common.io.Resources.getResource; import com.spotify.github.jackson.Json; -import java.io.IOException; -import org.junit.jupiter.api.Test; public class PullRequestReviewCommentEventTest { @Test @@ -41,6 +42,7 @@ public void testDeserialization() throws IOException { Json.create().fromJson(fixture, PullRequestReviewCommentEvent.class); assertThat(event.action(), is("created")); assertThat(event.comment().id(), is(29724692L)); + assertThat(event.comment().nodeId(), is("abc234")); assertThat(event.pullRequest().nodeId(), is("abc123")); assertThat(event.comment().body(), is("Maybe you should use more emojji on this line.")); } diff --git a/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json b/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json index 88cf407d..631e771d 100644 --- a/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json +++ b/src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json @@ -3,6 +3,7 @@ "comment": { "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692", "id": 29724692, + "node_id": "abc234", "diff_hunk": "@@ -1 +1 @@\n-# public-repo", "path": "README.md", "position": 1,