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

Commit 768f607

Browse filesBrowse files
committed
Add Output and more tests
1 parent ce7cfc0 commit 768f607
Copy full SHA for 768f607

File tree

Expand file treeCollapse file tree

4 files changed

+85
-36
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+85
-36
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCheckSuite.java
+66-2Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.io.IOException;
66
import java.net.URL;
7+
import java.util.Date;
78

89
/**
910
* Represents a check suite.
@@ -25,7 +26,7 @@ public class GHCheckSuite extends GHObject {
2526
private String after;
2627
private int latestCheckRunsCount;
2728
private URL checkRunsUrl;
28-
private GHCommit.ShortInfo headCommit;
29+
private HeadCommit headCommit;
2930
private GHApp app;
3031
private GHPullRequest[] pullRequests;
3132

@@ -136,7 +137,7 @@ public URL getCheckRunsUrl() {
136137
*
137138
* @return head commit
138139
*/
139-
public GHCommit.ShortInfo getHeadCommit() {
140+
public HeadCommit getHeadCommit() {
140141
return headCommit;
141142
}
142143

@@ -172,4 +173,67 @@ GHPullRequest[] getPullRequests() throws IOException {
172173
public URL getHtmlUrl() {
173174
return null;
174175
}
176+
177+
public static class HeadCommit {
178+
private String id;
179+
private String treeId;
180+
private String message;
181+
private String timestamp;
182+
private GitUser author;
183+
private GitUser committer;
184+
185+
/**
186+
* Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
187+
*
188+
* @return id of the commit
189+
*/
190+
public String getId() {
191+
return id;
192+
}
193+
194+
/**
195+
* Gets id of the tree.
196+
*
197+
* @return id of the tree
198+
*/
199+
public String getTreeId() {
200+
return treeId;
201+
}
202+
203+
/**
204+
* Gets message.
205+
*
206+
* @return commit message.
207+
*/
208+
public String getMessage() {
209+
return message;
210+
}
211+
212+
/**
213+
* Gets timestamp of the commit.
214+
*
215+
* @return timestamp of the commit
216+
*/
217+
public Date getTimestamp() {
218+
return GitHubClient.parseDate(timestamp);
219+
}
220+
221+
/**
222+
* Gets author.
223+
*
224+
* @return the author
225+
*/
226+
public GitUser getAuthor() {
227+
return author;
228+
}
229+
230+
/**
231+
* Gets committer.
232+
*
233+
* @return the committer
234+
*/
235+
public GitUser getCommitter() {
236+
return committer;
237+
}
238+
}
175239
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommit.java
+5-32Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
import java.io.IOException;
77
import java.net.URL;
8-
import java.util.*;
8+
import java.util.AbstractList;
9+
import java.util.ArrayList;
10+
import java.util.Collections;
11+
import java.util.Date;
12+
import java.util.List;
913

1014
/**
1115
* A commit in a repository.
@@ -34,43 +38,12 @@ public static class ShortInfo {
3438

3539
private int comment_count;
3640

37-
private String id;
38-
private String timestamp;
39-
private String treeId;
40-
4141
static class Tree {
4242
String sha;
4343
}
4444

4545
private Tree tree;
4646

47-
/**
48-
* Gets id of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
49-
*
50-
* @return id of the commit
51-
*/
52-
public String getId() {
53-
return id;
54-
}
55-
56-
/**
57-
* Gets timestamp of the commit, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
58-
*
59-
* @return timestamp of the commit
60-
*/
61-
public Date getTimestamp() {
62-
return GitHubClient.parseDate(timestamp);
63-
}
64-
65-
/**
66-
* Gets id of the tree, used by {@link GHCheckSuite} when a {@link GHEvent#CHECK_SUITE} comes
67-
*
68-
* @return id of the tree
69-
*/
70-
public String getTreeId() {
71-
return treeId;
72-
}
73-
7447
/**
7548
* Gets author.
7649
*

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHEventPayload.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public GHRequestedAction getRequestedAction() {
132132
* @return the repository
133133
*/
134134
public GHRepository getRepository() {
135+
repository.root = root;
135136
return repository;
136137
}
137138

@@ -187,6 +188,7 @@ public GHCheckSuite getCheckSuite() {
187188
* @return the repository
188189
*/
189190
public GHRepository getRepository() {
191+
repository.root = root;
190192
return repository;
191193
}
192194
}

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHEventPayloadTest.java
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ public void checkRunEvent() throws Exception {
322322
GHEventPayload.CheckRun event = GitHub.offline()
323323
.parseEventPayload(payload.asReader(), GHEventPayload.CheckRun.class);
324324
assertThat(event.getRepository().getName(), is("Hello-World"));
325+
assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat"));
325326
assertThat(event.getAction(), is("created"));
326327

327328
// Checks the deserialization of check_run
@@ -338,15 +339,18 @@ public void checkRunEvent() throws Exception {
338339
assertThat(formatter.format(checkRun.getCompletedAt()), is("2019-05-15T20:22:22Z"));
339340

340341
assertThat(checkRun.getConclusion(), is("success"));
341-
assertThat(checkRun.getUrl().toString(),
342-
is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228"));
343342
assertThat(checkRun.getUrl().toString(),
344343
is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228"));
345344
assertThat(checkRun.getHtmlUrl().toString(), is("https://github.com/Codertocat/Hello-World/runs/128620228"));
346345
assertThat(checkRun.getDetailsUrl().toString(), is("https://octocoders.io"));
347346
assertThat(checkRun.getApp().getId(), is(29310L));
348347
assertThat(checkRun.getCheckSuite().getId(), is(118578147L));
349348
assertThat(checkRun.getOutput().getTitle(), is("check-run output"));
349+
assertThat(checkRun.getOutput().getSummary(), nullValue());
350+
assertThat(checkRun.getOutput().getText(), nullValue());
351+
assertThat(checkRun.getOutput().getAnnotationsCount(), is(0));
352+
assertThat(checkRun.getOutput().getAnnotationsUrl().toString(),
353+
is("https://api.github.com/repos/Codertocat/Hello-World/check-runs/128620228/annotations"));
350354

351355
// Checks the deserialization of sender
352356
assertThat(event.getSender().getId(), is(21031067L));
@@ -359,6 +363,7 @@ public void checkSuiteEvent() throws Exception {
359363
.parseEventPayload(payload.asReader(), GHEventPayload.CheckSuite.class);
360364

361365
assertThat(event.getRepository().getName(), is("Hello-World"));
366+
assertThat(event.getRepository().getOwner().getLogin(), is("Codertocat"));
362367
assertThat(event.getAction(), is("completed"));
363368
assertThat(event.getSender().getId(), is(21031067L));
364369

@@ -379,6 +384,11 @@ public void checkSuiteEvent() throws Exception {
379384
assertThat(checkSuite.getHeadCommit().getTreeId(), is("31b122c26a97cf9af023e9ddab94a82c6e77b0ea"));
380385
assertThat(checkSuite.getHeadCommit().getAuthor().getName(), is("Codertocat"));
381386
assertThat(checkSuite.getHeadCommit().getCommitter().getName(), is("Codertocat"));
387+
388+
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
389+
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
390+
assertThat(formatter.format(checkSuite.getHeadCommit().getTimestamp()), is("2019-05-15T15:20:30Z"));
391+
382392
assertThat(checkSuite.getApp().getId(), is(29310L));
383393
}
384394

0 commit comments

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