mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
GHRepository#listLanguages returns correct Map type
This is a less than perfect solution, but it is sufficient to solve the current issue without risking further side-effects. Fixes #1103
This commit is contained in:
@@ -578,7 +578,15 @@ public class GHRepository extends GHObject {
|
||||
* the io exception
|
||||
*/
|
||||
public Map<String, Long> listLanguages() throws IOException {
|
||||
return root.createRequest().withUrlPath(getApiTailUrl("languages")).fetch(HashMap.class);
|
||||
HashMap<String, Long> result = new HashMap<>();
|
||||
root.createRequest().withUrlPath(getApiTailUrl("languages")).fetch(HashMap.class).forEach((key, value) -> {
|
||||
Long addValue = -1L;
|
||||
if (value instanceof Integer) {
|
||||
addValue = Long.valueOf((Integer) value);
|
||||
}
|
||||
result.put(key.toString(), addValue);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
@@ -396,7 +397,10 @@ public class GHRepositoryTest extends AbstractGitHubWireMockTest {
|
||||
public void listLanguages() throws IOException {
|
||||
GHRepository r = gitHub.getRepository("hub4j/github-api");
|
||||
String mainLanguage = r.getLanguage();
|
||||
assertTrue(r.listLanguages().containsKey(mainLanguage));
|
||||
assertThat(mainLanguage, equalTo("Java"));
|
||||
Map<String, Long> languages = r.listLanguages();
|
||||
assertTrue(languages.containsKey(mainLanguage));
|
||||
assertThat(languages.get("Java"), greaterThan(100000L));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user