-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHubからリポジトリの情報を取得できるようにした #18
Conversation
/** | ||
* @see <a href="https://developer.github.com/v3/repos/#response">github document</a> | ||
*/ | ||
public class GithubRepository { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GithubRepositoryを取得するのはGithubRepositoryRepository?やばいな。と一瞬考えたがこれが一番わかり易いと思った。いい名前案絶賛募集中です
|
||
@Test | ||
public void testFetchRepository() { | ||
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RestTemplateでAPIを叩くテストをするときはMockRestServiceServerを使うと叩いた先をMockすることができて便利。
public void testFetchRepository() { | ||
MockRestServiceServer server = MockRestServiceServer.createServer(restTemplate); | ||
//<editor-fold desc="test rest server"> | ||
server.expect(requestTo("https://api.github.com/user/repos")).andRespond(withSuccess("[\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestToで叩かれるエンドポイントを指定して、andRespondで返したいレスポンスを渡す。仮にrequestToの値が間違っていればテストが落ちてくれる。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
refs: #2
リポジトリを登録するときに自分のリポジトリ一覧が見れる必要がある。
GitHubからリポジトリの一覧を持ってこれるようにした。