{"action":"created","comment":{"url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/comments/89953700","pull_request_review_id":10477111,"id":89953700,"diff_hunk":"@@ -1,14 +1,146 @@\n package interndiary.service\n \n import interndiary.helper._\n-import org.joda.time.LocalDateTime\n \n import scala.util.Random\n+import org.joda.time.DateTimeUtils\n \n class DiaryAppSpec extends UnitSpec with SetupDB {\n+  private def createApp(): DiaryApp = new DiaryApp(Random.nextInt().toString)\n+\n+  def mockTime[T](innerMillis: Long)(block: => T): T = {\n+    DateTimeUtils.setCurrentMillisFixed(innerMillis)\n+    try {\n+      block\n+    } finally {\n+      DateTimeUtils.setCurrentMillisSystem()\n+    }\n+  }\n+\n+\n   describe(\"DiaryApp\") {\n-    it(\"should be DiaryApp\") {\n-      \"DiaryApp\" shouldBe \"DiaryApp\"\n+    it(\"should be able to write and read\") {\n+      val app = createApp()\n+      app.write(\"Test title\",\"This is unit test.\").fold(\n+        { _ => fail() },\n+        { entry =>\n+          entry.userId shouldBe app.currentUser.id\n+          entry.title shouldBe \"Test title\"\n+          entry.body shouldBe \"This is unit test.\"\n+        }\n+      )\n+      app.read(app.currentUser.name).fold(\n+        { _ => fail() },\n+        { entries =>\n+          entries.length shouldBe 1\n+          entries.head.title shouldBe \"Test title\"\n+          entries.head.body shouldBe \"This is unit test.\"\n+        }\n+      )\n+      app.write(\"2nd entry\",\"I won't see bugs anymore.\").fold(\n+        { _ => fail() },\n+        { entry =>\n+          entry.title shouldBe \"2nd entry\"\n+          entry.body shouldBe \"I won't see bugs anymore.\"\n+        }\n+      )\n+      app.read(app.currentUser.name).fold(\n+        { _ => fail() },\n+        { entries =>\n+          entries.length shouldBe 2\n+          entries.head.title shouldBe \"2nd entry\"\n+          entries(1).body shouldBe \"This is unit test.\"\n+        }\n+      )\n+    }\n+\n+    it(\"should be able to delete\") {\n+      val app = createApp()\n+      val entry0 = mockTime(1400000000000L){\n+        app.write(\"Test title\",\"This is unit test.\").right.get\n+      }\n+      val entry3 = mockTime(1430000000000L){\n+        app.write(\"4th entry\",\"tired.\").right.get\n+      }\n+      val entry2 = mockTime(1420000000000L){\n+        app.write(\"3rd entry\",\"I will delete all bugs.\").right.get\n+      }\n+      val entry1 = mockTime(1410000000000L){\n+        app.write(\"2nd entry\",\"I won't see bugs anymore.\").right.get\n+      }\n+      print(app.read(app.currentUser.name))\n+      app.read(app.currentUser.name).fold(\n+        { _ => fail() },\n+        { entries =>\n+          entries.length shouldBe 4\n+          entries(0) shouldBe entry3\n+          entries(1) shouldBe entry2\n+          entries(2) shouldBe entry1\n+        }\n+      )\n+      app.delete(entry1.id)\n+      app.read(app.currentUser.name).fold(\n+        { _ => fail() },\n+        { entries =>\n+          entries.length shouldBe 3\n+          entries(0) shouldBe entry3\n+          entries(2) shouldBe entry0\n+        }\n+      )\n+      app.delete(entry3.id)\n+      app.read(app.currentUser.name).fold(\n+        { _ => fail() },\n+        { entries =>\n+          entries.length shouldBe 2\n+          entries(0) shouldBe entry2\n+          entries(1) shouldBe entry0\n+        }\n+      )\n+    }\n+\n+    it(\"should be able to delete2\") {","path":"src/test/scala/interndiary/service/DiaryAppSpec.scala","position":104,"original_position":104,"commit_id":"ad6f862fe76ecd8aaae6dfc74259adaea40ccfbd","original_commit_id":"ad6f862fe76ecd8aaae6dfc74259adaea40ccfbd","user":{"login":"windymelt","id":1113940,"avatar_url":"https://avatars.githubusercontent.com/u/1113940?v=3","gravatar_id":"","url":"https://api.github.com/users/windymelt","html_url":"https://github.com/windymelt","followers_url":"https://api.github.com/users/windymelt/followers","following_url":"https://api.github.com/users/windymelt/following{/other_user}","gists_url":"https://api.github.com/users/windymelt/gists{/gist_id}","starred_url":"https://api.github.com/users/windymelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windymelt/subscriptions","organizations_url":"https://api.github.com/users/windymelt/orgs","repos_url":"https://api.github.com/users/windymelt/repos","events_url":"https://api.github.com/users/windymelt/events{/privacy}","received_events_url":"https://api.github.com/users/windymelt/received_events","type":"User","site_admin":false},"body":"[SHOULD] アプリケーションのどういった性質を確かめたいのか，もうちょっと具体的な名前をつけてほしいです．(テストは単調な繰り返しになりがちで，意図がわからなくなることもしばしばです．)","created_at":"2016-11-29T07:34:40Z","updated_at":"2016-11-29T07:35:54Z","html_url":"https://github.com/siotouto/scala-Intern-Diary/pull/2#discussion_r89953700","pull_request_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/comments/89953700"},"html":{"href":"https://github.com/siotouto/scala-Intern-Diary/pull/2#discussion_r89953700"},"pull_request":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2","id":95635075,"html_url":"https://github.com/siotouto/scala-Intern-Diary/pull/2","diff_url":"https://github.com/siotouto/scala-Intern-Diary/pull/2.diff","patch_url":"https://github.com/siotouto/scala-Intern-Diary/pull/2.patch","issue_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/2","number":2,"state":"open","locked":false,"title":"Ex2","user":{"login":"siotouto","id":7277510,"avatar_url":"https://avatars.githubusercontent.com/u/7277510?v=3","gravatar_id":"","url":"https://api.github.com/users/siotouto","html_url":"https://github.com/siotouto","followers_url":"https://api.github.com/users/siotouto/followers","following_url":"https://api.github.com/users/siotouto/following{/other_user}","gists_url":"https://api.github.com/users/siotouto/gists{/gist_id}","starred_url":"https://api.github.com/users/siotouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siotouto/subscriptions","organizations_url":"https://api.github.com/users/siotouto/orgs","repos_url":"https://api.github.com/users/siotouto/repos","events_url":"https://api.github.com/users/siotouto/events{/privacy}","received_events_url":"https://api.github.com/users/siotouto/received_events","type":"User","site_admin":false},"body":"コメントを投稿できる機能は投稿までしか出来ていないため、テストしていません。\r\n\r\nhttps://github.com/hatena/Hatena-Textbook/blob/master/database-programming-scala.md#課題2","created_at":"2016-11-29T06:45:01Z","updated_at":"2016-11-29T07:35:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a29502a462cc964213fbb2f58c6f72d52122b6e6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2/commits","review_comments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2/comments","review_comment_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/2/comments","statuses_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/statuses/ad6f862fe76ecd8aaae6dfc74259adaea40ccfbd","head":{"label":"siotouto:Ex2","ref":"Ex2","sha":"ad6f862fe76ecd8aaae6dfc74259adaea40ccfbd","user":{"login":"siotouto","id":7277510,"avatar_url":"https://avatars.githubusercontent.com/u/7277510?v=3","gravatar_id":"","url":"https://api.github.com/users/siotouto","html_url":"https://github.com/siotouto","followers_url":"https://api.github.com/users/siotouto/followers","following_url":"https://api.github.com/users/siotouto/following{/other_user}","gists_url":"https://api.github.com/users/siotouto/gists{/gist_id}","starred_url":"https://api.github.com/users/siotouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siotouto/subscriptions","organizations_url":"https://api.github.com/users/siotouto/orgs","repos_url":"https://api.github.com/users/siotouto/repos","events_url":"https://api.github.com/users/siotouto/events{/privacy}","received_events_url":"https://api.github.com/users/siotouto/received_events","type":"User","site_admin":false},"repo":{"id":73903352,"name":"scala-Intern-Diary","full_name":"siotouto/scala-Intern-Diary","owner":{"login":"siotouto","id":7277510,"avatar_url":"https://avatars.githubusercontent.com/u/7277510?v=3","gravatar_id":"","url":"https://api.github.com/users/siotouto","html_url":"https://github.com/siotouto","followers_url":"https://api.github.com/users/siotouto/followers","following_url":"https://api.github.com/users/siotouto/following{/other_user}","gists_url":"https://api.github.com/users/siotouto/gists{/gist_id}","starred_url":"https://api.github.com/users/siotouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siotouto/subscriptions","organizations_url":"https://api.github.com/users/siotouto/orgs","repos_url":"https://api.github.com/users/siotouto/repos","events_url":"https://api.github.com/users/siotouto/events{/privacy}","received_events_url":"https://api.github.com/users/siotouto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/siotouto/scala-Intern-Diary","description":"はてな教科書課題ひな形","fork":true,"url":"https://api.github.com/repos/siotouto/scala-Intern-Diary","forks_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/forks","keys_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/teams","hooks_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/hooks","issue_events_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/events{/number}","events_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/events","assignees_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/assignees{/user}","branches_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/branches{/branch}","tags_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/tags","blobs_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/refs{/sha}","trees_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/statuses/{sha}","languages_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/languages","stargazers_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/stargazers","contributors_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/contributors","subscribers_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/subscribers","subscription_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/subscription","commits_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/commits{/sha}","git_commits_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/commits{/sha}","comments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/comments{/number}","issue_comment_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/comments{/number}","contents_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/contents/{+path}","compare_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/merges","archive_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/downloads","issues_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues{/number}","pulls_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls{/number}","milestones_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/milestones{/number}","notifications_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/labels{/name}","releases_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/releases{/id}","deployments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/deployments","created_at":"2016-11-16T09:14:55Z","updated_at":"2016-11-16T09:14:57Z","pushed_at":"2016-11-29T06:45:01Z","git_url":"git://github.com/siotouto/scala-Intern-Diary.git","ssh_url":"git@github.com:siotouto/scala-Intern-Diary.git","clone_url":"https://github.com/siotouto/scala-Intern-Diary.git","svn_url":"https://github.com/siotouto/scala-Intern-Diary","homepage":"https://github.com/hatena/Hatena-Textbook","size":37,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"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":"siotouto:master","ref":"master","sha":"ca7f3f9989e161d4e4cdf1616748b93f1078ae4c","user":{"login":"siotouto","id":7277510,"avatar_url":"https://avatars.githubusercontent.com/u/7277510?v=3","gravatar_id":"","url":"https://api.github.com/users/siotouto","html_url":"https://github.com/siotouto","followers_url":"https://api.github.com/users/siotouto/followers","following_url":"https://api.github.com/users/siotouto/following{/other_user}","gists_url":"https://api.github.com/users/siotouto/gists{/gist_id}","starred_url":"https://api.github.com/users/siotouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siotouto/subscriptions","organizations_url":"https://api.github.com/users/siotouto/orgs","repos_url":"https://api.github.com/users/siotouto/repos","events_url":"https://api.github.com/users/siotouto/events{/privacy}","received_events_url":"https://api.github.com/users/siotouto/received_events","type":"User","site_admin":false},"repo":{"id":73903352,"name":"scala-Intern-Diary","full_name":"siotouto/scala-Intern-Diary","owner":{"login":"siotouto","id":7277510,"avatar_url":"https://avatars.githubusercontent.com/u/7277510?v=3","gravatar_id":"","url":"https://api.github.com/users/siotouto","html_url":"https://github.com/siotouto","followers_url":"https://api.github.com/users/siotouto/followers","following_url":"https://api.github.com/users/siotouto/following{/other_user}","gists_url":"https://api.github.com/users/siotouto/gists{/gist_id}","starred_url":"https://api.github.com/users/siotouto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siotouto/subscriptions","organizations_url":"https://api.github.com/users/siotouto/orgs","repos_url":"https://api.github.com/users/siotouto/repos","events_url":"https://api.github.com/users/siotouto/events{/privacy}","received_events_url":"https://api.github.com/users/siotouto/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/siotouto/scala-Intern-Diary","description":"はてな教科書課題ひな形","fork":true,"url":"https://api.github.com/repos/siotouto/scala-Intern-Diary","forks_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/forks","keys_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/teams","hooks_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/hooks","issue_events_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/events{/number}","events_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/events","assignees_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/assignees{/user}","branches_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/branches{/branch}","tags_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/tags","blobs_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/refs{/sha}","trees_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/statuses/{sha}","languages_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/languages","stargazers_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/stargazers","contributors_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/contributors","subscribers_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/subscribers","subscription_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/subscription","commits_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/commits{/sha}","git_commits_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/git/commits{/sha}","comments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/comments{/number}","issue_comment_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/comments{/number}","contents_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/contents/{+path}","compare_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/merges","archive_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/downloads","issues_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues{/number}","pulls_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls{/number}","milestones_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/milestones{/number}","notifications_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/labels{/name}","releases_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/releases{/id}","deployments_url":"https://api.github.com/repos/siotouto/scala-Intern-Diary/deployments","created_at":"2016-11-16T09:14:55Z","updated_at":"2016-11-16T09:14:57Z","pushed_at":"2016-11-29T06:45:01Z","git_url":"git://github.com/siotouto/scala-Intern-Diary.git","ssh_url":"git@github.com:siotouto/scala-Intern-Diary.git","clone_url":"https://github.com/siotouto/scala-Intern-Diary.git","svn_url":"https://github.com/siotouto/scala-Intern-Diary","homepage":"https://github.com/hatena/Hatena-Textbook","size":37,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"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/siotouto/scala-Intern-Diary/pulls/2"},"html":{"href":"https://github.com/siotouto/scala-Intern-Diary/pull/2"},"issue":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/2"},"comments":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/siotouto/scala-Intern-Diary/statuses/ad6f862fe76ecd8aaae6dfc74259adaea40ccfbd"}}}}
{"actor":{"display_login":"windymelt"}}