{"action":"created","comment":{"url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/comments/43745236","id":43745236,"diff_hunk":"@@ -0,0 +1,51 @@\n+public class EchoServer {\n+\n+    public static final String PROMPT = \"Type something ('exit' to quit)\";\n+    private Console console;\n+\n+    public EchoServer(Console console) {\n+        this.console = console;\n+    }\n+\n+    public static void main(String[] args) {\n+        EchoServer echoServer = new EchoServer(new EchoConsole(System.in, System.out));\n+        echoServer.run();\n+    }\n+\n+    public void run() {\n+        String message = \"\";\n+\n+        do {\n+            message = printUserInput();\n+        } while (!userTypedExit(message));\n+    }\n+\n+    public String printUserInput() {\n+        String message = promptForInput();\n+        setOutput(message);\n+        return message;\n+    }\n+\n+    private void promptUser() {\n+        console.write(PROMPT);\n+    }\n+\n+    private String getInput() {\n+        return console.read();\n+    }\n+\n+    public String promptForInput() {\n+        promptUser();\n+        return getInput();\n+    }\n+\n+    public void setOutput(String message) {","path":"src/EchoServer.java","position":42,"original_position":42,"commit_id":"5443028220ca0e12f65c86554da11aeb623de8ba","original_commit_id":"5443028220ca0e12f65c86554da11aeb623de8ba","user":{"login":"jsuchy","id":6295,"avatar_url":"https://avatars.githubusercontent.com/u/6295?v=3","gravatar_id":"","url":"https://api.github.com/users/jsuchy","html_url":"https://github.com/jsuchy","followers_url":"https://api.github.com/users/jsuchy/followers","following_url":"https://api.github.com/users/jsuchy/following{/other_user}","gists_url":"https://api.github.com/users/jsuchy/gists{/gist_id}","starred_url":"https://api.github.com/users/jsuchy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsuchy/subscriptions","organizations_url":"https://api.github.com/users/jsuchy/orgs","repos_url":"https://api.github.com/users/jsuchy/repos","events_url":"https://api.github.com/users/jsuchy/events{/privacy}","received_events_url":"https://api.github.com/users/jsuchy/received_events","type":"User","site_admin":false},"body":"The name of this method is a little weird. You're not actually setting the output (i.e., this.output = message;) but you're writing message to the console.","created_at":"2015-11-03T13:14:12Z","updated_at":"2015-11-03T13:14:12Z","html_url":"https://github.com/me-stevens/EchoServer/pull/2#discussion_r43745236","pull_request_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/comments/43745236"},"html":{"href":"https://github.com/me-stevens/EchoServer/pull/2#discussion_r43745236"},"pull_request":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2","id":49552814,"html_url":"https://github.com/me-stevens/EchoServer/pull/2","diff_url":"https://github.com/me-stevens/EchoServer/pull/2.diff","patch_url":"https://github.com/me-stevens/EchoServer/pull/2.patch","issue_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/2","number":2,"state":"open","locked":false,"title":"Rewrite the EchoServer and EchoServerTest classes.","user":{"login":"me-stevens","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/me-stevens","html_url":"https://github.com/me-stevens","followers_url":"https://api.github.com/users/me-stevens/followers","following_url":"https://api.github.com/users/me-stevens/following{/other_user}","gists_url":"https://api.github.com/users/me-stevens/gists{/gist_id}","starred_url":"https://api.github.com/users/me-stevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/me-stevens/subscriptions","organizations_url":"https://api.github.com/users/me-stevens/orgs","repos_url":"https://api.github.com/users/me-stevens/repos","events_url":"https://api.github.com/users/me-stevens/events{/privacy}","received_events_url":"https://api.github.com/users/me-stevens/received_events","type":"User","site_admin":false},"body":"Wiped out the previous code for the `EchoServer` and `EchoServerTest` and started over again.\r\n\r\nChanges:\r\n* I have now a `promptForInput()` method that writes a message and reads a user input, and a test for it, `userInputIsRead()`, that checks the input was read.\r\n* I also have a `setOutput()` method and a test `anyMessageIsPrinted()` that checks that the `write()` method was called and that the message was recorded when we call `setOutput()`.\r\n* I extracted the behaviour for each loop in `printUserInput()`, which calls the `promptForInput()` and `setOutput()` methods, and two tests, `userInputIsPrinted()` and `ifUserTypesExitNothingIsPrinted()` to check that method.\r\n* I moved the check for \"exit\" to `setOutput()`, and made a method for the condition, `userTypedExit()`.\r\n* The loop calls `printUserInput()` in every loop and checks the user input. I think this is still a bit of repetition because in the `setOutput()` method we are doing the check again. The test for this is `readsSeveralInputs()`, for which I added an overload of the `userInput()` method, and left both to keep  the previous tests simple and readable.\r\n\r\nIt's hard to TDD! :smile: ","created_at":"2015-11-03T13:06:49Z","updated_at":"2015-11-03T13:14:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2860e7cf30867efa6dff5fe317df11070e7dd2c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2/commits","review_comments_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2/comments","review_comment_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/2/comments","statuses_url":"https://api.github.com/repos/me-stevens/EchoServer/statuses/5443028220ca0e12f65c86554da11aeb623de8ba","head":{"label":"me-stevens:separateBehaviours","ref":"separateBehaviours","sha":"5443028220ca0e12f65c86554da11aeb623de8ba","user":{"login":"me-stevens","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/me-stevens","html_url":"https://github.com/me-stevens","followers_url":"https://api.github.com/users/me-stevens/followers","following_url":"https://api.github.com/users/me-stevens/following{/other_user}","gists_url":"https://api.github.com/users/me-stevens/gists{/gist_id}","starred_url":"https://api.github.com/users/me-stevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/me-stevens/subscriptions","organizations_url":"https://api.github.com/users/me-stevens/orgs","repos_url":"https://api.github.com/users/me-stevens/repos","events_url":"https://api.github.com/users/me-stevens/events{/privacy}","received_events_url":"https://api.github.com/users/me-stevens/received_events","type":"User","site_admin":false},"repo":{"id":45203212,"name":"EchoServer","full_name":"me-stevens/EchoServer","owner":{"login":"me-stevens","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/me-stevens","html_url":"https://github.com/me-stevens","followers_url":"https://api.github.com/users/me-stevens/followers","following_url":"https://api.github.com/users/me-stevens/following{/other_user}","gists_url":"https://api.github.com/users/me-stevens/gists{/gist_id}","starred_url":"https://api.github.com/users/me-stevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/me-stevens/subscriptions","organizations_url":"https://api.github.com/users/me-stevens/orgs","repos_url":"https://api.github.com/users/me-stevens/repos","events_url":"https://api.github.com/users/me-stevens/events{/privacy}","received_events_url":"https://api.github.com/users/me-stevens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/me-stevens/EchoServer","description":"Implements a spy class to be used as a test double for a program that speaks to the console.","fork":false,"url":"https://api.github.com/repos/me-stevens/EchoServer","forks_url":"https://api.github.com/repos/me-stevens/EchoServer/forks","keys_url":"https://api.github.com/repos/me-stevens/EchoServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/me-stevens/EchoServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/me-stevens/EchoServer/teams","hooks_url":"https://api.github.com/repos/me-stevens/EchoServer/hooks","issue_events_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/events{/number}","events_url":"https://api.github.com/repos/me-stevens/EchoServer/events","assignees_url":"https://api.github.com/repos/me-stevens/EchoServer/assignees{/user}","branches_url":"https://api.github.com/repos/me-stevens/EchoServer/branches{/branch}","tags_url":"https://api.github.com/repos/me-stevens/EchoServer/tags","blobs_url":"https://api.github.com/repos/me-stevens/EchoServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/me-stevens/EchoServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/me-stevens/EchoServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/me-stevens/EchoServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/me-stevens/EchoServer/statuses/{sha}","languages_url":"https://api.github.com/repos/me-stevens/EchoServer/languages","stargazers_url":"https://api.github.com/repos/me-stevens/EchoServer/stargazers","contributors_url":"https://api.github.com/repos/me-stevens/EchoServer/contributors","subscribers_url":"https://api.github.com/repos/me-stevens/EchoServer/subscribers","subscription_url":"https://api.github.com/repos/me-stevens/EchoServer/subscription","commits_url":"https://api.github.com/repos/me-stevens/EchoServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/me-stevens/EchoServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/me-stevens/EchoServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/comments{/number}","contents_url":"https://api.github.com/repos/me-stevens/EchoServer/contents/{+path}","compare_url":"https://api.github.com/repos/me-stevens/EchoServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/me-stevens/EchoServer/merges","archive_url":"https://api.github.com/repos/me-stevens/EchoServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/me-stevens/EchoServer/downloads","issues_url":"https://api.github.com/repos/me-stevens/EchoServer/issues{/number}","pulls_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls{/number}","milestones_url":"https://api.github.com/repos/me-stevens/EchoServer/milestones{/number}","notifications_url":"https://api.github.com/repos/me-stevens/EchoServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/me-stevens/EchoServer/labels{/name}","releases_url":"https://api.github.com/repos/me-stevens/EchoServer/releases{/id}","created_at":"2015-10-29T18:39:24Z","updated_at":"2015-10-29T21:08:08Z","pushed_at":"2015-11-03T13:06:51Z","git_url":"git://github.com/me-stevens/EchoServer.git","ssh_url":"git@github.com:me-stevens/EchoServer.git","clone_url":"https://github.com/me-stevens/EchoServer.git","svn_url":"https://github.com/me-stevens/EchoServer","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"me-stevens:master","ref":"master","sha":"2fd390b4cb6c54e1f9574ffdf6b4e30501212b4a","user":{"login":"me-stevens","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/me-stevens","html_url":"https://github.com/me-stevens","followers_url":"https://api.github.com/users/me-stevens/followers","following_url":"https://api.github.com/users/me-stevens/following{/other_user}","gists_url":"https://api.github.com/users/me-stevens/gists{/gist_id}","starred_url":"https://api.github.com/users/me-stevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/me-stevens/subscriptions","organizations_url":"https://api.github.com/users/me-stevens/orgs","repos_url":"https://api.github.com/users/me-stevens/repos","events_url":"https://api.github.com/users/me-stevens/events{/privacy}","received_events_url":"https://api.github.com/users/me-stevens/received_events","type":"User","site_admin":false},"repo":{"id":45203212,"name":"EchoServer","full_name":"me-stevens/EchoServer","owner":{"login":"me-stevens","id":2157089,"avatar_url":"https://avatars.githubusercontent.com/u/2157089?v=3","gravatar_id":"","url":"https://api.github.com/users/me-stevens","html_url":"https://github.com/me-stevens","followers_url":"https://api.github.com/users/me-stevens/followers","following_url":"https://api.github.com/users/me-stevens/following{/other_user}","gists_url":"https://api.github.com/users/me-stevens/gists{/gist_id}","starred_url":"https://api.github.com/users/me-stevens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/me-stevens/subscriptions","organizations_url":"https://api.github.com/users/me-stevens/orgs","repos_url":"https://api.github.com/users/me-stevens/repos","events_url":"https://api.github.com/users/me-stevens/events{/privacy}","received_events_url":"https://api.github.com/users/me-stevens/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/me-stevens/EchoServer","description":"Implements a spy class to be used as a test double for a program that speaks to the console.","fork":false,"url":"https://api.github.com/repos/me-stevens/EchoServer","forks_url":"https://api.github.com/repos/me-stevens/EchoServer/forks","keys_url":"https://api.github.com/repos/me-stevens/EchoServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/me-stevens/EchoServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/me-stevens/EchoServer/teams","hooks_url":"https://api.github.com/repos/me-stevens/EchoServer/hooks","issue_events_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/events{/number}","events_url":"https://api.github.com/repos/me-stevens/EchoServer/events","assignees_url":"https://api.github.com/repos/me-stevens/EchoServer/assignees{/user}","branches_url":"https://api.github.com/repos/me-stevens/EchoServer/branches{/branch}","tags_url":"https://api.github.com/repos/me-stevens/EchoServer/tags","blobs_url":"https://api.github.com/repos/me-stevens/EchoServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/me-stevens/EchoServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/me-stevens/EchoServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/me-stevens/EchoServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/me-stevens/EchoServer/statuses/{sha}","languages_url":"https://api.github.com/repos/me-stevens/EchoServer/languages","stargazers_url":"https://api.github.com/repos/me-stevens/EchoServer/stargazers","contributors_url":"https://api.github.com/repos/me-stevens/EchoServer/contributors","subscribers_url":"https://api.github.com/repos/me-stevens/EchoServer/subscribers","subscription_url":"https://api.github.com/repos/me-stevens/EchoServer/subscription","commits_url":"https://api.github.com/repos/me-stevens/EchoServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/me-stevens/EchoServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/me-stevens/EchoServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/me-stevens/EchoServer/issues/comments{/number}","contents_url":"https://api.github.com/repos/me-stevens/EchoServer/contents/{+path}","compare_url":"https://api.github.com/repos/me-stevens/EchoServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/me-stevens/EchoServer/merges","archive_url":"https://api.github.com/repos/me-stevens/EchoServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/me-stevens/EchoServer/downloads","issues_url":"https://api.github.com/repos/me-stevens/EchoServer/issues{/number}","pulls_url":"https://api.github.com/repos/me-stevens/EchoServer/pulls{/number}","milestones_url":"https://api.github.com/repos/me-stevens/EchoServer/milestones{/number}","notifications_url":"https://api.github.com/repos/me-stevens/EchoServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/me-stevens/EchoServer/labels{/name}","releases_url":"https://api.github.com/repos/me-stevens/EchoServer/releases{/id}","created_at":"2015-10-29T18:39:24Z","updated_at":"2015-10-29T21:08:08Z","pushed_at":"2015-11-03T13:06:51Z","git_url":"git://github.com/me-stevens/EchoServer.git","ssh_url":"git@github.com:me-stevens/EchoServer.git","clone_url":"https://github.com/me-stevens/EchoServer.git","svn_url":"https://github.com/me-stevens/EchoServer","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2"},"html":{"href":"https://github.com/me-stevens/EchoServer/pull/2"},"issue":{"href":"https://api.github.com/repos/me-stevens/EchoServer/issues/2"},"comments":{"href":"https://api.github.com/repos/me-stevens/EchoServer/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/me-stevens/EchoServer/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/me-stevens/EchoServer/statuses/5443028220ca0e12f65c86554da11aeb623de8ba"}}}}