Skip to content

Commit 1165c88

Browse files
committed
Throw UnsupportedOperationException in long deprecated GitHub#getTeam(int)
This API is not supported anymore.
1 parent 358f4ee commit 1165c88

File tree

16 files changed

+181
-500
lines changed

16 files changed

+181
-500
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,9 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
874874
}
875875

876876
/**
877-
* Gets a sigle team by ID.
877+
* Gets a single team by ID.
878+
* <p>
879+
* This method is no longer supported and throws an UnsupportedOperationException.
878880
*
879881
* @param id
880882
* the id
@@ -883,11 +885,14 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
883885
* the io exception
884886
*
885887
* @deprecated Use {@link GHOrganization#getTeam(long)}
886-
* @see <a href= "https://developer.github.com/v3/teams/#get-team-legacy">deprecation notice</a>
888+
* @see <a href="https://developer.github.com/v3/teams/#get-team-legacy">deprecation notice</a>
889+
* @see <a href="https://github.blog/changelog/2022-02-22-sunset-notice-deprecated-teams-api-endpoints/">sunset
890+
* notice</a>
887891
*/
888892
@Deprecated
889893
public GHTeam getTeam(int id) throws IOException {
890-
return createRequest().withUrlPath("/teams/" + id).fetch(GHTeam.class).wrapUp(this);
894+
throw new UnsupportedOperationException(
895+
"This method is not supported anymore. Please use GHOrganization#getTeam(long).");
891896
}
892897

