Skip to content

Commit

Permalink
Throw UnsupportedOperationException in long deprecated GitHub#getTeam…
Browse files Browse the repository at this point in the history
…(int)

This API is not supported anymore.
  • Loading branch information
gsmet committed Mar 4, 2022
1 parent 358f4ee commit 1165c88
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 500 deletions.
11 changes: 8 additions & 3 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,9 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
}

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

/**
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/org/kohsuke/github/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.stream.Collectors;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThrows;

/**
* Unit test for simple App.
Expand Down Expand Up @@ -444,15 +445,12 @@ private boolean shouldBelongToTeam(String organizationName, String teamName) thr
}

@Test
public void testShouldFetchTeam() throws Exception {
@SuppressWarnings("deprecation")
public void testFetchingTeamFromGitHubInstanceThrowsException() throws Exception {
GHOrganization organization = gitHub.getOrganization(GITHUB_API_TEST_ORG);
GHTeam teamByName = organization.getTeams().get("Core Developers");

GHTeam teamById = gitHub.getTeam((int) teamByName.getId());
assertThat(teamById, notNullValue());

assertThat(teamById.getId(), equalTo(teamByName.getId()));
assertThat(teamById.getDescription(), equalTo(teamByName.getDescription()));
assertThrows(UnsupportedOperationException.class, () -> gitHub.getTeam((int) teamByName.getId()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,47 @@
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"description": null,
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
"description": "Hub4j Test Org Description (this could be null or blank too)",
"name": "Hub4j Test Org Name (this could be null or blank too)",
"company": null,
"blog": "https://hub4j.url.io/could/be/null",
"location": "Hub4j Test Org Location (this could be null or blank too)",
"email": "hub4jtestorgemail@could.be.null.com",
"twitter_username": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 26,
"public_repos": 49,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2015-04-20T00:42:30Z",
"updated_at": "2020-06-04T05:56:10Z",
"type": "Organization",
"total_private_repos": 0,
"owned_private_repos": 0,
"total_private_repos": 3,
"owned_private_repos": 3,
"private_gists": 0,
"disk_usage": 147,
"disk_usage": 11979,
"collaborators": 0,
"billing_email": "kk@kohsuke.org",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"members_allowed_repository_creation_type": "none",
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": false,
"members_can_create_internal_repositories": false,
"members_can_create_pages": true,
"members_can_fork_private_repositories": false,
"members_can_create_public_pages": true,
"members_can_create_private_pages": true,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 0,
"filled_seats": 13,
"seats": 0
"private_repos": 10000,
"filled_seats": 35,
"seats": 3
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"name": "child-team-for-dummy",
"id": 3903497,
"node_id": "MDQ6VGVhbTM5MDM0OTc=",
"slug": "child-team-for-dummy",
"description": "to test the fetching of child teams",
"privacy": "closed",
"url": "https://api.github.com/organizations/7544739/team/3903497",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/child-team-for-dummy",
"members_url": "https://api.github.com/organizations/7544739/team/3903497/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3903497/repos",
"permission": "pull",
"parent": {
"name": "dummy-team",
"id": 3451996,
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
"slug": "dummy-team",
"description": "Updated by API TestModified",
"privacy": "closed",
"url": "https://api.github.com/organizations/7544739/team/3451996",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
"permission": "pull"
}
},
{
"name": "Contributors",
"id": 4882699,
"node_id": "MDQ6VGVhbTQ4ODI2OTk=",
"slug": "contributors",
"description": "",
"privacy": "closed",
"url": "https://api.github.com/organizations/7544739/team/4882699",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/contributors",
"members_url": "https://api.github.com/organizations/7544739/team/4882699/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/4882699/repos",
"permission": "pull",
"parent": null
},
{
"name": "Core Developers",
"id": 820406,
"node_id": "MDQ6VGVhbTgyMDQwNg==",
"slug": "core-developers",
"description": "A random team",
"privacy": "secret",
"url": "https://api.github.com/organizations/7544739/team/820406",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/core-developers",
"members_url": "https://api.github.com/organizations/7544739/team/820406/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/820406/repos",
"permission": "pull",
"parent": null
},
{
"name": "dummy-team",
"id": 3451996,
"node_id": "MDQ6VGVhbTM0NTE5OTY=",
"slug": "dummy-team",
"description": "Updated by API TestModified",
"privacy": "closed",
"url": "https://api.github.com/organizations/7544739/team/3451996",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/dummy-team",
"members_url": "https://api.github.com/organizations/7544739/team/3451996/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3451996/repos",
"permission": "pull",
"parent": null
},
{
"name": "Owners-team",
"id": 820404,
"node_id": "MDQ6VGVhbTgyMDQwNA==",
"slug": "owners-team",
"description": null,
"privacy": "secret",
"url": "https://api.github.com/organizations/7544739/team/820404",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/owners-team",
"members_url": "https://api.github.com/organizations/7544739/team/820404/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/820404/repos",
"permission": "pull",
"parent": null
},
{
"name": "simple-team",
"id": 3947450,
"node_id": "MDQ6VGVhbTM5NDc0NTA=",
"slug": "simple-team",
"description": "A simple team with no children",
"privacy": "secret",
"url": "https://api.github.com/organizations/7544739/team/3947450",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/simple-team",
"members_url": "https://api.github.com/organizations/7544739/team/3947450/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3947450/repos",
"permission": "pull",
"parent": null
},
{
"name": "tricky-team",
"id": 3454508,
"node_id": "MDQ6VGVhbTM0NTQ1MDg=",
"slug": "tricky-team",
"description": "",
"privacy": "secret",
"url": "https://api.github.com/organizations/7544739/team/3454508",
"html_url": "https://github.com/orgs/hub4j-test-org/teams/tricky-team",
"members_url": "https://api.github.com/organizations/7544739/team/3454508/members{/member}",
"repositories_url": "https://api.github.com/organizations/7544739/team/3454508/repos",
"permission": "pull",
"parent": null
}
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "84aa5465-24ab-43e3-9655-e835c39bfa65",
"id": "3c0fb9cd-6289-4f5c-baea-1bd6980a9d15",
"name": "orgs_hub4j-test-org",
"request": {
"url": "/orgs/hub4j-test-org",
Expand All @@ -12,35 +12,36 @@
},
"response": {
"status": 200,
"bodyFileName": "orgs_hub4j-test-org-2.json",
"bodyFileName": "orgs_hub4j-test-org-1.json",
"headers": {
"Date": "Tue, 17 Mar 2020 10:05:32 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4937",
"X-RateLimit-Reset": "1584440312",
"Date": "Fri, 04 Mar 2022 19:26:44 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"9d4203e09aeffc9b5325c2a5355275b5\"",
"Last-Modified": "Mon, 20 Apr 2015 00:42:30 GMT",
"X-OAuth-Scopes": "admin:org, admin:public_key, admin:repo_hook, notifications, repo, user",
"ETag": "W/\"861b38147d37bd59e507771e76ec048def20dd6e5ac5b75aceb01c8b9f0ef4f5\"",
"Last-Modified": "Thu, 04 Jun 2020 05:56:10 GMT",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4998",
"X-RateLimit-Reset": "1646424320",
"X-RateLimit-Used": "2",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "FBBC:4FD5:1C7954:325E0B:5E70A0EA"
"X-GitHub-Request-Id": "B678:265F:2A24E9B:2AE23A8:622267F3"
}
},
"uuid": "84aa5465-24ab-43e3-9655-e835c39bfa65",
"uuid": "3c0fb9cd-6289-4f5c-baea-1bd6980a9d15",
"persistent": true,
"insertionIndex": 2
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "d833590f-9896-462c-846b-712b50377536",
"id": "ea1f3852-66f4-4238-b721-34f584b153dd",
"name": "orgs_hub4j-test-org_teams",
"request": {
"url": "/orgs/hub4j-test-org/teams",
Expand All @@ -12,34 +12,35 @@
},
"response": {
"status": 200,
"bodyFileName": "orgs_hub4j-test-org_teams-3.json",
"bodyFileName": "orgs_hub4j-test-org_teams-2.json",
"headers": {
"Date": "Tue, 17 Mar 2020 10:05:32 GMT",
"Content-Type": "application/json; charset=utf-8",
"Server": "GitHub.com",
"Status": "200 OK",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4936",
"X-RateLimit-Reset": "1584440312",
"Date": "Fri, 04 Mar 2022 19:26:44 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"54e42fc30d88d2a30340b56bbe54f211\"",
"X-OAuth-Scopes": "admin:org, admin:public_key, admin:repo_hook, notifications, repo, user",
"ETag": "W/\"1964a2ad48a21e85f64539404f5b8da870c58d1e9f3f8cf1b2dd8b6969b2c909\"",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "admin:org, read:org, repo, user, write:org",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4997",
"X-RateLimit-Reset": "1646424320",
"X-RateLimit-Used": "3",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "FBBC:4FD5:1C7963:325E5F:5E70A0EC"
"X-GitHub-Request-Id": "B67A:2658:7E2214:85CE23:622267F4"
}
},
"uuid": "d833590f-9896-462c-846b-712b50377536",
"uuid": "ea1f3852-66f4-4238-b721-34f584b153dd",
"persistent": true,
"insertionIndex": 3
"insertionIndex": 2
}

This file was deleted.

Loading

0 comments on commit 1165c88

Please sign in to comment.