Skip to content

Commit fa26013

Browse files
committed
Add tests for new reactions
1 parent 6fc9dd4 commit fa26013

30 files changed

Lines changed: 956 additions & 89 deletions

File tree

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

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,15 +874,60 @@ public void checkToString() throws Exception {
874874
public void reactions() throws Exception {
875875
GHIssue i = gitHub.getRepository("github-api/github-api").getIssue(311);
876876

877+
List<GHReaction> l;
877878
// retrieval
878-
GHReaction r = i.listReactions().iterator().next();
879-
assertThat(r.getUser().getLogin(), is("kohsuke"));
880-
assertThat(r.getContent(), is(ReactionContent.HEART));
879+
l = i.listReactions().asList();
880+
assertThat(l.size(), equalTo(1));
881+
882+
assertThat(l.get(0).getUser().getLogin(), is("kohsuke"));
883+
assertThat(l.get(0).getContent(), is(ReactionContent.HEART));
881884

882885
// CRUD
883-
GHReaction a = i.createReaction(ReactionContent.HOORAY);
886+
GHReaction a;
887+
a = i.createReaction(ReactionContent.HOORAY);
884888
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
889+
assertThat(a.getContent(), is(ReactionContent.HOORAY));
885890
a.delete();
891+
892+
l = i.listReactions().asList();
893+
assertThat(l.size(), equalTo(1));
894+
895+
a = i.createReaction(ReactionContent.PLUS_ONE);
896+
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
897+
assertThat(a.getContent(), is(ReactionContent.PLUS_ONE));
898+
899+
a = i.createReaction(ReactionContent.CONFUSED);
900+
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
901+
assertThat(a.getContent(), is(ReactionContent.CONFUSED));
902+
903+
a = i.createReaction(ReactionContent.EYES);
904+
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
905+
assertThat(a.getContent(), is(ReactionContent.EYES));
906+
907+
a = i.createReaction(ReactionContent.ROCKET);
908+
assertThat(a.getUser().getLogin(), is(gitHub.getMyself().getLogin()));
909+
assertThat(a.getContent(), is(ReactionContent.ROCKET));
910+
911+
l = i.listReactions().asList();
912+
assertThat(l.size(), equalTo(5));
913+
assertThat(l.get(0).getUser().getLogin(), is("kohsuke"));
914+
assertThat(l.get(0).getContent(), is(ReactionContent.HEART));
915+
assertThat(l.get(1).getUser().getLogin(), is(gitHub.getMyself().getLogin()));
916+
assertThat(l.get(1).getContent(), is(ReactionContent.PLUS_ONE));
917+
assertThat(l.get(2).getUser().getLogin(), is(gitHub.getMyself().getLogin()));
918+
assertThat(l.get(2).getContent(), is(ReactionContent.CONFUSED));
919+
assertThat(l.get(3).getUser().getLogin(), is(gitHub.getMyself().getLogin()));
920+
assertThat(l.get(3).getContent(), is(ReactionContent.EYES));
921+
assertThat(l.get(4).getUser().getLogin(), is(gitHub.getMyself().getLogin()));
922+
assertThat(l.get(4).getContent(), is(ReactionContent.ROCKET));
923+
924+
l.get(1).delete();
925+
l.get(2).delete();
926+
l.get(3).delete();
927+
l.get(4).delete();
928+
929+
l = i.listReactions().asList();
930+
assertThat(l.size(), equalTo(1));
886931
}
887932

888933
@Test

src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api-802b5ffb-1b82-43ae-bd10-62f1cf8adfa3.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api-66f6b3ba-129b-441c-9f2f-c9e18c941eea.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,46 +65,48 @@
6565
"releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}",
6666
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
6767
"created_at": "2010-04-19T04:13:03Z",
68-
"updated_at": "2019-10-25T01:32:16Z",
69-
"pushed_at": "2019-10-25T16:41:09Z",
68+
"updated_at": "2020-02-23T02:42:15Z",
69+
"pushed_at": "2020-02-23T02:48:53Z",
7070
"git_url": "git://github.com/github-api/github-api.git",
7171
"ssh_url": "git@github.com:github-api/github-api.git",
7272
"clone_url": "https://github.com/github-api/github-api.git",
7373
"svn_url": "https://github.com/github-api/github-api",
74-
"homepage": "http://github-api.kohsuke.org/",
75-
"size": 13494,
76-
"stargazers_count": 565,
77-
"watchers_count": 565,
74+
"homepage": "https://github-api.kohsuke.org/",
75+
"size": 19552,
76+
"stargazers_count": 613,
77+
"watchers_count": 613,
7878
"language": "Java",
7979
"has_issues": true,
8080
"has_projects": true,
8181
"has_downloads": true,
8282
"has_wiki": true,
8383
"has_pages": true,
84-
"forks_count": 433,
84+
"forks_count": 456,
8585
"mirror_url": null,
8686
"archived": false,
8787
"disabled": false,
88-
"open_issues_count": 64,
88+
"open_issues_count": 57,
8989
"license": {
9090
"key": "mit",
9191
"name": "MIT License",
9292
"spdx_id": "MIT",
9393
"url": "https://api.github.com/licenses/mit",
9494
"node_id": "MDc6TGljZW5zZTEz"
9595
},
96-
"forks": 433,
97-
"open_issues": 64,
98-
"watchers": 565,
96+
"forks": 456,
97+
"open_issues": 57,
98+
"watchers": 613,
9999
"default_branch": "master",
100100
"permissions": {
101101
"admin": true,
102102
"push": true,
103103
"pull": true
104104
},
105+
"temp_clone_token": "",
105106
"allow_squash_merge": true,
106107
"allow_merge_commit": true,
107108
"allow_rebase_merge": true,
109+
"delete_branch_on_merge": false,
108110
"organization": {
109111
"login": "github-api",
110112
"id": 54909825,
@@ -125,6 +127,6 @@
125127
"type": "Organization",
126128
"site_admin": false
127129
},
128-
"network_count": 433,
129-
"subscribers_count": 48
130+
"network_count": 456,
131+
"subscribers_count": 47
130132
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311-27fe2304-4e19-4da7-8db3-0adf9281f71b.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311-1e8e21ad-edaf-4647-b812-4046b8f71a3a.json

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"id": 63220306,
3+
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwNg==",
4+
"user": {
5+
"login": "bitwiseman",
6+
"id": 1958953,
7+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
8+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
9+
"gravatar_id": "",
10+
"url": "https://api.github.com/users/bitwiseman",
11+
"html_url": "https://github.com/bitwiseman",
12+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
13+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
14+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
15+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
16+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
17+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
18+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
19+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
20+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
21+
"type": "User",
22+
"site_admin": false
23+
},
24+
"content": "eyes",
25+
"created_at": "2020-02-23T03:15:56Z"
26+
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311_reactions-4abb0b9d-6883-4156-9111-86ec994328df.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311_reactions-39f59d4e-7875-4b75-a093-97a0b4e7239b.json

File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"id": 63220307,
3+
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwNw==",
4+
"user": {
5+
"login": "bitwiseman",
6+
"id": 1958953,
7+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
8+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
9+
"gravatar_id": "",
10+
"url": "https://api.github.com/users/bitwiseman",
11+
"html_url": "https://github.com/bitwiseman",
12+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
13+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
14+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
15+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
16+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
17+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
18+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
19+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
20+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
21+
"type": "User",
22+
"site_admin": false
23+
},
24+
"content": "rocket",
25+
"created_at": "2020-02-23T03:15:57Z"
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"id": 63220305,
3+
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwNQ==",
4+
"user": {
5+
"login": "bitwiseman",
6+
"id": 1958953,
7+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
8+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
9+
"gravatar_id": "",
10+
"url": "https://api.github.com/users/bitwiseman",
11+
"html_url": "https://github.com/bitwiseman",
12+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
13+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
14+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
15+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
16+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
17+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
18+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
19+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
20+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
21+
"type": "User",
22+
"site_admin": false
23+
},
24+
"content": "confused",
25+
"created_at": "2020-02-23T03:15:56Z"
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"id": 5037900,
4+
"node_id": "MDg6UmVhY3Rpb241MDM3OTAw",
5+
"user": {
6+
"login": "kohsuke",
7+
"id": 50003,
8+
"node_id": "MDQ6VXNlcjUwMDAz",
9+
"avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4",
10+
"gravatar_id": "",
11+
"url": "https://api.github.com/users/kohsuke",
12+
"html_url": "https://github.com/kohsuke",
13+
"followers_url": "https://api.github.com/users/kohsuke/followers",
14+
"following_url": "https://api.github.com/users/kohsuke/following{/other_user}",
15+
"gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}",
16+
"starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}",
17+
"subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions",
18+
"organizations_url": "https://api.github.com/users/kohsuke/orgs",
19+
"repos_url": "https://api.github.com/users/kohsuke/repos",
20+
"events_url": "https://api.github.com/users/kohsuke/events{/privacy}",
21+
"received_events_url": "https://api.github.com/users/kohsuke/received_events",
22+
"type": "User",
23+
"site_admin": false
24+
},
25+
"content": "heart",
26+
"created_at": "2016-11-17T02:40:15Z"
27+
}
28+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"id": 63220303,
3+
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwMw==",
4+
"user": {
5+
"login": "bitwiseman",
6+
"id": 1958953,
7+
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
8+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
9+
"gravatar_id": "",
10+
"url": "https://api.github.com/users/bitwiseman",
11+
"html_url": "https://github.com/bitwiseman",
12+
"followers_url": "https://api.github.com/users/bitwiseman/followers",
13+
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
14+
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
15+
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
16+
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
17+
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
18+
"repos_url": "https://api.github.com/users/bitwiseman/repos",
19+
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
20+
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
21+
"type": "User",
22+
"site_admin": false
23+
},
24+
"content": "+1",
25+
"created_at": "2020-02-23T03:15:55Z"
26+
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311_reactions-03125293-7da8-4da4-8d53-38060ef25daa.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/reactions/__files/repos_github-api_github-api_issues_311_reactions-dfcc4bc3-3276-408a-a945-e132d4fbf2e5.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": 54107401,
3-
"node_id": "MDg6UmVhY3Rpb241NDEwNzQwMQ==",
2+
"id": 63220302,
3+
"node_id": "MDg6UmVhY3Rpb242MzIyMDMwMg==",
44
"user": {
55
"login": "bitwiseman",
66
"id": 1958953,
@@ -22,5 +22,5 @@
2222
"site_admin": false
2323
},
2424
"content": "hooray",
25-
"created_at": "2019-10-26T01:27:43Z"
25+
"created_at": "2020-02-23T03:15:55Z"
2626
}

0 commit comments

Comments
 (0)