893898
/**

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.stream.Collectors;
2222

2323
import static org.hamcrest.Matchers.*;
24+
import static org.junit.Assert.assertThrows;
2425

2526
/**
2627
* Unit test for simple App.
@@ -444,15 +445,12 @@ private boolean shouldBelongToTeam(String organizationName, String teamName) thr
444445
}
445446

446447
@Test
447-
public void testShouldFetchTeam() throws Exception {
448+
@SuppressWarnings("deprecation")
449+
public void testFetchingTeamFromGitHubInstanceThrowsException() throws Exception {
448450
GHOrganization organization = gitHub.getOrganization(GITHUB_API_TEST_ORG);
449451
GHTeam teamByName = organization.getTeams().get("Core Developers");
450452

451-
GHTeam teamById = gitHub.getTeam((int) teamByName.getId());
452-
assertThat(teamById, notNullValue());
453-
454-
assertThat(teamById.getId(), equalTo(teamByName.getId()));
455-
assertThat(teamById.getDescription(), equalTo(teamByName.getDescription()));
453+
assertThrows(UnsupportedOperationException.class, () -> gitHub.getTeam((int) teamByName.getId()));
456454
}
457455

458456
@Test

src/test/resources/org/kohsuke/github/AppTest/wiremock/testShouldFetchTeam/__files/orgs_hub4j-test-org-2.json renamed to src/test/resources/org/kohsuke/github/AppTest/wiremock/testFetchingTeamFromGitHubInstanceThrowsException/__files/orgs_hub4j-test-org-1.json

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,47 @@
99
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
1010
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
1111
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
12-
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
13-
"description": null,
12+
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
13+
"description": "Hub4j Test Org Description (this could be null or blank too)",
14+
"name": "Hub4j Test Org Name (this could be null or blank too)",
15+
"company": null,
16+
"blog": "https://hub4j.url.io/could/be/null",
17+
"location": "Hub4j Test Org Location (this could be null or blank too)",
18+
"email": "[email protected]",
19+
"twitter_username": null,
1420
"is_verified": false,
1521
"has_organization_projects": true,
1622
"has_repository_projects": true,
17-
"public_repos": 26,
23+
"public_repos": 49,
1824
"public_gists": 0,
1925
"followers": 0,
2026
"following": 0,
2127
"html_url": "https://github.com/hub4j-test-org",
2228
"created_at": "2014-05-10T19:39:11Z",
23-
"updated_at": "2015-04-20T00:42:30Z",
29+
"updated_at": "2020-06-04T05:56:10Z",
2430
"type": "Organization",
25-
"total_private_repos": 0,
26-
"owned_private_repos": 0,
31+
"total_private_repos": 3,
32+
"owned_private_repos": 3,
2733
"private_gists": 0,
28-
"disk_usage": 147,
34+
"disk_usage": 11979,
2935
"collaborators": 0,
3036
"billing_email": "[email protected]",
3137
"default_repository_permission": "none",
3238
"members_can_create_repositories": false,
3339
"two_factor_requirement_enabled": false,
40+
"members_allowed_repository_creation_type": "none",
41+
"members_can_create_public_repositories": false,
42+
"members_can_create_private_repositories": false,
43+
"members_can_create_internal_repositories": false,
44+
"members_can_create_pages": true,
45+
"members_can_fork_private_repositories": false,
46+
"members_can_create_public_pages": true,
47+
"members_can_create_private_pages": true,
3448
"plan": {
3549
"name": "free",
3650
"space": 976562499,
37-
"private_repos": 0,
38-
"filled_seats": 13,
39-
"seats": 0
51+
"private_repos": 10000,
52+
"filled_seats": 35,
53+
"seats": 3
4054
}
4155
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[
2+
{
3+
"name": "child-team-for-dummy",
4+
"id": 3903497,
5+
"node_id": "MDQ6VGVhbTM5MDM0OTc=",
6+
"slug": "child-team-for-dummy",
7+
"description": "to test the fetching of child teams",
8+
"privacy": "closed",
9+
"url": "https://api.github.com/organizations/7544739/team/3903497",
10+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/child-team-for-dummy",
11+
"members_url": "https://api.github.com/organizations/7544739/team/3903497/members{/member}",
12+
"repositories_url": "https://api.github.com/organizations/7544739/team/3903497/repos",
13+
"permission": "pull",
14+
"parent": {
15+
"name": "dummy-team",
16+
"id": 3451996,
17+
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
18+
"slug": "dummy-team",
19+
"description": "Updated by API TestModified",
20+
"privacy": "closed",
21+
"url": "https://api.github.com/organizations/7544739/team/3451996",
22+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
23+
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
24+
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
25+
"permission": "pull"
26+
}
27+
},
28+
{
29+
"name": "Contributors",
30+
"id": 4882699,
31+
"node_id": "MDQ6VGVhbTQ4ODI2OTk=",
32+
"slug": "contributors",
33+
"description": "",
34+
"privacy": "closed",
35+
"url": "https://api.github.com/organizations/7544739/team/4882699",
36+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/contributors",
37+
"members_url": "https://api.github.com/organizations/7544739/team/4882699/members{/member}",
38+
"repositories_url": "https://api.github.com/organizations/7544739/team/4882699/repos",
39+
"permission": "pull",
40+
"parent": null
41+
},
42+
{
43+
"name": "Core Developers",
44+
"id": 820406,
45+
"node_id": "MDQ6VGVhbTgyMDQwNg==",
46+
"slug": "core-developers",
47+
"description": "A random team",
48+
"privacy": "secret",
49+
"url": "https://api.github.com/organizations/7544739/team/820406",
50+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/core-developers",
51+
"members_url": "https://api.github.com/organizations/7544739/team/820406/members{/member}",
52+
"repositories_url": "https://api.github.com/organizations/7544739/team/820406/repos",
53+
"permission": "pull",
54+
"parent": null
55+
},
56+
{
57+
"name": "dummy-team",
58+
"id": 3451996,
59+
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
60+
"slug": "dummy-team",
61+
"description": "Updated by API TestModified",
62+
"privacy": "closed",
63+
"url": "https://api.github.com/organizations/7544739/team/3451996",
64+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
65+
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
66+
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
67+
"permission": "pull",
68+
"parent": null
69+
},
70+
{
71+
"name": "Owners-team",
72+
"id": 820404,
73+
"node_id": "MDQ6VGVhbTgyMDQwNA==",
74+
"slug": "owners-team",
75+
"description": null,
76+
"privacy": "secret",
77+
"url": "https://api.github.com/organizations/7544739/team/820404",
78+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/owners-team",
79+
"members_url": "https://api.github.com/organizations/7544739/team/820404/members{/member}",
80+
"repositories_url": "https://api.github.com/organizations/7544739/team/820404/repos",
81+
"permission": "pull",
82+
"parent": null
83+
},
84+
{
85+
"name": "simple-team",
86+
"id": 3947450,
87+
"node_id": "MDQ6VGVhbTM5NDc0NTA=",
88+
"slug": "simple-team",
89+
"description": "A simple team with no children",
90+
"privacy": "secret",
91+
"url": "https://api.github.com/organizations/7544739/team/3947450",
92+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/simple-team",
93+
"members_url": "https://api.github.com/organizations/7544739/team/3947450/members{/member}",
94+
"repositories_url": "https://api.github.com/organizations/7544739/team/3947450/repos",
95+
"permission": "pull",
96+
"parent": null
97+
},
98+
{
99+
"name": "tricky-team",
100+
"id": 3454508,
101+
"node_id": "MDQ6VGVhbTM0NTQ1MDg=",
102+
"slug": "tricky-team",
103+
"description": "",
104+
"privacy": "secret",
105+
"url": "https://api.github.com/organizations/7544739/team/3454508",
106+
"html_url": "https://github.com/orgs/hub4j-test-org/teams/tricky-team",
107+
"members_url": "https://api.github.com/organizations/7544739/team/3454508/members{/member}",
108+
"repositories_url": "https://api.github.com/organizations/7544739/team/3454508/repos",
109+
"permission": "pull",
110+
"parent": null
111+
}
112+
]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "84aa5465-24ab-43e3-9655-e835c39bfa65",
2+
"id": "3c0fb9cd-6289-4f5c-baea-1bd6980a9d15",
33
"name": "orgs_hub4j-test-org",
44
"request": {
55
"url": "/orgs/hub4j-test-org",
@@ -12,35 +12,36 @@
1212
},
1313
"response": {
1414
"status": 200,
15-
"bodyFileName": "orgs_hub4j-test-org-2.json",
15+
"bodyFileName": "orgs_hub4j-test-org-1.json",
1616
"headers": {
17-
"Date": "Tue, 17 Mar 2020 10:05:32 GMT",
18-
"Content-Type": "application/json; charset=utf-8",
1917
"Server": "GitHub.com",
20-
"Status": "200 OK",
21-
"X-RateLimit-Limit": "5000",
22-
"X-RateLimit-Remaining": "4937",
23-
"X-RateLimit-Reset": "1584440312",
18+
"Date": "Fri, 04 Mar 2022 19:26:44 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
2420
"Cache-Control": "private, max-age=60, s-maxage=60",
2521
"Vary": [
2622
"Accept, Authorization, Cookie, X-GitHub-OTP",
2723
"Accept-Encoding, Accept, X-Requested-With"
2824
],
29-
"ETag": "W/\"9d4203e09aeffc9b5325c2a5355275b5\"",
30-
"Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
31-
"X-OAuth-Scopes": "admin:org, admin:public_key, admin:repo_hook, notifications, repo, user",
25+
"ETag": "W/\"861b38147d37bd59e507771e76ec048def20dd6e5ac5b75aceb01c8b9f0ef4f5\"",
26+
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
27+
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
3228
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
33-
"X-GitHub-Media-Type": "unknown, github.v3",
29+
"X-GitHub-Media-Type": "github.v3; format=json",
30+
"X-RateLimit-Limit": "5000",
31+
"X-RateLimit-Remaining": "4998",
32+
"X-RateLimit-Reset": "1646424320",
33+
"X-RateLimit-Used": "2",
34+
"X-RateLimit-Resource": "core",
3435
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
3536
"X-Frame-Options": "deny",
3637
"X-Content-Type-Options": "nosniff",
37-
"X-XSS-Protection": "1; mode=block",
38+
"X-XSS-Protection": "0",
3839
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
3940
"Content-Security-Policy": "default-src 'none'",
40-
"X-GitHub-Request-Id": "FBBC:4FD5:1C7954:325E0B:5E70A0EA"
41+
"X-GitHub-Request-Id": "B678:265F:2A24E9B:2AE23A8:622267F3"
4142
}
4243
},
43-
"uuid": "84aa5465-24ab-43e3-9655-e835c39bfa65",
44+
"uuid": "3c0fb9cd-6289-4f5c-baea-1bd6980a9d15",
4445
"persistent": true,
45-
"insertionIndex": 2
46+
"insertionIndex": 1
4647
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "d833590f-9896-462c-846b-712b50377536",
2+
"id": "ea1f3852-66f4-4238-b721-34f584b153dd",
33
"name": "orgs_hub4j-test-org_teams",
44
"request": {
55
"url": "/orgs/hub4j-test-org/teams",
@@ -12,34 +12,35 @@
1212
},
1313
"response": {
1414
"status": 200,
15-
"bodyFileName": "orgs_hub4j-test-org_teams-3.json",
15+
"bodyFileName": "orgs_hub4j-test-org_teams-2.json",
1616
"headers": {
17-
"Date": "Tue, 17 Mar 2020 10:05:32 GMT",
18-
"Content-Type": "application/json; charset=utf-8",
1917
"Server": "GitHub.com",
20-
"Status": "200 OK",
21-
"X-RateLimit-Limit": "5000",
22-
"X-RateLimit-Remaining": "4936",
23-
"X-RateLimit-Reset": "1584440312",
18+
"Date": "Fri, 04 Mar 2022 19:26:44 GMT",
19+
"Content-Type": "application/json; charset=utf-8",
2420
"Cache-Control": "private, max-age=60, s-maxage=60",
2521
"Vary": [
2622
"Accept, Authorization, Cookie, X-GitHub-OTP",
2723
"Accept-Encoding, Accept, X-Requested-With"
2824
],
29-
"ETag": "W/\"54e42fc30d88d2a30340b56bbe54f211\"",
30-
"X-OAuth-Scopes": "admin:org, admin:public_key, admin:repo_hook, notifications, repo, user",
25+
"ETag": "W/\"1964a2ad48a21e85f64539404f5b8da870c58d1e9f3f8cf1b2dd8b6969b2c909\"",
26+
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
3127
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
32-
"X-GitHub-Media-Type": "unknown, github.v3",
28+
"X-GitHub-Media-Type": "github.v3; format=json",
29+
"X-RateLimit-Limit": "5000",
30+
"X-RateLimit-Remaining": "4997",
31+
"X-RateLimit-Reset": "1646424320",
32+
"X-RateLimit-Used": "3",
33+
"X-RateLimit-Resource": "core",
3334
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
3435
"X-Frame-Options": "deny",
3536
"X-Content-Type-Options": "nosniff",
36-
"X-XSS-Protection": "1; mode=block",
37+
"X-XSS-Protection": "0",
3738
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
3839
"Content-Security-Policy": "default-src 'none'",
39-
"X-GitHub-Request-Id": "FBBC:4FD5:1C7963:325E5F:5E70A0EC"
40+
"X-GitHub-Request-Id": "B67A:2658:7E2214:85CE23:622267F4"
4041
}
4142
},
42-
"uuid": "d833590f-9896-462c-846b-712b50377536",
43+
"uuid": "ea1f3852-66f4-4238-b721-34f584b153dd",
4344
"persistent": true,
44-
"insertionIndex": 3
45+
"insertionIndex": 2
4546
}

src/test/resources/org/kohsuke/github/AppTest/wiremock/testShouldFetchTeam/__files/organizations_7544739_team_820406-7.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)