Skip to content

Commit ee3adcd

Browse files
authored
parse nodeId to PullRequestItem (#235)
* parse nodeId to PullRequestItem * add nodeId to prs.comment as well
1 parent 03f6e0f commit ee3adcd

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

src/main/java/com/spotify/github/v3/prs/Comment.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -94,4 +94,8 @@ public interface Comment extends UpdateTracking {
9494
@Nullable
9595
@JsonProperty("_links")
9696
CommentLinks links();
97+
98+
/** Node ID */
99+
@Nullable
100+
String nodeId();
97101
}

src/main/java/com/spotify/github/v3/prs/PullRequestItem.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -122,6 +122,12 @@ public interface PullRequestItem extends PartialPullRequestItem {
122122
@JsonProperty("requested_teams")
123123
List<User> requestedTeams();
124124

125-
/** @Deprecated the merge commit sha. */
125+
/**
126+
* @Deprecated the merge commit sha.
127+
*/
126128
Optional<String> mergeCommitSha();
129+
130+
/** Node ID. */
131+
@Nullable
132+
String nodeId();
127133
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*-
2+
* -\-\-
3+
* github-client
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.activity.events;
22+
23+
import java.io.IOException;
24+
import static java.nio.charset.Charset.defaultCharset;
25+
26+
import static org.hamcrest.MatcherAssert.assertThat;
27+
import static org.hamcrest.core.Is.is;
28+
import org.junit.jupiter.api.Test;
29+
30+
import com.google.common.io.Resources;
31+
import static com.google.common.io.Resources.getResource;
32+
import com.spotify.github.jackson.Json;
33+
34+
public class PullRequestReviewCommentEventTest {
35+
@Test
36+
public void testDeserialization() throws IOException {
37+
String fixture =
38+
Resources.toString(
39+
getResource(this.getClass(), "fixtures/pull_request_review_comment_event.json"),
40+
defaultCharset());
41+
final PullRequestReviewCommentEvent event =
42+
Json.create().fromJson(fixture, PullRequestReviewCommentEvent.class);
43+
assertThat(event.action(), is("created"));
44+
assertThat(event.comment().id(), is(29724692L));
45+
assertThat(event.comment().nodeId(), is("abc234"));
46+
assertThat(event.pullRequest().nodeId(), is("abc123"));
47+
assertThat(event.comment().body(), is("Maybe you should use more emojji on this line."));
48+
}
49+
}

src/test/resources/com/spotify/github/v3/activity/events/fixtures/pull_request_review_comment_event.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"comment": {
44
"url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692",
55
"id": 29724692,
6+
"node_id": "abc234",
67
"diff_hunk": "@@ -1 +1 @@\n-# public-repo",
78
"path": "README.md",
89
"position": 1,
@@ -48,6 +49,7 @@
4849
"pull_request": {
4950
"url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1",
5051
"id": 34778301,
52+
"node_id": "abc123",
5153
"html_url": "https://github.com/baxterthehacker/public-repo/pull/1",
5254
"diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff",
5355
"patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch",

0 commit comments

Comments
 (0)