{"action":"created","comment":{"url":"https://api.github.com/repos/broadinstitute/centaur/pulls/comments/61267789","id":61267789,"diff_hunk":"@@ -119,52 +120,62 @@ object Operations {\n \n   /**\n     * This method uses a Metadata JSON returned by Cromwell as it's parameter,\n-    * and creates a test map. Since there can be many attempts per call,\n-    * this method takes the last call attempt, and filters the metadata\n-    * key value pairs by those of interest.\n+    * and creates a test map. It flattens the nested JSON into a Map[String, JsValue]\n+    * and it filters the keys of interest.\n     */\n-  private def convertMetadataToTestMap(metadataJson: String): Map[String, JsObject] = {\n-    val calls = metadataJson.parseJson.asJsObject.fields.get(\"calls\").get.asJsObject\n-    val listOfkeys = Seq(\"runtimeAttributes\", \"preemptible\", \"executionStatus\")\n-\n-    val lastCallAttempt = calls.fields map {\n-      case (k1, allCallAttempts: JsArray) =>\n-        val lastCallAttempt = allCallAttempts.elements.last.asJsObject\n-        val filteredCallAttributes = lastCallAttempt.fields collect {\n-          case (k2, callAttributes) if listOfkeys.contains(k2) => k2 -> callAttributes\n-        }\n-        k1 -> JsObject(filteredCallAttributes)\n+  private def makeMetadataMap(metadataJson: String): Map[String, JsValue] = {\n \n-      case(k, v) => throw new Exception(s\"Wrong Js parameter for $k, Call attempts are expected to be in a JsArray\")\n-    }\n+    val flattenedMetadataMap = metadataJson.parseJson.asJsObject.flatten().fields map { case(k, v) => k -> v }\n+    val listOfKeys = Set(\"runtimeAttributes\", \"preemptible\", \"executionStatus\")\n+    val filteredMap = flattenedMetadataMap filter { case (k, v) => listOfKeys exists { x => k.contains(x) } }\n \n-    lastCallAttempt\n+    filteredMap\n   }\n \n   private def makeOutputMap(metadataJson: String): Map[String, JsValue] = {\n     // Need DefaultJsonProtocol export to use convertTo[Map[String,String]]\n     import DefaultJsonProtocol._\n     val outputs = metadataJson.parseJson.asJsObject.fields.get(\"outputs\").get.asJsObject.toString\n-\n     outputs.parseJson.convertTo[Map[String, JsValue]]\n   }\n \n+  /**\n+    * This method accepts the two maps being compared, Workflow Request, and type of Map\n+    * (metadata/output). It finds and returns the differences in the keys/values of the two maps.\n+    */\n+  def assertMapDiff(expectedMetadata: Option[Map[String, JsValue]], actualMetadata: Map[String, JsValue], request: WorkflowRequest, testType: String) = {\n+    val expectedMap = expectedMetadata.get\n+\n+    val diff = expectedMap.keySet -- actualMetadata.keySet\n+    println(s\"For workflow ${request.name}: \\nMissing expected $testType fields: $diff\")\n+\n+    expectedMap foreach { case (k, v:JsValue) =>\n+      if (actualMetadata.contains(k) && (!v.toString.equals(actualMetadata.get(k).mkString))) {\n+          println(s\"Unexpected $testType for key: $k. Found: ${v.toString} Expected: ${actualMetadata.get(k).mkString}\")\n+      }\n+    }\n+  }\n \n   def verifyMetadataAndOutputs(workflow: Workflow, request: WorkflowRequest): Test[Workflow] = {\n     new Test[Workflow] {\n-      val expectedMap: Option[Map[String, JsObject]] = request.metadata map { metadataString: String => convertMetadataToTestMap(metadataString) }\n+      val expectedMap: Option[Map[String, JsValue]] = request.metadata map { metadataString: String => makeMetadataMap(metadataString) }\n       val expectedOutputMap: Option[Map[String, JsValue]] = request.metadata map { metadataString: String => makeOutputMap(metadataString) }\n \n-      def verifyWorkflowMetadata(metadata: Map[String, JsObject]) = {\n-        expectedMap match {\n-          case Some(expected) if !expected.equals(metadata) => throw new Exception(s\"Bad Metadata for Workflow ${request.name}\")\n-          case _ =>\n-        }\n+\n+      def verifyWorkflowMetadata(metadata: Map[String, JsValue]) = {\n+          expectedMap match {","path":"src/main/scala/centaur/Test.scala","position":79,"original_position":79,"commit_id":"51fe9aa05c45c5d55faa4766e22db9bfbdd74053","original_commit_id":"fd35ac1d72db7b611a090595f3843dc6d87b6e8c","user":{"login":"ruchim","id":14941133,"avatar_url":"https://avatars.githubusercontent.com/u/14941133?v=3","gravatar_id":"","url":"https://api.github.com/users/ruchim","html_url":"https://github.com/ruchim","followers_url":"https://api.github.com/users/ruchim/followers","following_url":"https://api.github.com/users/ruchim/following{/other_user}","gists_url":"https://api.github.com/users/ruchim/gists{/gist_id}","starred_url":"https://api.github.com/users/ruchim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruchim/subscriptions","organizations_url":"https://api.github.com/users/ruchim/orgs","repos_url":"https://api.github.com/users/ruchim/repos","events_url":"https://api.github.com/users/ruchim/events{/privacy}","received_events_url":"https://api.github.com/users/ruchim/received_events","type":"User","site_admin":false},"body":"I know what you're saying, I guess I'm hoping that the comparison of the expected vs. actual can grow further into more cases than just perfectly matching vs. not. With that idea in mind, I'm hoping it's okay to leave the cases, and I imagine with Jeff's changes a lot of these cases will have to adapt soon.","created_at":"2016-04-27T14:34:41Z","updated_at":"2016-04-27T14:34:41Z","html_url":"https://github.com/broadinstitute/centaur/pull/35#discussion_r61267789","pull_request_url":"https://api.github.com/repos/broadinstitute/centaur/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/comments/61267789"},"html":{"href":"https://github.com/broadinstitute/centaur/pull/35#discussion_r61267789"},"pull_request":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/broadinstitute/centaur/pulls/35","id":67942152,"html_url":"https://github.com/broadinstitute/centaur/pull/35","diff_url":"https://github.com/broadinstitute/centaur/pull/35.diff","patch_url":"https://github.com/broadinstitute/centaur/pull/35.patch","issue_url":"https://api.github.com/repos/broadinstitute/centaur/issues/35","number":35,"state":"open","locked":false,"title":"Compare Metadata/Outputs","user":{"login":"ruchim","id":14941133,"avatar_url":"https://avatars.githubusercontent.com/u/14941133?v=3","gravatar_id":"","url":"https://api.github.com/users/ruchim","html_url":"https://github.com/ruchim","followers_url":"https://api.github.com/users/ruchim/followers","following_url":"https://api.github.com/users/ruchim/following{/other_user}","gists_url":"https://api.github.com/users/ruchim/gists{/gist_id}","starred_url":"https://api.github.com/users/ruchim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruchim/subscriptions","organizations_url":"https://api.github.com/users/ruchim/orgs","repos_url":"https://api.github.com/users/ruchim/repos","events_url":"https://api.github.com/users/ruchim/events{/privacy}","received_events_url":"https://api.github.com/users/ruchim/received_events","type":"User","site_admin":false},"body":"Find and return metadata/output test results for each workflow to the user of Centaur.","created_at":"2016-04-26T19:16:12Z","updated_at":"2016-04-27T14:34:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71c445d31a45b039eab6ca579e4705d0ff201c89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/broadinstitute/centaur/pulls/35/commits","review_comments_url":"https://api.github.com/repos/broadinstitute/centaur/pulls/35/comments","review_comment_url":"https://api.github.com/repos/broadinstitute/centaur/pulls/comments{/number}","comments_url":"https://api.github.com/repos/broadinstitute/centaur/issues/35/comments","statuses_url":"https://api.github.com/repos/broadinstitute/centaur/statuses/51fe9aa05c45c5d55faa4766e22db9bfbdd74053","head":{"label":"broadinstitute:rm_compareJSON","ref":"rm_compareJSON","sha":"51fe9aa05c45c5d55faa4766e22db9bfbdd74053","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":52314959,"name":"centaur","full_name":"broadinstitute/centaur","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/centaur","description":"Cromwell integration testing environment","fork":false,"url":"https://api.github.com/repos/broadinstitute/centaur","forks_url":"https://api.github.com/repos/broadinstitute/centaur/forks","keys_url":"https://api.github.com/repos/broadinstitute/centaur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/centaur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/centaur/teams","hooks_url":"https://api.github.com/repos/broadinstitute/centaur/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/centaur/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/centaur/events","assignees_url":"https://api.github.com/repos/broadinstitute/centaur/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/centaur/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/centaur/tags","blobs_url":"https://api.github.com/repos/broadinstitute/centaur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/centaur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/centaur/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/centaur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/centaur/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/centaur/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/centaur/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/centaur/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/centaur/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/centaur/subscription","commits_url":"https://api.github.com/repos/broadinstitute/centaur/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/centaur/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/centaur/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/centaur/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/centaur/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/centaur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/centaur/merges","archive_url":"https://api.github.com/repos/broadinstitute/centaur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/centaur/downloads","issues_url":"https://api.github.com/repos/broadinstitute/centaur/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/centaur/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/centaur/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/centaur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/centaur/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/centaur/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/centaur/deployments","created_at":"2016-02-22T23:48:30Z","updated_at":"2016-04-26T20:49:26Z","pushed_at":"2016-04-27T14:15:53Z","git_url":"git://github.com/broadinstitute/centaur.git","ssh_url":"git@github.com:broadinstitute/centaur.git","clone_url":"https://github.com/broadinstitute/centaur.git","svn_url":"https://github.com/broadinstitute/centaur","homepage":null,"size":101,"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":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"develop"}},"base":{"label":"broadinstitute:develop","ref":"develop","sha":"0b4c3698bc53e0dce9f261bc08067048d8df7376","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":52314959,"name":"centaur","full_name":"broadinstitute/centaur","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/centaur","description":"Cromwell integration testing environment","fork":false,"url":"https://api.github.com/repos/broadinstitute/centaur","forks_url":"https://api.github.com/repos/broadinstitute/centaur/forks","keys_url":"https://api.github.com/repos/broadinstitute/centaur/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broadinstitute/centaur/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broadinstitute/centaur/teams","hooks_url":"https://api.github.com/repos/broadinstitute/centaur/hooks","issue_events_url":"https://api.github.com/repos/broadinstitute/centaur/issues/events{/number}","events_url":"https://api.github.com/repos/broadinstitute/centaur/events","assignees_url":"https://api.github.com/repos/broadinstitute/centaur/assignees{/user}","branches_url":"https://api.github.com/repos/broadinstitute/centaur/branches{/branch}","tags_url":"https://api.github.com/repos/broadinstitute/centaur/tags","blobs_url":"https://api.github.com/repos/broadinstitute/centaur/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broadinstitute/centaur/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broadinstitute/centaur/git/refs{/sha}","trees_url":"https://api.github.com/repos/broadinstitute/centaur/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broadinstitute/centaur/statuses/{sha}","languages_url":"https://api.github.com/repos/broadinstitute/centaur/languages","stargazers_url":"https://api.github.com/repos/broadinstitute/centaur/stargazers","contributors_url":"https://api.github.com/repos/broadinstitute/centaur/contributors","subscribers_url":"https://api.github.com/repos/broadinstitute/centaur/subscribers","subscription_url":"https://api.github.com/repos/broadinstitute/centaur/subscription","commits_url":"https://api.github.com/repos/broadinstitute/centaur/commits{/sha}","git_commits_url":"https://api.github.com/repos/broadinstitute/centaur/git/commits{/sha}","comments_url":"https://api.github.com/repos/broadinstitute/centaur/comments{/number}","issue_comment_url":"https://api.github.com/repos/broadinstitute/centaur/issues/comments{/number}","contents_url":"https://api.github.com/repos/broadinstitute/centaur/contents/{+path}","compare_url":"https://api.github.com/repos/broadinstitute/centaur/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broadinstitute/centaur/merges","archive_url":"https://api.github.com/repos/broadinstitute/centaur/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broadinstitute/centaur/downloads","issues_url":"https://api.github.com/repos/broadinstitute/centaur/issues{/number}","pulls_url":"https://api.github.com/repos/broadinstitute/centaur/pulls{/number}","milestones_url":"https://api.github.com/repos/broadinstitute/centaur/milestones{/number}","notifications_url":"https://api.github.com/repos/broadinstitute/centaur/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broadinstitute/centaur/labels{/name}","releases_url":"https://api.github.com/repos/broadinstitute/centaur/releases{/id}","deployments_url":"https://api.github.com/repos/broadinstitute/centaur/deployments","created_at":"2016-02-22T23:48:30Z","updated_at":"2016-04-26T20:49:26Z","pushed_at":"2016-04-27T14:15:53Z","git_url":"git://github.com/broadinstitute/centaur.git","ssh_url":"git@github.com:broadinstitute/centaur.git","clone_url":"https://github.com/broadinstitute/centaur.git","svn_url":"https://github.com/broadinstitute/centaur","homepage":null,"size":101,"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":11,"forks":0,"open_issues":11,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/35"},"html":{"href":"https://github.com/broadinstitute/centaur/pull/35"},"issue":{"href":"https://api.github.com/repos/broadinstitute/centaur/issues/35"},"comments":{"href":"https://api.github.com/repos/broadinstitute/centaur/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/broadinstitute/centaur/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/broadinstitute/centaur/statuses/51fe9aa05c45c5d55faa4766e22db9bfbdd74053"}}}}