Skip to content

Commit afce9ec

Browse files
authored
Merge pull request hub4j#507 from ingwarsw/add_get_team_by_id
Add getTeam by id function
2 parents 154e50e + 87245ab commit afce9ec

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,13 @@ public Map<String, Set<GHTeam>> getMyTeams() throws IOException {
577577
return allMyTeams;
578578
}
579579

580+
/**
581+
* Gets a sigle team by ID.
582+
*/
583+
public GHTeam getTeam(int id) throws IOException {
584+
return retrieve().to("/teams/" + id, GHTeam.class).wrapUp(this);
585+
}
586+
580587
/**
581588
* Public events visible to you. Equivalent of what's displayed on https://github.com/
582589
*/

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ private boolean shouldBelongToTeam(String organizationName, String teamName) thr
245245
assertNotNull(team);
246246
return team.hasMember(gitHub.getMyself());
247247
}
248+
249+
@Test
250+
public void testShouldFetchTeam() throws Exception {
251+
GHOrganization j = gitHub.getOrganization("github-api-test-org");
252+
GHTeam teamByName = j.getTeams().get("Core Developers");
253+
254+
GHTeam teamById = gitHub.getTeam(teamByName.getId());
255+
assertNotNull(teamById);
256+
257+
assertEquals(teamByName, teamById);
258+
}
248259

249260
@Test
250261
public void testFetchPullRequest() throws Exception {

0 commit comments

Comments
 (0)