From c6d1d6ea0407669434b54005b83c5c9b7a60bda3 Mon Sep 17 00:00:00 2001 From: Vootele Rotov Date: Mon, 2 Jun 2025 18:53:06 +0300 Subject: [PATCH] fix: allow Review id to be bigger than Integer.MAX --- .../com/spotify/github/v3/prs/Review.java | 2 +- .../com/spotify/github/v3/prs/ReviewTest.java | 16 +++++++- .../spotify/github/v3/prs/review_long_id.json | 38 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/com/spotify/github/v3/prs/review_long_id.json diff --git a/src/main/java/com/spotify/github/v3/prs/Review.java b/src/main/java/com/spotify/github/v3/prs/Review.java index e2ec2361..ba66c29b 100644 --- a/src/main/java/com/spotify/github/v3/prs/Review.java +++ b/src/main/java/com/spotify/github/v3/prs/Review.java @@ -44,7 +44,7 @@ public interface Review { /** Id. */ @Nullable - Integer id(); + Long id(); /** User. */ @Nullable diff --git a/src/test/java/com/spotify/github/v3/prs/ReviewTest.java b/src/test/java/com/spotify/github/v3/prs/ReviewTest.java index db54fc29..cefe2a3a 100644 --- a/src/test/java/com/spotify/github/v3/prs/ReviewTest.java +++ b/src/test/java/com/spotify/github/v3/prs/ReviewTest.java @@ -41,6 +41,20 @@ public void testDeserialization() throws IOException { Json.create().fromJson(fixture, Review.class); assertThat(review.state(), is(ReviewState.APPROVED)); assertThat(review.commitId(), is("ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091")); - assertThat(review.id(), is(80)); + assertThat(review.id(), is(80L)); } + + @Test + public void testDeserializationWithLargeId() throws IOException { + String fixture = + Resources.toString( + getResource(this.getClass(), "review_long_id.json"), + defaultCharset()); + final Review review = + Json.create().fromJson(fixture, Review.class); + assertThat(review.state(), is(ReviewState.APPROVED)); + assertThat(review.commitId(), is("ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091")); + assertThat(review.id(), is(2459198580L)); + } + } \ No newline at end of file diff --git a/src/test/resources/com/spotify/github/v3/prs/review_long_id.json b/src/test/resources/com/spotify/github/v3/prs/review_long_id.json new file mode 100644 index 00000000..4dcca923 --- /dev/null +++ b/src/test/resources/com/spotify/github/v3/prs/review_long_id.json @@ -0,0 +1,38 @@ +{ + "id": 2459198580, + "node_id": "MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=", + "user": { + "login": "octocat", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "Here is the body for the review.", + "submitted_at": "2019-11-17T17:43:43Z", + "commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091", + "state": "APPROVED", + "html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80", + "pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12", + "_links": { + "html": { + "href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80" + }, + "pull_request": { + "href": "https://api.github.com/repos/octocat/Hello-World/pulls/12" + } + } +} \ No newline at end of file