Skip to content

Commit 0cd3828

Browse files
committed
Code coverage
1 parent c0f17e1 commit 0cd3828

12 files changed

+40
-5
lines changed

src/main/java/org/kohsuke/github/GHCommentAuthorAssociation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,9 @@ public enum GHCommentAuthorAssociation {
3838
/**
3939
* Author is the owner of the repository.
4040
*/
41-
OWNER
41+
OWNER,
42+
/**
43+
* Author association is not recognized.
44+
*/
45+
UNKNOWN
4246
}

src/main/java/org/kohsuke/github/GHIssueComment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
package org.kohsuke.github;
2525

2626
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27+
import org.kohsuke.github.internal.EnumUtils;
2728

2829
import java.io.IOException;
2930
import java.net.URL;
@@ -107,7 +108,9 @@ public URL getHtmlUrl() {
107108
* @return the author association
108109
*/
109110
public GHCommentAuthorAssociation getAuthorAssociation() {
110-
return GHCommentAuthorAssociation.valueOf(authorAssociation);
111+
return EnumUtils.getEnumOrDefault(GHCommentAuthorAssociation.class,
112+
authorAssociation,
113+
GHCommentAuthorAssociation.UNKNOWN);
111114
}
112115

113116
/**

src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public Commit() {
121121
String url;
122122

123123
/** The comment count. */
124-
int commentCount;
124+
Integer commentCount;
125125

126126
/**
127127
* Gets author.
@@ -175,7 +175,7 @@ public int getComment_count() {
175175
*
176176
* @return the comment count
177177
*/
178-
public int getCommentCount() {
178+
public Integer getCommentCount() {
179179
return commentCount;
180180
}
181181

src/test/java/org/kohsuke/github/AppTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ public void testIssueSearch() {
14191419
PagedIterable<GHIssueComment> comments = issue.listComments();
14201420
for (GHIssueComment comment : comments) {
14211421
assertThat(comment, notNullValue());
1422+
14221423
}
14231424
}
14241425
}

src/test/java/org/kohsuke/github/EnumTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void touchEnums() {
2727
assertThat(GHCheckRun.Conclusion.values().length, equalTo(9));
2828
assertThat(GHCheckRun.Status.values().length, equalTo(4));
2929

30-
assertThat(GHCommentAuthorAssociation.values().length, equalTo(8));
30+
assertThat(GHCommentAuthorAssociation.values().length, equalTo(9));
3131

3232
assertThat(GHCommitSearchBuilder.Sort.values().length, equalTo(2));
3333

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ public void issue_comment() throws Exception {
195195
assertThat(event.getIssue().getLabels().iterator().next().getName(), is("bug"));
196196
assertThat(event.getComment().getUser().getLogin(), is("baxterthehacker"));
197197
assertThat(event.getComment().getBody(), is("You are totally right! I'll get this fixed right away."));
198+
assertThat(event.getComment().getAuthorAssociation(), equalTo(GHCommentAuthorAssociation.UNKNOWN));
199+
assertThat(event.getComment().getBody(), is("You are totally right! I'll get this fixed right away."));
198200
assertThat(event.getRepository().getName(), is("public-repo"));
199201
assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker"));
200202
assertThat(event.getSender().getLogin(), is("baxterthehacker"));

src/test/java/org/kohsuke/github/GHGistTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,10 @@ public void gistFile() throws Exception {
168168
assertThat(f.getType(), equalTo("text/markdown"));
169169
assertThat(f.getLanguage(), equalTo("Markdown"));
170170
assertThat(f.getContent(), containsString("### Keybase proof"));
171+
assertThat(f.getRawUrl().toString(),
172+
equalTo("https://gist.githubusercontent.com/rtyler/9903708/raw/2b68396d836af8c5b6ba905f27c4baf94ceb0ed3/keybase.md"));
173+
assertThat(f.getFileName(), equalTo("keybase.md"));
174+
assertThat(f.getSize(), equalTo(2131));
175+
assertThat(f.isTruncated(), equalTo(false));
171176
}
172177
}

src/test/java/org/kohsuke/github/GHIssueTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public void issueComment() throws Exception {
9292
comments = issue.listComments().toList();
9393
assertThat(comments, hasSize(1));
9494
assertThat(comments, contains(hasProperty("body", equalTo("First comment"))));
95+
assertThat(comments.get(0).getAuthorAssociation(), equalTo(GHCommentAuthorAssociation.NONE));
9596

9697
comments = issue.queryComments().list().toList();
9798
assertThat(comments, hasSize(1));

src/test/java/org/kohsuke/github/GHProjectTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public void testCreatedProject() {
4747
assertThat(project.getState(), equalTo(GHProject.ProjectState.OPEN));
4848
assertThat(project.getHtmlUrl().toString(), containsString("/orgs/hub4j-test-org/projects/"));
4949
assertThat(project.getUrl().toString(), containsString("/projects/"));
50+
assertThat(project.getOwnerUrl().toString(), endsWith("/orgs/hub4j-test-org"));
51+
5052
}
5153

5254
/**

src/test/java/org/kohsuke/github/GHPullRequestTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public void createDraftPullRequest() throws Exception {
127127
public void pullRequestComment() throws Exception {
128128
String name = "createPullRequestComment";
129129
GHPullRequest p = getRepository().createPullRequest(name, "test/stable", "main", "## test");
130+
assertThat(p.getIssueUrl().toString(), endsWith("/repos/hub4j-test-org/github-api/issues/461"));
130131

131132
List<GHIssueComment> comments;
132133
comments = p.listComments().toList();
@@ -226,9 +227,18 @@ public void getListOfCommits() throws Exception {
226227

227228
GHPullRequestCommitDetail.Commit commit = detail.getCommit();
228229
assertThat(commit, notNullValue());
230+
assertThat(commit.getAuthor().getEmail(), equalTo("bitwiseman@gmail.com"));
231+
assertThat(commit.getCommitter().getEmail(), equalTo("bitwiseman@gmail.com"));
232+
assertThat(commit.getMessage(), equalTo("Update README"));
233+
assertThat(commit.getUrl().toString(),
234+
endsWith("/repos/hub4j-test-org/github-api/git/commits/2d29c787b46ce61b98a1c13e05e21ebc21f49dbf"));
235+
assertThat(commit.getComment_count(), equalTo(0));
229236

230237
GHPullRequestCommitDetail.Tree tree = commit.getTree();
231238
assertThat(tree, notNullValue());
239+
assertThat(tree.getSha(), equalTo("ce7a1ba95aba901cf08d9f8365410d290d6c23aa"));
240+
assertThat(tree.getUrl().toString(),
241+
endsWith("/repos/hub4j-test-org/github-api/git/trees/ce7a1ba95aba901cf08d9f8365410d290d6c23aa"));
232242

233243
GHPullRequestCommitDetail.CommitPointer[] parents = detail.getParents();
234244
assertThat(parents, notNullValue());

src/test/java/org/kohsuke/github/GHRepositoryTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ public void addCollaborators() throws Exception {
643643

644644
GHPersonSet<GHUser> collabs = repo.getCollaborators();
645645
GHUser colabUser = collabs.byLogin("jimmysombrero");
646+
assertThat(colabUser.getAvatarUrl(), equalTo("https://avatars3.githubusercontent.com/u/12157727?v=4"));
647+
assertThat(colabUser.getHtmlUrl().toString(), equalTo("https://github.com/jimmysombrero"));
648+
assertThat(colabUser.getLocation(), nullValue());
646649

647650
assertThat(user.getName(), equalTo(colabUser.getName()));
648651
}

src/test/java/org/kohsuke/github/GitHubTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ public void searchContent() throws Exception {
164164
.order(GHDirection.DESC)
165165
.list();
166166
GHContent c = r.iterator().next();
167+
assertThat(c.getGitUrl(), endsWith("/repositories/167174/git/blobs/796fbcc808ca15bbe771f8c9c1a7bab3388f6128"));
168+
assertThat(c.getHtmlUrl(),
169+
endsWith(
170+
"https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/attributes/classes.js"));
167171

168172
// System.out.println(c.getName());
169173
assertThat(c.getDownloadUrl(), notNullValue());

0 commit comments

Comments
 (0)