Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

Commit b40ca62

Browse files
committed
feat: add test to test team client creation
1 parent 36d1521 commit b40ca62

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.clients;
22+
23+
import static com.google.common.io.Resources.getResource;
24+
import static java.nio.charset.Charset.defaultCharset;
25+
import static java.util.concurrent.CompletableFuture.completedFuture;
26+
import static org.hamcrest.MatcherAssert.assertThat;
27+
import static org.hamcrest.core.Is.is;
28+
import static org.mockito.Mockito.mock;
29+
import static org.mockito.Mockito.when;
30+
31+
import com.google.common.io.Resources;
32+
import com.spotify.github.jackson.Json;
33+
import com.spotify.github.v3.Team;
34+
import java.io.IOException;
35+
import java.util.concurrent.CompletableFuture;
36+
import org.junit.Before;
37+
import org.junit.Test;
38+
39+
public class OrganisationClientTest {
40+
41+
private GitHubClient github;
42+
43+
private OrganisationClient organisationClient;
44+
45+
private Json json;
46+
47+
private static String getFixture(String resource) throws IOException {
48+
return Resources.toString(getResource(TeamClientTest.class, resource), defaultCharset());
49+
}
50+
51+
@Before
52+
public void setUp() {
53+
github = mock(GitHubClient.class);
54+
organisationClient = new OrganisationClient(github, "github");
55+
json = Json.create();
56+
when(github.json()).thenReturn(json);
57+
}
58+
59+
@Test
60+
public void testTeamClient() throws Exception {
61+
final TeamClient teamClient = organisationClient.createTeamClient(github, "github");
62+
final CompletableFuture<Team> fixture =
63+
completedFuture(json.fromJson(getFixture("team_get.json"), Team.class));
64+
when(github.request("/orgs/github/teams/justice-league", Team.class)).thenReturn(fixture);
65+
final Team team = teamClient.getTeam("justice-league").get();
66+
assertThat(team.id(), is(1));
67+
assertThat(team.name(), is("Justice League"));
68+
}
69+
}

0 commit comments

Comments
 (0)