{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/comments/31121551","id":31121551,"diff_hunk":"@@ -0,0 +1,45 @@\n+package org.broadinstitute.dsde.vault.services.mock\n+\n+import org.broadinstitute.dsde.vault.model.Analysis\n+import org.broadinstitute.dsde.vault.model.AnalysisJsonProtocol._\n+import org.mockserver.mock.action.ExpectationCallback\n+import org.mockserver.model.Header.header\n+import org.mockserver.model.HttpResponse.{notFoundResponse, response}\n+import org.mockserver.model.{HttpRequest, HttpResponse, HttpStatusCode}\n+import spray.json._\n+\n+class AnalysisUpdateSwitchCallback extends ExpectationCallback {\n+\n+  def createResponse(analysis: Analysis): HttpResponse = {\n+    println(\"\\nRESPONSE : \" + analysis.toJson.prettyPrint)\n+    response()\n+      .withStatusCode(HttpStatusCode.OK_200.code())\n+      .withHeaders(\n+        header(\"Content-Type\", \"application/json\")\n+      )\n+      .withBody(analysis.toJson.prettyPrint)\n+  }\n+\n+  override def handle(httpRequest: HttpRequest): HttpResponse = {\n+\n+    println(\"\\n\" + httpRequest.getMethod + \" : \" + httpRequest.getPath)\n+\n+    if(httpRequest.getPath.endsWith(\"/analyses\")){\n+      AnalysesResponseContainer.setEmptyResponse()\n+      return createResponse(AnalysesResponseContainer.emptyAnalysis)\n+    }\n+\n+    if(httpRequest.getPath.endsWith(\"/analyses/9b66665c-f41a-11e4-b9b2-1697f925ec7b\")) {\n+      return createResponse(AnalysesResponseContainer.responseAnalysis)\n+    } else if(httpRequest.getPath.endsWith(\"9b66665c-f41a-11e4-b9b2-1697f925ec7b/outputs\")) {\n+      AnalysesResponseContainer.setUpdatedResponse()\n+      return createResponse(AnalysesResponseContainer.responseAnalysis)\n+    } else {\n+      return notFoundResponse()\n+    }\n+","path":"src/test/scala/org/broadinstitute/dsde/vault/services/mock/AnalysisUpdateSwitchCallback.scala","position":40,"original_position":40,"commit_id":"9c2375c5631c998a79d5eef22d7bfcfd29c0581f","original_commit_id":"9c2375c5631c998a79d5eef22d7bfcfd29c0581f","user":{"login":"rushtong","id":116679,"avatar_url":"https://avatars.githubusercontent.com/u/116679?v=3","gravatar_id":"","url":"https://api.github.com/users/rushtong","html_url":"https://github.com/rushtong","followers_url":"https://api.github.com/users/rushtong/followers","following_url":"https://api.github.com/users/rushtong/following{/other_user}","gists_url":"https://api.github.com/users/rushtong/gists{/gist_id}","starred_url":"https://api.github.com/users/rushtong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rushtong/subscriptions","organizations_url":"https://api.github.com/users/rushtong/orgs","repos_url":"https://api.github.com/users/rushtong/repos","events_url":"https://api.github.com/users/rushtong/events{/privacy}","received_events_url":"https://api.github.com/users/rushtong/received_events","type":"User","site_admin":false},"body":"It is more idiomatic in scala to use case statements in place of the if conditions here. Something like this:\r\n\r\n```\r\n    httpRequest match {\r\n      case request if request.getPath.endsWith(\"/analyses\") =>\r\n        AnalysesResponseContainer.setEmptyResponse()\r\n        createResponse(AnalysesResponseContainer.emptyAnalysis)\r\n      case request if request.getPath.endsWith(\"/analyses/9b66665c-f41a-11e4-b9b2-1697f925ec7b\") =>\r\n        createResponse(AnalysesResponseContainer.responseAnalysis)\r\n      case request if request.getPath.endsWith(\"9b66665c-f41a-11e4-b9b2-1697f925ec7b/outputs\") =>\r\n        AnalysesResponseContainer.setUpdatedResponse()\r\n        createResponse(AnalysesResponseContainer.responseAnalysis)\r\n      case _ => notFoundResponse()\r\n    }\r\n```","created_at":"2015-05-27T10:49:22Z","updated_at":"2015-05-27T10:49:22Z","html_url":"https://github.com/broadinstitute/vault-api/pull/48#discussion_r31121551","pull_request_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/comments/31121551"},"html":{"href":"https://github.com/broadinstitute/vault-api/pull/48#discussion_r31121551"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48","id":33474508,"html_url":"https://github.com/broadinstitute/vault-api/pull/48","diff_url":"https://github.com/broadinstitute/vault-api/pull/48.diff","patch_url":"https://github.com/broadinstitute/vault-api/pull/48.patch","issue_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/48","number":48,"state":"open","locked":false,"title":"Mock services for Unit Tests","user":{"login":"aracioppibroad","id":11407995,"avatar_url":"https://avatars.githubusercontent.com/u/11407995?v=3","gravatar_id":"","url":"https://api.github.com/users/aracioppibroad","html_url":"https://github.com/aracioppibroad","followers_url":"https://api.github.com/users/aracioppibroad/followers","following_url":"https://api.github.com/users/aracioppibroad/following{/other_user}","gists_url":"https://api.github.com/users/aracioppibroad/gists{/gist_id}","starred_url":"https://api.github.com/users/aracioppibroad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aracioppibroad/subscriptions","organizations_url":"https://api.github.com/users/aracioppibroad/orgs","repos_url":"https://api.github.com/users/aracioppibroad/repos","events_url":"https://api.github.com/users/aracioppibroad/events{/privacy}","received_events_url":"https://api.github.com/users/aracioppibroad/received_events","type":"User","site_admin":false},"body":"Created MockServers and included a testing.conf file","created_at":"2015-04-16T17:37:03Z","updated_at":"2015-05-27T10:49:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6247d122ced8a4583903031a88c8ddc3e7920c6","assignee":{"login":"rushtong","id":116679,"avatar_url":"https://avatars.githubusercontent.com/u/116679?v=3","gravatar_id":"","url":"https://api.github.com/users/rushtong","html_url":"https://github.com/rushtong","followers_url":"https://api.github.com/users/rushtong/followers","following_url":"https://api.github.com/users/rushtong/following{/other_user}","gists_url":"https://api.github.com/users/rushtong/gists{/gist_id}","starred_url":"https://api.github.com/users/rushtong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rushtong/subscriptions","organizations_url":"https://api.github.com/users/rushtong/orgs","repos_url":"https://api.github.com/users/rushtong/repos","events_url":"https://api.github.com/users/rushtong/events{/privacy}","received_events_url":"https://api.github.com/users/rushtong/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/48/comments","statuses_url":"https://api.github.com/repos/broadinstitute/vault-api/statuses/9c2375c5631c998a79d5eef22d7bfcfd29c0581f","head":{"label":"broadinstitute:ar_mockServer","ref":"ar_mockServer","sha":"9c2375c5631c998a79d5eef22d7bfcfd29c0581f","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":30926361,"name":"vault-api","full_name":"broadinstitute/vault-api","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/vault-api","description":"Vault Orchestration Service","fork":false,"url":"https://api.github.com/repos/broadinstitute/vault-api","forks_url":"https://api.github.com/repos/broadinstitute/vault-api/forks","keys_url":"https://api.github.com/repos/broadinstitute/vault-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/vault-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/vault-api/teams","hooks_url":"https://api.github.com/repos/broadinstitute/vault-api/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/vault-api/events","assignees_url":"https://api.github.com/repos/broadinstitute/vault-api/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/vault-api/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/vault-api/tags","blobs_url":"https://api.github.com/repos/broadinstitute/vault-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/vault-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/vault-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/vault-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/vault-api/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/vault-api/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/vault-api/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/vault-api/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/vault-api/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/vault-api/subscription","commits_url":"https://api.github.com/repos/broadinstitute/vault-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/vault-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/vault-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/vault-api/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/vault-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/vault-api/merges","archive_url":"https://api.github.com/repos/broadinstitute/vault-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/vault-api/downloads","issues_url":"https://api.github.com/repos/broadinstitute/vault-api/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/vault-api/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/vault-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/vault-api/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/vault-api/releases{/id}","created_at":"2015-02-17T16:41:31Z","updated_at":"2015-05-08T18:30:44Z","pushed_at":"2015-05-26T20:24:21Z","git_url":"git://github.com/broadinstitute/vault-api.git","ssh_url":"git@github.com:broadinstitute/vault-api.git","clone_url":"https://github.com/broadinstitute/vault-api.git","svn_url":"https://github.com/broadinstitute/vault-api","homepage":null,"size":2583,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"develop"}},"base":{"label":"broadinstitute:develop","ref":"develop","sha":"62af3a6b83e99ddcb3f77548b9785a7a623c946a","user":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"repo":{"id":30926361,"name":"vault-api","full_name":"broadinstitute/vault-api","owner":{"login":"broadinstitute","id":393552,"avatar_url":"https://avatars.githubusercontent.com/u/393552?v=3","gravatar_id":"","url":"https://api.github.com/users/broadinstitute","html_url":"https://github.com/broadinstitute","followers_url":"https://api.github.com/users/broadinstitute/followers","following_url":"https://api.github.com/users/broadinstitute/following{/other_user}","gists_url":"https://api.github.com/users/broadinstitute/gists{/gist_id}","starred_url":"https://api.github.com/users/broadinstitute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broadinstitute/subscriptions","organizations_url":"https://api.github.com/users/broadinstitute/orgs","repos_url":"https://api.github.com/users/broadinstitute/repos","events_url":"https://api.github.com/users/broadinstitute/events{/privacy}","received_events_url":"https://api.github.com/users/broadinstitute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/broadinstitute/vault-api","description":"Vault Orchestration Service","fork":false,"url":"https://api.github.com/repos/broadinstitute/vault-api","forks_url":"https://api.github.com/repos/broadinstitute/vault-api/forks","keys_url":"https://api.github.com/repos/broadinstitute/vault-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/vault-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/vault-api/teams","hooks_url":"https://api.github.com/repos/broadinstitute/vault-api/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/vault-api/events","assignees_url":"https://api.github.com/repos/broadinstitute/vault-api/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/vault-api/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/vault-api/tags","blobs_url":"https://api.github.com/repos/broadinstitute/vault-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/vault-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/vault-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/vault-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/vault-api/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/vault-api/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/vault-api/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/vault-api/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/vault-api/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/vault-api/subscription","commits_url":"https://api.github.com/repos/broadinstitute/vault-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/vault-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/vault-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/vault-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/vault-api/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/vault-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/vault-api/merges","archive_url":"https://api.github.com/repos/broadinstitute/vault-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/vault-api/downloads","issues_url":"https://api.github.com/repos/broadinstitute/vault-api/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/vault-api/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/vault-api/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/vault-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/vault-api/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/vault-api/releases{/id}","created_at":"2015-02-17T16:41:31Z","updated_at":"2015-05-08T18:30:44Z","pushed_at":"2015-05-26T20:24:21Z","git_url":"git://github.com/broadinstitute/vault-api.git","ssh_url":"git@github.com:broadinstitute/vault-api.git","clone_url":"https://github.com/broadinstitute/vault-api.git","svn_url":"https://github.com/broadinstitute/vault-api","homepage":null,"size":2583,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48"},"html":{"href":"https://github.com/broadinstitute/vault-api/pull/48"},"issue":{"href":"https://api.github.com/repos/broadinstitute/vault-api/issues/48"},"comments":{"href":"https://api.github.com/repos/broadinstitute/vault-api/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/vault-api/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/vault-api/statuses/9c2375c5631c998a79d5eef22d7bfcfd29c0581f"}}}}