Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 3, 2021. It is now read-only.

Commit f2bb6a0

Browse filesBrowse files
committed
Merge pull request hub4j#384
2 parents f41da19 + 0f81d1d commit f2bb6a0
Copy full SHA for f2bb6a0

File tree

Expand file treeCollapse file tree

2 files changed

+143
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+143
-6
lines changed

‎src/main/java/org/kohsuke/github/GHEventPayload.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHEventPayload.java
+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,95 @@ void wrapUp(GitHub root) {
8585
}
8686
}
8787

88+
89+
/**
90+
* A review was added to a pull request
91+
*
92+
* @see <a href="https://developer.github.com/v3/activity/events/types/#pullrequestreviewevent">authoritative source</a>
93+
*/
94+
public static class PullRequestReview extends GHEventPayload {
95+
private String action;
96+
private GHPullRequestReview review;
97+
private GHPullRequest pull_request;
98+
private GHRepository repository;
99+
100+
public String getAction() {
101+
return action;
102+
}
103+
104+
public GHPullRequestReview getReview() {
105+
return review;
106+
}
107+
108+
public GHPullRequest getPullRequest() {
109+
return pull_request;
110+
}
111+
112+
public GHRepository getRepository() {
113+
return repository;
114+
}
115+
116+
@Override
117+
void wrapUp(GitHub root) {
118+
super.wrapUp(root);
119+
if (review==null)
120+
throw new IllegalStateException("Expected pull_request_review payload, but got something else. Maybe we've got another type of event?");
121+
122+
review.wrapUp(pull_request);
123+
124+
if (repository!=null) {
125+
repository.wrap(root);
126+
pull_request.wrapUp(repository);
127+
} else {
128+
pull_request.wrapUp(root);
129+
}
130+
}
131+
}
132+
133+
/**
134+
* A review comment was added to a pull request
135+
*
136+
* @see <a href="https://developer.github.com/v3/activity/events/types/#pullrequestreviewcommentevent">authoritative source</a>
137+
*/
138+
public static class PullRequestReviewComment extends GHEventPayload {
139+
private String action;
140+
private GHPullRequestReviewComment comment;
141+
private GHPullRequest pull_request;
142+
private GHRepository repository;
143+
144+
public String getAction() {
145+
return action;
146+
}
147+
148+
public GHPullRequestReviewComment getComment() {
149+
return comment;
150+
}
151+
152+
public GHPullRequest getPullRequest() {
153+
return pull_request;
154+
}
155+
156+
public GHRepository getRepository() {
157+
return repository;
158+
}
159+
160+
@Override
161+
void wrapUp(GitHub root) {
162+
super.wrapUp(root);
163+
if (comment==null)
164+
throw new IllegalStateException("Expected pull_request_review_comment payload, but got something else. Maybe we've got another type of event?");
165+
166+
comment.wrapUp(pull_request);
167+
168+
if (repository!=null) {
169+
repository.wrap(root);
170+
pull_request.wrapUp(repository);
171+
} else {
172+
pull_request.wrapUp(root);
173+
}
174+
}
175+
}
176+
88177
/**
89178
* A comment was added to an issue
90179
*

‎src/test/java/org/kohsuke/github/GHEventPayloadTest.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHEventPayloadTest.java
+54-6Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,61 @@ public void pull_request() throws Exception {
187187
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
188188
}
189189

190-
// TODO implement support classes and write test
191-
// @Test
192-
// public void pull_request_review() throws Exception {}
190+
@Test
191+
public void pull_request_review() throws Exception {
192+
GHEventPayload.PullRequestReview event =
193+
GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReview.class);
194+
assertThat(event.getAction(), is("submitted"));
195+
196+
assertThat(event.getReview().getId(), is(2626884));
197+
assertThat(event.getReview().getBody(), is("Looks great!"));
198+
assertThat(event.getReview().getState(), is(GHPullRequestReviewState.APPROVED));
199+
200+
assertThat(event.getPullRequest().getNumber(), is(8));
201+
assertThat(event.getPullRequest().getTitle(), is("Add a README description"));
202+
assertThat(event.getPullRequest().getBody(), is("Just a few more details"));
203+
assertThat(event.getPullRequest().getUser().getLogin(), is("skalnik"));
204+
assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("skalnik"));
205+
assertThat(event.getPullRequest().getHead().getRef(), is("patch-2"));
206+
assertThat(event.getPullRequest().getHead().getLabel(), is("skalnik:patch-2"));
207+
assertThat(event.getPullRequest().getHead().getSha(), is("b7a1f9c27caa4e03c14a88feb56e2d4f7500aa63"));
208+
assertThat(event.getPullRequest().getBase().getUser().getLogin(), is("baxterthehacker"));
209+
assertThat(event.getPullRequest().getBase().getRef(), is("master"));
210+
assertThat(event.getPullRequest().getBase().getLabel(), is("baxterthehacker:master"));
211+
assertThat(event.getPullRequest().getBase().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
212+
213+
assertThat(event.getRepository().getName(), is("public-repo"));
214+
assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker"));
215+
216+
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
217+
}
193218

194-
// TODO implement support classes and write test
195-
// @Test
196-
// public void pull_request_review_comment() throws Exception {}
219+
@Test
220+
public void pull_request_review_comment() throws Exception {
221+
GHEventPayload.PullRequestReviewComment event =
222+
GitHub.offline().parseEventPayload(payload.asReader(), GHEventPayload.PullRequestReviewComment.class);
223+
assertThat(event.getAction(), is("created"));
224+
225+
assertThat(event.getComment().getBody(), is("Maybe you should use more emojji on this line."));
226+
227+
assertThat(event.getPullRequest().getNumber(), is(1));
228+
assertThat(event.getPullRequest().getTitle(), is("Update the README with new information"));
229+
assertThat(event.getPullRequest().getBody(), is("This is a pretty simple change that we need to pull into master."));
230+
assertThat(event.getPullRequest().getUser().getLogin(), is("baxterthehacker"));
231+
assertThat(event.getPullRequest().getHead().getUser().getLogin(), is("baxterthehacker"));
232+
assertThat(event.getPullRequest().getHead().getRef(), is("changes"));
233+
assertThat(event.getPullRequest().getHead().getLabel(), is("baxterthehacker:changes"));
234+
assertThat(event.getPullRequest().getHead().getSha(), is("0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c"));
235+
assertThat(event.getPullRequest().getBase().getUser().getLogin(), is("baxterthehacker"));
236+
assertThat(event.getPullRequest().getBase().getRef(), is("master"));
237+
assertThat(event.getPullRequest().getBase().getLabel(), is("baxterthehacker:master"));
238+
assertThat(event.getPullRequest().getBase().getSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
239+
240+
assertThat(event.getRepository().getName(), is("public-repo"));
241+
assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker"));
242+
243+
assertThat(event.getSender().getLogin(), is("baxterthehacker"));
244+
}
197245

198246
@Test
199247
public void push() throws Exception {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.