diff --git a/src/main/java/net/tuzigiri/TuzigiriApplication.java b/src/main/java/net/tuzigiri/TuzigiriApplication.java index 5281842..bc87641 100644 --- a/src/main/java/net/tuzigiri/TuzigiriApplication.java +++ b/src/main/java/net/tuzigiri/TuzigiriApplication.java @@ -2,11 +2,18 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; @SpringBootApplication public class TuzigiriApplication { - public static void main(String[] args) { - SpringApplication.run(TuzigiriApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(TuzigiriApplication.class, args); + } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } } diff --git a/src/main/java/net/tuzigiri/domain/github/GithubApi.java b/src/main/java/net/tuzigiri/domain/github/GithubApi.java new file mode 100644 index 0000000..f00bb17 --- /dev/null +++ b/src/main/java/net/tuzigiri/domain/github/GithubApi.java @@ -0,0 +1,43 @@ +package net.tuzigiri.domain.github; + +import net.tuzigiri.domain.identity.AccessToken; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; +import org.springframework.http.RequestEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +@Component +public class GithubApi { + + private final RestTemplate restOperations; + + public GithubApi(RestTemplate restOperations) { + this.restOperations = restOperations; + } + + /** + * アクセストークンに紐づくユーザーのリポジトリ一覧を返します + * + * @param accessToken アクセストークン + * @return アクセストークンに紐づくユーザーのリポジトリ一覧 + */ + public List fetchRepositories(AccessToken accessToken) { + try { + LinkedMultiValueMap headers = new LinkedMultiValueMap<>(); + headers.add("Authorization", String.format("token %s", accessToken.getTokenValue())); + RequestEntity requestEntity = new RequestEntity<>(headers, HttpMethod.GET, new URI("https://api.github.com/user/repos")); + ResponseEntity> entity = restOperations.exchange(requestEntity, new ParameterizedTypeReference>() { + }); + return entity.getBody(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/net/tuzigiri/domain/github/GithubRepository.java b/src/main/java/net/tuzigiri/domain/github/GithubRepository.java new file mode 100644 index 0000000..a93ab2e --- /dev/null +++ b/src/main/java/net/tuzigiri/domain/github/GithubRepository.java @@ -0,0 +1,135 @@ +package net.tuzigiri.domain.github; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.time.LocalDateTime; + +/** + * @see github document + */ +public class GithubRepository { + private final long id; + private final String name; + private final String fullName; + private final boolean isPrivate; + private final GithubUser owner; + private final String repositoryUrl; + private final LocalDateTime createdAt; + private final LocalDateTime updatedAt; + private final LocalDateTime pushedAt; + private final String gitUrl; + private final String sshUrl; + private final String cloneUrl; + private final long size; + private final long starsCount; + private final long watchersCount; + private final long forksCount; + private final String language; + + @JsonCreator + public GithubRepository( + @JsonProperty("id") long id, + @JsonProperty("name") String name, + @JsonProperty("full_name") String fullName, + @JsonProperty("private") boolean isPrivate, + @JsonProperty("owner") GithubUser owner, + @JsonProperty("html_url") String repositoryUrl, + @JsonProperty("created_at") LocalDateTime createdAt, + @JsonProperty("updated_at") LocalDateTime updatedAt, + @JsonProperty("pushed_at") LocalDateTime pushedAt, + @JsonProperty("git_url") String gitUrl, + @JsonProperty("ssh_url") String sshUrl, + @JsonProperty("clone_url") String cloneUrl, + @JsonProperty("size") long size, + @JsonProperty("stargazers_count") long starsCount, + @JsonProperty("watchers_count") long watchersCount, + @JsonProperty("forks_count") long forksCount, + @JsonProperty("language") String language) { + this.id = id; + this.name = name; + this.fullName = fullName; + this.isPrivate = isPrivate; + this.owner = owner; + this.repositoryUrl = repositoryUrl; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.pushedAt = pushedAt; + this.gitUrl = gitUrl; + this.sshUrl = sshUrl; + this.cloneUrl = cloneUrl; + this.size = size; + this.starsCount = starsCount; + this.watchersCount = watchersCount; + this.forksCount = forksCount; + this.language = language; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + + public String getFullName() { + return fullName; + } + + public boolean isPrivate() { + return isPrivate; + } + + public GithubUser getOwner() { + return owner; + } + + public String getRepositoryUrl() { + return repositoryUrl; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + public LocalDateTime getPushedAt() { + return pushedAt; + } + + public String getGitUrl() { + return gitUrl; + } + + public String getSshUrl() { + return sshUrl; + } + + public String getCloneUrl() { + return cloneUrl; + } + + public long getSize() { + return size; + } + + public long getStarsCount() { + return starsCount; + } + + public long getWatchersCount() { + return watchersCount; + } + + public long getForksCount() { + return forksCount; + } + + public String getLanguage() { + return language; + } +} diff --git a/src/main/java/net/tuzigiri/domain/github/GithubUser.java b/src/main/java/net/tuzigiri/domain/github/GithubUser.java new file mode 100644 index 0000000..46beefe --- /dev/null +++ b/src/main/java/net/tuzigiri/domain/github/GithubUser.java @@ -0,0 +1,39 @@ +package net.tuzigiri.domain.github; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class GithubUser { + private final String userId; + private final long id; + private final String avatarUrl; + private final String profileUrl; + + @JsonCreator + public GithubUser( + @JsonProperty("login") String userId, + @JsonProperty("id") long id, + @JsonProperty("avatar_url") String avatarUrl, + @JsonProperty("html_url") String profileUrl) { + this.userId = userId; + this.id = id; + this.avatarUrl = avatarUrl; + this.profileUrl = profileUrl; + } + + public String getUserId() { + return userId; + } + + public long getId() { + return id; + } + + public String getAvatarUrl() { + return avatarUrl; + } + + public String getProfileUrl() { + return profileUrl; + } +} diff --git a/src/test/java/net/tuzigiri/domain/github/GithubApiTest.java b/src/test/java/net/tuzigiri/domain/github/GithubApiTest.java new file mode 100644 index 0000000..f5306ce --- /dev/null +++ b/src/test/java/net/tuzigiri/domain/github/GithubApiTest.java @@ -0,0 +1,334 @@ +package net.tuzigiri.domain.github; + +import net.tuzigiri.domain.identity.AccessToken; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.web.client.RestTemplate; + +import java.time.LocalDateTime; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class GithubApiTest { + + @Autowired + private GithubApi service; + + @Autowired + private RestTemplate restTemplate; + + @Test + public void testFetchRepository() { + MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); + // + server.expect(requestTo("https://api.github.com/user/repos")).andRespond(withSuccess("[\n" + + " {\n" + + " \"id\": 123787484,\n" + + " \"node_id\": \"MDEwOlJlcG9zaXRvcnkxMjM3ODc0ODQ=\",\n" + + " \"name\": \"Moco-Framework\",\n" + + " \"full_name\": \"orekyuu/Moco-Framework\",\n" + + " \"private\": false,\n" + + " \"owner\": {\n" + + " \"login\": \"orekyuu\",\n" + + " \"id\": 2792624,\n" + + " \"node_id\": \"MDQ6VXNlcjI3OTI2MjQ=\",\n" + + " \"avatar_url\": \"https://avatars0.githubusercontent.com/u/2792624?v=4\",\n" + + " \"gravatar_id\": \"\",\n" + + " \"url\": \"https://api.github.com/users/orekyuu\",\n" + + " \"html_url\": \"https://github.com/orekyuu\",\n" + + " \"followers_url\": \"https://api.github.com/users/orekyuu/followers\",\n" + + " \"following_url\": \"https://api.github.com/users/orekyuu/following{/other_user}\",\n" + + " \"gists_url\": \"https://api.github.com/users/orekyuu/gists{/gist_id}\",\n" + + " \"starred_url\": \"https://api.github.com/users/orekyuu/starred{/owner}{/repo}\",\n" + + " \"subscriptions_url\": \"https://api.github.com/users/orekyuu/subscriptions\",\n" + + " \"organizations_url\": \"https://api.github.com/users/orekyuu/orgs\",\n" + + " \"repos_url\": \"https://api.github.com/users/orekyuu/repos\",\n" + + " \"events_url\": \"https://api.github.com/users/orekyuu/events{/privacy}\",\n" + + " \"received_events_url\": \"https://api.github.com/users/orekyuu/received_events\",\n" + + " \"type\": \"User\",\n" + + " \"site_admin\": false\n" + + " },\n" + + " \"html_url\": \"https://github.com/orekyuu/Moco-Framework\",\n" + + " \"description\": null,\n" + + " \"fork\": false,\n" + + " \"url\": \"https://api.github.com/repos/orekyuu/Moco-Framework\",\n" + + " \"forks_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/forks\",\n" + + " \"keys_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/keys{/key_id}\",\n" + + " \"collaborators_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/collaborators{/collaborator}\",\n" + + " \"teams_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/teams\",\n" + + " \"hooks_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/hooks\",\n" + + " \"issue_events_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/issues/events{/number}\",\n" + + " \"events_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/events\",\n" + + " \"assignees_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/assignees{/user}\",\n" + + " \"branches_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/branches{/branch}\",\n" + + " \"tags_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/tags\",\n" + + " \"blobs_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/git/blobs{/sha}\",\n" + + " \"git_tags_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/git/tags{/sha}\",\n" + + " \"git_refs_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/git/refs{/sha}\",\n" + + " \"trees_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/git/trees{/sha}\",\n" + + " \"statuses_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/statuses/{sha}\",\n" + + " \"languages_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/languages\",\n" + + " \"stargazers_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/stargazers\",\n" + + " \"contributors_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/contributors\",\n" + + " \"subscribers_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/subscribers\",\n" + + " \"subscription_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/subscription\",\n" + + " \"commits_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/commits{/sha}\",\n" + + " \"git_commits_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/git/commits{/sha}\",\n" + + " \"comments_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/comments{/number}\",\n" + + " \"issue_comment_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/issues/comments{/number}\",\n" + + " \"contents_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/contents/{+path}\",\n" + + " \"compare_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/compare/{base}...{head}\",\n" + + " \"merges_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/merges\",\n" + + " \"archive_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/{archive_format}{/ref}\",\n" + + " \"downloads_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/downloads\",\n" + + " \"issues_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/issues{/number}\",\n" + + " \"pulls_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/pulls{/number}\",\n" + + " \"milestones_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/milestones{/number}\",\n" + + " \"notifications_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/notifications{?since,all,participating}\",\n" + + " \"labels_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/labels{/name}\",\n" + + " \"releases_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/releases{/id}\",\n" + + " \"deployments_url\": \"https://api.github.com/repos/orekyuu/Moco-Framework/deployments\",\n" + + " \"created_at\": \"2018-03-04T12:43:10Z\",\n" + + " \"updated_at\": \"2018-08-23T13:03:57Z\",\n" + + " \"pushed_at\": \"2018-05-27T14:10:19Z\",\n" + + " \"git_url\": \"git://github.com/orekyuu/Moco-Framework.git\",\n" + + " \"ssh_url\": \"git@github.com:orekyuu/Moco-Framework.git\",\n" + + " \"clone_url\": \"https://github.com/orekyuu/Moco-Framework.git\",\n" + + " \"svn_url\": \"https://github.com/orekyuu/Moco-Framework\",\n" + + " \"homepage\": null,\n" + + " \"size\": 353,\n" + + " \"stargazers_count\": 8,\n" + + " \"watchers_count\": 8,\n" + + " \"language\": \"Java\",\n" + + " \"has_issues\": true,\n" + + " \"has_projects\": true,\n" + + " \"has_downloads\": true,\n" + + " \"has_wiki\": true,\n" + + " \"has_pages\": false,\n" + + " \"forks_count\": 1,\n" + + " \"mirror_url\": null,\n" + + " \"archived\": false,\n" + + " \"open_issues_count\": 1,\n" + + " \"license\": null,\n" + + " \"forks\": 1,\n" + + " \"open_issues\": 1,\n" + + " \"watchers\": 8,\n" + + " \"default_branch\": \"master\",\n" + + " \"permissions\": {\n" + + " \"admin\": true,\n" + + " \"push\": true,\n" + + " \"pull\": true\n" + + " }\n" + + " },\n" + + " {\n" + + " \"id\": 135037896,\n" + + " \"node_id\": \"MDEwOlJlcG9zaXRvcnkxMzUwMzc4OTY=\",\n" + + " \"name\": \"Moco-SpringBoot-Sample\",\n" + + " \"full_name\": \"orekyuu/Moco-SpringBoot-Sample\",\n" + + " \"private\": false,\n" + + " \"owner\": {\n" + + " \"login\": \"orekyuu\",\n" + + " \"id\": 2792624,\n" + + " \"node_id\": \"MDQ6VXNlcjI3OTI2MjQ=\",\n" + + " \"avatar_url\": \"https://avatars0.githubusercontent.com/u/2792624?v=4\",\n" + + " \"gravatar_id\": \"\",\n" + + " \"url\": \"https://api.github.com/users/orekyuu\",\n" + + " \"html_url\": \"https://github.com/orekyuu\",\n" + + " \"followers_url\": \"https://api.github.com/users/orekyuu/followers\",\n" + + " \"following_url\": \"https://api.github.com/users/orekyuu/following{/other_user}\",\n" + + " \"gists_url\": \"https://api.github.com/users/orekyuu/gists{/gist_id}\",\n" + + " \"starred_url\": \"https://api.github.com/users/orekyuu/starred{/owner}{/repo}\",\n" + + " \"subscriptions_url\": \"https://api.github.com/users/orekyuu/subscriptions\",\n" + + " \"organizations_url\": \"https://api.github.com/users/orekyuu/orgs\",\n" + + " \"repos_url\": \"https://api.github.com/users/orekyuu/repos\",\n" + + " \"events_url\": \"https://api.github.com/users/orekyuu/events{/privacy}\",\n" + + " \"received_events_url\": \"https://api.github.com/users/orekyuu/received_events\",\n" + + " \"type\": \"User\",\n" + + " \"site_admin\": false\n" + + " },\n" + + " \"html_url\": \"https://github.com/orekyuu/Moco-SpringBoot-Sample\",\n" + + " \"description\": null,\n" + + " \"fork\": false,\n" + + " \"url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample\",\n" + + " \"forks_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/forks\",\n" + + " \"keys_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/keys{/key_id}\",\n" + + " \"collaborators_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/collaborators{/collaborator}\",\n" + + " \"teams_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/teams\",\n" + + " \"hooks_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/hooks\",\n" + + " \"issue_events_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/issues/events{/number}\",\n" + + " \"events_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/events\",\n" + + " \"assignees_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/assignees{/user}\",\n" + + " \"branches_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/branches{/branch}\",\n" + + " \"tags_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/tags\",\n" + + " \"blobs_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/git/blobs{/sha}\",\n" + + " \"git_tags_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/git/tags{/sha}\",\n" + + " \"git_refs_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/git/refs{/sha}\",\n" + + " \"trees_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/git/trees{/sha}\",\n" + + " \"statuses_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/statuses/{sha}\",\n" + + " \"languages_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/languages\",\n" + + " \"stargazers_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/stargazers\",\n" + + " \"contributors_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/contributors\",\n" + + " \"subscribers_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/subscribers\",\n" + + " \"subscription_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/subscription\",\n" + + " \"commits_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/commits{/sha}\",\n" + + " \"git_commits_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/git/commits{/sha}\",\n" + + " \"comments_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/comments{/number}\",\n" + + " \"issue_comment_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/issues/comments{/number}\",\n" + + " \"contents_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/contents/{+path}\",\n" + + " \"compare_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/compare/{base}...{head}\",\n" + + " \"merges_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/merges\",\n" + + " \"archive_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/{archive_format}{/ref}\",\n" + + " \"downloads_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/downloads\",\n" + + " \"issues_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/issues{/number}\",\n" + + " \"pulls_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/pulls{/number}\",\n" + + " \"milestones_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/milestones{/number}\",\n" + + " \"notifications_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/notifications{?since,all,participating}\",\n" + + " \"labels_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/labels{/name}\",\n" + + " \"releases_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/releases{/id}\",\n" + + " \"deployments_url\": \"https://api.github.com/repos/orekyuu/Moco-SpringBoot-Sample/deployments\",\n" + + " \"created_at\": \"2018-05-27T10:52:19Z\",\n" + + " \"updated_at\": \"2018-05-27T10:54:48Z\",\n" + + " \"pushed_at\": \"2018-05-27T10:54:47Z\",\n" + + " \"git_url\": \"git://github.com/orekyuu/Moco-SpringBoot-Sample.git\",\n" + + " \"ssh_url\": \"git@github.com:orekyuu/Moco-SpringBoot-Sample.git\",\n" + + " \"clone_url\": \"https://github.com/orekyuu/Moco-SpringBoot-Sample.git\",\n" + + " \"svn_url\": \"https://github.com/orekyuu/Moco-SpringBoot-Sample\",\n" + + " \"homepage\": null,\n" + + " \"size\": 55,\n" + + " \"stargazers_count\": 0,\n" + + " \"watchers_count\": 0,\n" + + " \"language\": \"Java\",\n" + + " \"has_issues\": true,\n" + + " \"has_projects\": true,\n" + + " \"has_downloads\": true,\n" + + " \"has_wiki\": true,\n" + + " \"has_pages\": false,\n" + + " \"forks_count\": 0,\n" + + " \"mirror_url\": null,\n" + + " \"archived\": false,\n" + + " \"open_issues_count\": 0,\n" + + " \"license\": null,\n" + + " \"forks\": 0,\n" + + " \"open_issues\": 0,\n" + + " \"watchers\": 0,\n" + + " \"default_branch\": \"master\",\n" + + " \"permissions\": {\n" + + " \"admin\": true,\n" + + " \"push\": true,\n" + + " \"pull\": true\n" + + " }\n" + + " },\n" + + " {\n" + + " \"id\": 134043223,\n" + + " \"node_id\": \"MDEwOlJlcG9zaXRvcnkxMzQwNDMyMjM=\",\n" + + " \"name\": \"MocoSample\",\n" + + " \"full_name\": \"orekyuu/MocoSample\",\n" + + " \"private\": false,\n" + + " \"owner\": {\n" + + " \"login\": \"orekyuu\",\n" + + " \"id\": 2792624,\n" + + " \"node_id\": \"MDQ6VXNlcjI3OTI2MjQ=\",\n" + + " \"avatar_url\": \"https://avatars0.githubusercontent.com/u/2792624?v=4\",\n" + + " \"gravatar_id\": \"\",\n" + + " \"url\": \"https://api.github.com/users/orekyuu\",\n" + + " \"html_url\": \"https://github.com/orekyuu\",\n" + + " \"followers_url\": \"https://api.github.com/users/orekyuu/followers\",\n" + + " \"following_url\": \"https://api.github.com/users/orekyuu/following{/other_user}\",\n" + + " \"gists_url\": \"https://api.github.com/users/orekyuu/gists{/gist_id}\",\n" + + " \"starred_url\": \"https://api.github.com/users/orekyuu/starred{/owner}{/repo}\",\n" + + " \"subscriptions_url\": \"https://api.github.com/users/orekyuu/subscriptions\",\n" + + " \"organizations_url\": \"https://api.github.com/users/orekyuu/orgs\",\n" + + " \"repos_url\": \"https://api.github.com/users/orekyuu/repos\",\n" + + " \"events_url\": \"https://api.github.com/users/orekyuu/events{/privacy}\",\n" + + " \"received_events_url\": \"https://api.github.com/users/orekyuu/received_events\",\n" + + " \"type\": \"User\",\n" + + " \"site_admin\": false\n" + + " },\n" + + " \"html_url\": \"https://github.com/orekyuu/MocoSample\",\n" + + " \"description\": \"Mocoのサンプルリポジトリです\",\n" + + " \"fork\": false,\n" + + " \"url\": \"https://api.github.com/repos/orekyuu/MocoSample\",\n" + + " \"forks_url\": \"https://api.github.com/repos/orekyuu/MocoSample/forks\",\n" + + " \"keys_url\": \"https://api.github.com/repos/orekyuu/MocoSample/keys{/key_id}\",\n" + + " \"collaborators_url\": \"https://api.github.com/repos/orekyuu/MocoSample/collaborators{/collaborator}\",\n" + + " \"teams_url\": \"https://api.github.com/repos/orekyuu/MocoSample/teams\",\n" + + " \"hooks_url\": \"https://api.github.com/repos/orekyuu/MocoSample/hooks\",\n" + + " \"issue_events_url\": \"https://api.github.com/repos/orekyuu/MocoSample/issues/events{/number}\",\n" + + " \"events_url\": \"https://api.github.com/repos/orekyuu/MocoSample/events\",\n" + + " \"assignees_url\": \"https://api.github.com/repos/orekyuu/MocoSample/assignees{/user}\",\n" + + " \"branches_url\": \"https://api.github.com/repos/orekyuu/MocoSample/branches{/branch}\",\n" + + " \"tags_url\": \"https://api.github.com/repos/orekyuu/MocoSample/tags\",\n" + + " \"blobs_url\": \"https://api.github.com/repos/orekyuu/MocoSample/git/blobs{/sha}\",\n" + + " \"git_tags_url\": \"https://api.github.com/repos/orekyuu/MocoSample/git/tags{/sha}\",\n" + + " \"git_refs_url\": \"https://api.github.com/repos/orekyuu/MocoSample/git/refs{/sha}\",\n" + + " \"trees_url\": \"https://api.github.com/repos/orekyuu/MocoSample/git/trees{/sha}\",\n" + + " \"statuses_url\": \"https://api.github.com/repos/orekyuu/MocoSample/statuses/{sha}\",\n" + + " \"languages_url\": \"https://api.github.com/repos/orekyuu/MocoSample/languages\",\n" + + " \"stargazers_url\": \"https://api.github.com/repos/orekyuu/MocoSample/stargazers\",\n" + + " \"contributors_url\": \"https://api.github.com/repos/orekyuu/MocoSample/contributors\",\n" + + " \"subscribers_url\": \"https://api.github.com/repos/orekyuu/MocoSample/subscribers\",\n" + + " \"subscription_url\": \"https://api.github.com/repos/orekyuu/MocoSample/subscription\",\n" + + " \"commits_url\": \"https://api.github.com/repos/orekyuu/MocoSample/commits{/sha}\",\n" + + " \"git_commits_url\": \"https://api.github.com/repos/orekyuu/MocoSample/git/commits{/sha}\",\n" + + " \"comments_url\": \"https://api.github.com/repos/orekyuu/MocoSample/comments{/number}\",\n" + + " \"issue_comment_url\": \"https://api.github.com/repos/orekyuu/MocoSample/issues/comments{/number}\",\n" + + " \"contents_url\": \"https://api.github.com/repos/orekyuu/MocoSample/contents/{+path}\",\n" + + " \"compare_url\": \"https://api.github.com/repos/orekyuu/MocoSample/compare/{base}...{head}\",\n" + + " \"merges_url\": \"https://api.github.com/repos/orekyuu/MocoSample/merges\",\n" + + " \"archive_url\": \"https://api.github.com/repos/orekyuu/MocoSample/{archive_format}{/ref}\",\n" + + " \"downloads_url\": \"https://api.github.com/repos/orekyuu/MocoSample/downloads\",\n" + + " \"issues_url\": \"https://api.github.com/repos/orekyuu/MocoSample/issues{/number}\",\n" + + " \"pulls_url\": \"https://api.github.com/repos/orekyuu/MocoSample/pulls{/number}\",\n" + + " \"milestones_url\": \"https://api.github.com/repos/orekyuu/MocoSample/milestones{/number}\",\n" + + " \"notifications_url\": \"https://api.github.com/repos/orekyuu/MocoSample/notifications{?since,all,participating}\",\n" + + " \"labels_url\": \"https://api.github.com/repos/orekyuu/MocoSample/labels{/name}\",\n" + + " \"releases_url\": \"https://api.github.com/repos/orekyuu/MocoSample/releases{/id}\",\n" + + " \"deployments_url\": \"https://api.github.com/repos/orekyuu/MocoSample/deployments\",\n" + + " \"created_at\": \"2018-05-19T08:12:12Z\",\n" + + " \"updated_at\": \"2018-05-21T14:27:35Z\",\n" + + " \"pushed_at\": \"2018-05-21T14:27:34Z\",\n" + + " \"git_url\": \"git://github.com/orekyuu/MocoSample.git\",\n" + + " \"ssh_url\": \"git@github.com:orekyuu/MocoSample.git\",\n" + + " \"clone_url\": \"https://github.com/orekyuu/MocoSample.git\",\n" + + " \"svn_url\": \"https://github.com/orekyuu/MocoSample\",\n" + + " \"homepage\": null,\n" + + " \"size\": 62,\n" + + " \"stargazers_count\": 0,\n" + + " \"watchers_count\": 0,\n" + + " \"language\": \"Java\",\n" + + " \"has_issues\": true,\n" + + " \"has_projects\": true,\n" + + " \"has_downloads\": true,\n" + + " \"has_wiki\": true,\n" + + " \"has_pages\": false,\n" + + " \"forks_count\": 0,\n" + + " \"mirror_url\": null,\n" + + " \"archived\": false,\n" + + " \"open_issues_count\": 0,\n" + + " \"license\": null,\n" + + " \"forks\": 0,\n" + + " \"open_issues\": 0,\n" + + " \"watchers\": 0,\n" + + " \"default_branch\": \"master\",\n" + + " \"permissions\": {\n" + + " \"admin\": true,\n" + + " \"push\": true,\n" + + " \"pull\": true\n" + + " }\n" + + " }\n" + + "]", MediaType.APPLICATION_JSON)); + // + List result = service.fetchRepositories(new AccessToken("test", LocalDateTime.now(), LocalDateTime.now())); + assertThat(result).hasSize(3); + } +}