{"action":"created","comment":{"url":"https://api.github.com/repos/mesosphere/marathon/pulls/comments/141286388","pull_request_review_id":65475722,"id":141286388,"diff_hunk":"@@ -0,0 +1,83 @@\n+package mesosphere.marathon\n+package api.akkahttp\n+\n+import akka.http.scaladsl.model.StatusCodes.NotFound\n+import akka.http.scaladsl.model.{ HttpEntity, StatusCodes, Uri }\n+import akka.http.scaladsl.model.Uri.Path\n+import akka.http.scaladsl.server.PathMatcher.{ Matched, Unmatched }\n+import akka.http.scaladsl.server.Route\n+import akka.http.scaladsl.testkit.ScalatestRouteTest\n+import mesosphere.UnitTest\n+import mesosphere.marathon.state.{ AppDefinition, PathId }\n+import mesosphere.marathon.test.GroupCreation\n+\n+class DirectivesTest extends UnitTest with GroupCreation with ScalatestRouteTest {\n+  import Directives._\n+  import PathId.StringPathId\n+\n+  trait DirectivesTestFixture {\n+    val app1 = AppDefinition(\"/test/group1/app1\".toPath)\n+    val app2 = AppDefinition(\"/test/group2/app2\".toPath)\n+    val rootGroup = createRootGroup(\n+      groups = Set(\n+        createGroup(\"/test\".toPath, groups = Set(\n+          createGroup(\"/test/group1\".toPath, Map(app1.id -> app1)),\n+          createGroup(\"/test/group2\".toPath, Map(app2.id -> app2))\n+        ))))\n+\n+  }\n+\n+  \"extractExistingAppId Directive\" should {\n+    trait ExtractExistingAppFixture extends DirectivesTestFixture {\n+      val rawRoute = extractExistingAppId(rootGroup) { appId =>\n+        get {\n+          complete(appId.toString)\n+        }\n+      }\n+      import akka.http.scaladsl.server._\n+      import EntityMarshallers._\n+\n+      implicit val rejectionHandler = RejectionHandler\n+        .newBuilder\n+        .handle {\n+          case Rejections.EntityNotFound(message) => complete(NotFound -> message)\n+        }\n+        .result()\n+      val route = Route.seal(rawRoute)\n+\n+      def checkRejection(appName: String, expectedRejectionAppName: String = \"\") = {\n+        val appNameInRejection = if (expectedRejectionAppName.isEmpty) appName else expectedRejectionAppName\n+        Get(Uri./.withPath(Path./ ++ Path(appName)), HttpEntity.Empty) ~> route ~> check {\n+          status shouldEqual StatusCodes.NotFound\n+          responseAs[String] should include(s\"App '/$appNameInRejection' does not exist\")\n+        }\n+      }\n+\n+      def checkExtraction(path: String) = {\n+        Get(Uri./.withPath(Path./ ++ Path(path)), HttpEntity.Empty) ~> route ~> check {\n+          status shouldEqual StatusCodes.OK\n+          responseAs[String] shouldEqual s\"/$path\"\n+        }\n+      }\n+    }\n+\n+    \"reject groups\" in new ExtractExistingAppFixture {\n+      checkRejection(\"test/group1\")","path":"src/test/scala/mesosphere/marathon/api/akkahttp/DirectivesTest.scala","position":65,"original_position":65,"commit_id":"91a92d13f8d438011284a57f62b3e4bffa7b9955","original_commit_id":"91a92d13f8d438011284a57f62b3e4bffa7b9955","user":{"login":"meln1k","id":1043441,"avatar_url":"https://avatars1.githubusercontent.com/u/1043441?v=4","gravatar_id":"","url":"https://api.github.com/users/meln1k","html_url":"https://github.com/meln1k","followers_url":"https://api.github.com/users/meln1k/followers","following_url":"https://api.github.com/users/meln1k/following{/other_user}","gists_url":"https://api.github.com/users/meln1k/gists{/gist_id}","starred_url":"https://api.github.com/users/meln1k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meln1k/subscriptions","organizations_url":"https://api.github.com/users/meln1k/orgs","repos_url":"https://api.github.com/users/meln1k/repos","events_url":"https://api.github.com/users/meln1k/events{/privacy}","received_events_url":"https://api.github.com/users/meln1k/received_events","type":"User","site_admin":false},"body":"I'm not sure if we should ignore DRY in tests. Let's discuss it.","created_at":"2017-09-27T09:13:15Z","updated_at":"2017-09-27T09:13:15Z","html_url":"https://github.com/mesosphere/marathon/pull/5532#discussion_r141286388","pull_request_url":"https://api.github.com/repos/mesosphere/marathon/pulls/5532","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/comments/141286388"},"html":{"href":"https://github.com/mesosphere/marathon/pull/5532#discussion_r141286388"},"pull_request":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/5532"}},"in_reply_to_id":141099469},"pull_request":{"url":"https://api.github.com/repos/mesosphere/marathon/pulls/5532","id":143144565,"html_url":"https://github.com/mesosphere/marathon/pull/5532","diff_url":"https://github.com/mesosphere/marathon/pull/5532.diff","patch_url":"https://github.com/mesosphere/marathon/pull/5532.patch","issue_url":"https://api.github.com/repos/mesosphere/marathon/issues/5532","number":5532,"state":"open","locked":false,"title":"Added directive for appId matching","user":{"login":"meln1k","id":1043441,"avatar_url":"https://avatars1.githubusercontent.com/u/1043441?v=4","gravatar_id":"","url":"https://api.github.com/users/meln1k","html_url":"https://github.com/meln1k","followers_url":"https://api.github.com/users/meln1k/followers","following_url":"https://api.github.com/users/meln1k/following{/other_user}","gists_url":"https://api.github.com/users/meln1k/gists{/gist_id}","starred_url":"https://api.github.com/users/meln1k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meln1k/subscriptions","organizations_url":"https://api.github.com/users/meln1k/orgs","repos_url":"https://api.github.com/users/meln1k/repos","events_url":"https://api.github.com/users/meln1k/events{/privacy}","received_events_url":"https://api.github.com/users/meln1k/received_events","type":"User","site_admin":false},"body":"Summary: PathMatchers and Directives for extracting appId\r\n\r\nTest Plan: sbt test\r\n\r\nJIRA issues: MARATHON-7299","created_at":"2017-09-26T14:06:17Z","updated_at":"2017-09-27T09:13:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b2e79cc728c387e0d553649c5220d125264453d","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/mesosphere/marathon/pulls/5532/commits","review_comments_url":"https://api.github.com/repos/mesosphere/marathon/pulls/5532/comments","review_comment_url":"https://api.github.com/repos/mesosphere/marathon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mesosphere/marathon/issues/5532/comments","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/91a92d13f8d438011284a57f62b3e4bffa7b9955","head":{"label":"mesosphere:nm/akka-http-apps-controller-directives-7299","ref":"nm/akka-http-apps-controller-directives-7299","sha":"91a92d13f8d438011284a57f62b3e4bffa7b9955","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars0.githubusercontent.com/u/3458585?v=4","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":10941409,"name":"marathon","full_name":"mesosphere/marathon","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars0.githubusercontent.com/u/3458585?v=4","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon","description":"Deploy and manage containers (including Docker) on top of Apache Mesos at scale.","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon","forks_url":"https://api.github.com/repos/mesosphere/marathon/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/marathon/deployments","created_at":"2013-06-25T14:56:34Z","updated_at":"2017-09-27T08:30:51Z","pushed_at":"2017-09-27T09:11:42Z","git_url":"git://github.com/mesosphere/marathon.git","ssh_url":"git@github.com:mesosphere/marathon.git","clone_url":"https://github.com/mesosphere/marathon.git","svn_url":"https://github.com/mesosphere/marathon","homepage":"https://mesosphere.github.io/marathon/","size":31296,"stargazers_count":3443,"watchers_count":3443,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":795,"mirror_url":null,"open_issues_count":22,"forks":795,"open_issues":22,"watchers":3443,"default_branch":"master"}},"base":{"label":"mesosphere:master","ref":"master","sha":"fd8d1c1e91715d89724964a6677b9177545f71bc","user":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars0.githubusercontent.com/u/3458585?v=4","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"repo":{"id":10941409,"name":"marathon","full_name":"mesosphere/marathon","owner":{"login":"mesosphere","id":3458585,"avatar_url":"https://avatars0.githubusercontent.com/u/3458585?v=4","gravatar_id":"","url":"https://api.github.com/users/mesosphere","html_url":"https://github.com/mesosphere","followers_url":"https://api.github.com/users/mesosphere/followers","following_url":"https://api.github.com/users/mesosphere/following{/other_user}","gists_url":"https://api.github.com/users/mesosphere/gists{/gist_id}","starred_url":"https://api.github.com/users/mesosphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesosphere/subscriptions","organizations_url":"https://api.github.com/users/mesosphere/orgs","repos_url":"https://api.github.com/users/mesosphere/repos","events_url":"https://api.github.com/users/mesosphere/events{/privacy}","received_events_url":"https://api.github.com/users/mesosphere/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mesosphere/marathon","description":"Deploy and manage containers (including Docker) on top of Apache Mesos at scale.","fork":false,"url":"https://api.github.com/repos/mesosphere/marathon","forks_url":"https://api.github.com/repos/mesosphere/marathon/forks","keys_url":"https://api.github.com/repos/mesosphere/marathon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mesosphere/marathon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mesosphere/marathon/teams","hooks_url":"https://api.github.com/repos/mesosphere/marathon/hooks","issue_events_url":"https://api.github.com/repos/mesosphere/marathon/issues/events{/number}","events_url":"https://api.github.com/repos/mesosphere/marathon/events","assignees_url":"https://api.github.com/repos/mesosphere/marathon/assignees{/user}","branches_url":"https://api.github.com/repos/mesosphere/marathon/branches{/branch}","tags_url":"https://api.github.com/repos/mesosphere/marathon/tags","blobs_url":"https://api.github.com/repos/mesosphere/marathon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mesosphere/marathon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mesosphere/marathon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mesosphere/marathon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mesosphere/marathon/statuses/{sha}","languages_url":"https://api.github.com/repos/mesosphere/marathon/languages","stargazers_url":"https://api.github.com/repos/mesosphere/marathon/stargazers","contributors_url":"https://api.github.com/repos/mesosphere/marathon/contributors","subscribers_url":"https://api.github.com/repos/mesosphere/marathon/subscribers","subscription_url":"https://api.github.com/repos/mesosphere/marathon/subscription","commits_url":"https://api.github.com/repos/mesosphere/marathon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mesosphere/marathon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mesosphere/marathon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mesosphere/marathon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mesosphere/marathon/contents/{+path}","compare_url":"https://api.github.com/repos/mesosphere/marathon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mesosphere/marathon/merges","archive_url":"https://api.github.com/repos/mesosphere/marathon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mesosphere/marathon/downloads","issues_url":"https://api.github.com/repos/mesosphere/marathon/issues{/number}","pulls_url":"https://api.github.com/repos/mesosphere/marathon/pulls{/number}","milestones_url":"https://api.github.com/repos/mesosphere/marathon/milestones{/number}","notifications_url":"https://api.github.com/repos/mesosphere/marathon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mesosphere/marathon/labels{/name}","releases_url":"https://api.github.com/repos/mesosphere/marathon/releases{/id}","deployments_url":"https://api.github.com/repos/mesosphere/marathon/deployments","created_at":"2013-06-25T14:56:34Z","updated_at":"2017-09-27T08:30:51Z","pushed_at":"2017-09-27T09:11:42Z","git_url":"git://github.com/mesosphere/marathon.git","ssh_url":"git@github.com:mesosphere/marathon.git","clone_url":"https://github.com/mesosphere/marathon.git","svn_url":"https://github.com/mesosphere/marathon","homepage":"https://mesosphere.github.io/marathon/","size":31296,"stargazers_count":3443,"watchers_count":3443,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":795,"mirror_url":null,"open_issues_count":22,"forks":795,"open_issues":22,"watchers":3443,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/5532"},"html":{"href":"https://github.com/mesosphere/marathon/pull/5532"},"issue":{"href":"https://api.github.com/repos/mesosphere/marathon/issues/5532"},"comments":{"href":"https://api.github.com/repos/mesosphere/marathon/issues/5532/comments"},"review_comments":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/5532/comments"},"review_comment":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mesosphere/marathon/pulls/5532/commits"},"statuses":{"href":"https://api.github.com/repos/mesosphere/marathon/statuses/91a92d13f8d438011284a57f62b3e4bffa7b9955"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"meln1k"}}