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 3a76281

Browse filesBrowse files
committed
Additional test coverage
1 parent cfcf81a commit 3a76281
Copy full SHA for 3a76281

File tree

Expand file treeCollapse file tree

62 files changed

+1853
-826
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

62 files changed

+1853
-826
lines changed

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppInstallation.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ private static class GHAppInstallationRepositoryResult extends SearchResult<GHRe
137137

138138
@Override
139139
GHRepository[] getItems(GitHub root) {
140-
for (GHRepository item : repositories) {
141-
}
142140
return repositories;
143141
}
144142
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHArtifact.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ private String getApiRoute() {
129129
}
130130

131131
GHArtifact wrapUp(GHRepository owner) {
132-
this.owner = owner;
133132
this.owner = owner;
134133
return this;
135134
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHContentSearchBuilder.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ private static class ContentSearchResult extends SearchResult<GHContent> {
158158

159159
@Override
160160
GHContent[] getItems(GitHub root) {
161-
for (GHContent item : items) {
162-
}
163161
return items;
164162
}
165163
}

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHHooks.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ private Context(GitHub root) {
2727
*/
2828
public List<GHHook> getHooks() throws IOException {
2929

30-
GHHook[] hookArray = root().createRequest().withUrlPath(collection()).fetch(collectionClass()); // jdk/eclipse
31-
// bug
30+
// jdk/eclipse bug
31+
GHHook[] hookArray = root().createRequest().withUrlPath(collection()).fetch(collectionClass());
3232
// requires this
3333
// to be on separate line
3434
List<GHHook> list = new ArrayList<GHHook>(Arrays.asList(hookArray));

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHIssue.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void lock() throws IOException {
190190
* the io exception
191191
*/
192192
public void unlock() throws IOException {
193-
root().createRequest().method("PUT").withUrlPath(getApiRoute() + "/lock").send();
193+
root().createRequest().method("DELETE").withUrlPath(getApiRoute() + "/lock").send();
194194
}
195195

196196
/**

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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHub.java
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,11 @@ GitHubClient getClient() {
13311331
@Nonnull
13321332
Requester createRequest() {
13331333
Requester requester = new Requester(client);
1334-
// For classes that extend GitHub, treat them still as a GitHub instance
1335-
requester.injectMappingValue(GitHub.class.getName(), this);
1334+
requester.injectMappingValue(this);
1335+
if (!this.getClass().equals(GitHub.class)) {
1336+
// For classes that extend GitHub, treat them still as a GitHub instance
1337+
requester.injectMappingValue(GitHub.class.getName(), this);
1338+
}
13361339
return requester;
13371340
}
13381341

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/AppTest.java
+43-3Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.nio.charset.StandardCharsets;
1818
import java.util.*;
1919
import java.util.Map.Entry;
20+
import java.util.stream.Collectors;
2021

2122
import static org.hamcrest.Matchers.*;
2223

@@ -138,9 +139,13 @@ public void testIssueWithNoComment() throws IOException {
138139
List<GHIssueComment> v = i.getComments();
139140
// System.out.println(v);
140141
assertThat(v, is(empty()));
142+
}
141143

142-
i = repository.getIssue(3);
143-
v = i.getComments();
144+
@Test
145+
public void testIssueWithComment() throws IOException {
146+
GHRepository repository = gitHub.getRepository("kohsuke/test");
147+
GHIssue i = repository.getIssue(3);
148+
List<GHIssueComment> v = i.getComments();
144149
// System.out.println(v);
145150
assertThat(v.size(), equalTo(3));
146151
assertThat(v.get(0).getHtmlUrl().toString(),
@@ -160,10 +165,33 @@ public void testIssueWithNoComment() throws IOException {
160165
assertThat(v.get(1).getUser().getLogin(), equalTo("kohsuke"));
161166
List<GHReaction> reactions = v.get(1).listReactions().toList();
162167
assertThat(reactions.size(), equalTo(3));
168+
assertThat(reactions.stream().map(item -> item.getContent()).collect(Collectors.toList()),
169+
containsInAnyOrder(ReactionContent.EYES, ReactionContent.HOORAY, ReactionContent.ROCKET));
163170

164171
// TODO: Add comment CRUD test
165-
// TODO: Add reactions CRUD test
166172

173+
GHReaction reaction = null;
174+
try {
175+
reaction = v.get(1).createReaction(ReactionContent.CONFUSED);
176+
v = i.getComments();
177+
reactions = v.get(1).listReactions().toList();
178+
assertThat(reactions.stream().map(item -> item.getContent()).collect(Collectors.toList()),
179+
containsInAnyOrder(ReactionContent.CONFUSED,
180+
ReactionContent.EYES,
181+
ReactionContent.HOORAY,
182+
ReactionContent.ROCKET));
183+
184+
reaction.delete();
185+
reaction = null;
186+
v = i.getComments();
187+
reactions = v.get(1).listReactions().toList();
188+
assertThat(reactions.stream().map(item -> item.getContent()).collect(Collectors.toList()),
189+
containsInAnyOrder(ReactionContent.EYES, ReactionContent.HOORAY, ReactionContent.ROCKET));
190+
} finally {
191+
if (reaction != null) {
192+
reaction.delete();
193+
}
194+
}
167195
}
168196

169197
@Test
@@ -179,6 +207,17 @@ public void testCreateIssue() throws IOException {
179207
.milestone(milestone)
180208
.create();
181209
assertThat(o, notNullValue());
210+
assertThat(o.getBody(), equalTo("this is body"));
211+
212+
// test locking
213+
assertThat(o.isLocked(), is(false));
214+
o.lock();
215+
o = repository.getIssue(o.getNumber());
216+
assertThat(o.isLocked(), is(true));
217+
o.unlock();
218+
o = repository.getIssue(o.getNumber());
219+
assertThat(o.isLocked(), is(false));
220+
182221
o.close();
183222
}
184223

@@ -771,6 +810,7 @@ public void testCommitStatus() throws Exception {
771810
// System.out.println(state);
772811
assertThat(state.getDescription(), equalTo("testing!"));
773812
assertThat(state.getTargetUrl(), equalTo("http://kohsuke.org/"));
813+
assertThat(state.getCreator().getLogin(), equalTo("kohsuke"));
774814
}
775815

776816
@Test

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

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/GHRepositoryTest.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ public void listCommitCommentsSomeComments() throws IOException {
495495
assertThat("Comment text found",
496496
commitComments.stream().map(GHCommitComment::getBody).collect(Collectors.toList()),
497497
containsInAnyOrder("comment 1", "comment 2"));
498-
499498
}
500499

501500
@Test // Issue #261

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/__files/orgs_hub4j-test-org-6ab1a03d-267b-4675-a8e4-91bbef27f6ec.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/__files/orgs_hub4j-test-org-6ab1a03d-267b-4675-a8e4-91bbef27f6ec.json
-41Lines changed: 0 additions & 41 deletions
This file was deleted.

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/__files/repos_hub4j-test-org_github-api-test-2.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/__files/repos_hub4j-test-org_github-api-test-2.json
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"id": 212423833,
3-
"node_id": "MDEwOlJlcG9zaXRvcnkyMTI0MjM4MzM=",
2+
"id": 405314245,
3+
"node_id": "MDEwOlJlcG9zaXRvcnk0MDUzMTQyNDU=",
44
"name": "github-api-test",
55
"full_name": "hub4j-test-org/github-api-test",
66
"private": false,
77
"owner": {
88
"login": "hub4j-test-org",
99
"id": 7544739,
1010
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
11-
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
1212
"gravatar_id": "",
1313
"url": "https://api.github.com/users/hub4j-test-org",
1414
"html_url": "https://github.com/hub4j-test-org",
@@ -25,7 +25,7 @@
2525
"site_admin": false
2626
},
2727
"html_url": "https://github.com/hub4j-test-org/github-api-test",
28-
"description": "A test repository for testing the github-api project",
28+
"description": "A test repository for testing the github-api project: github-api-test",
2929
"fork": false,
3030
"url": "https://api.github.com/repos/hub4j-test-org/github-api-test",
3131
"forks_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/forks",
@@ -64,9 +64,9 @@
6464
"labels_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/labels{/name}",
6565
"releases_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/hub4j-test-org/github-api-test/deployments",
67-
"created_at": "2019-10-02T19:25:19Z",
68-
"updated_at": "2019-10-02T19:25:34Z",
69-
"pushed_at": "2019-10-02T19:25:20Z",
67+
"created_at": "2021-09-11T07:32:33Z",
68+
"updated_at": "2021-09-11T07:32:36Z",
69+
"pushed_at": "2021-09-11T07:32:34Z",
7070
"git_url": "git://github.com/hub4j-test-org/github-api-test.git",
7171
"ssh_url": "git@github.com:hub4j-test-org/github-api-test.git",
7272
"clone_url": "https://github.com/hub4j-test-org/github-api-test.git",
@@ -93,17 +93,22 @@
9393
"default_branch": "main",
9494
"permissions": {
9595
"admin": true,
96+
"maintain": true,
9697
"push": true,
98+
"triage": true,
9799
"pull": true
98100
},
101+
"temp_clone_token": "",
99102
"allow_squash_merge": true,
100103
"allow_merge_commit": true,
101104
"allow_rebase_merge": true,
105+
"allow_auto_merge": false,
106+
"delete_branch_on_merge": false,
102107
"organization": {
103108
"login": "hub4j-test-org",
104109
"id": 7544739,
105110
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
106-
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
111+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
107112
"gravatar_id": "",
108113
"url": "https://api.github.com/users/hub4j-test-org",
109114
"html_url": "https://github.com/hub4j-test-org",
@@ -120,5 +125,5 @@
120125
"site_admin": false
121126
},
122127
"network_count": 0,
123-
"subscribers_count": 2
128+
"subscribers_count": 14
124129
}

0 commit comments

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