{"action":"created","comment":{"url":"https://api.github.com/repos/azkaban/azkaban/pulls/comments/79233228","id":79233228,"diff_hunk":"@@ -0,0 +1,132 @@\n+/*\n+ * Copyright 2016 LinkedIn Corp.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package azkaban.restli;\n+\n+import static org.junit.Assert.assertEquals;\n+\n+import azkaban.project.validator.ValidationReport;\n+\n+import com.linkedin.restli.common.HttpStatus;\n+import com.linkedin.restli.server.RestLiServiceException;\n+\n+import java.util.HashSet;\n+import java.util.LinkedHashMap;\n+import java.util.Map;\n+import java.util.Set;\n+\n+import org.junit.Test;\n+\n+/**\n+ * Test response to deploy with either warn or error reports.\n+ * If a report has any errors, a RestLiServiceException should be thrown.\n+ * Warnings should not elicit an exception.\n+ * If an exception does get raised, it should carry an HTTP 400 status\n+ */\n+\n+public class DeployProjectTest {\n+  @Test\n+  public void testWarnedDeploy() {\n+    ProjectManagerResource resource = new ProjectManagerResource();\n+    Map<String, ValidationReport> reports = new LinkedHashMap<String, ValidationReport>();\n+    for (int i = 0; i < 3; i++) {\n+      Set<String> warnMsgs = new HashSet<String>();\n+      ValidationReport warnRpt = new ValidationReport();\n+      warnMsgs.add(\"test warn level info message.\");\n+      warnRpt.addWarningMsgs(warnMsgs);\n+      reports.put(\"warn \" + i, warnRpt);\n+    }\n+    // We expect that no exceptions are thrown given a\n+    // report with warnings. Anything thrown will result in failure\n+    resource.checkReport(reports);\n+  }\n+\n+  @Test\n+  public void testErrorDeploy() {\n+    ProjectManagerResource resource = new ProjectManagerResource();\n+    Map<String, ValidationReport> reports = new LinkedHashMap<String, ValidationReport>();\n+    for (int i = 0; i < 3; i++) {\n+      Set<String> errorMsgs = new HashSet<String>();\n+      ValidationReport errorRpt = new ValidationReport();\n+      errorMsgs.add(\"test error level info message.\");\n+      errorRpt.addErrorMsgs(errorMsgs);\n+      reports.put(\"error \" + i, errorRpt);\n+    }\n+    // We expect that a RestLiServiceException is thrown given a\n+    // report with errors. Uncaught exceptions will result in failure\n+    try {\n+      resource.checkReport(reports);\n+    } catch (RestLiServiceException e) {\n+      //Ensure we have the right status code and exit\n+      assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);\n+    }\n+  }\n+\n+  @Test\n+  public void testWarnErrorDeploy() {\n+    ProjectManagerResource resource = new ProjectManagerResource();\n+    Map<String, ValidationReport> reports = new LinkedHashMap<String, ValidationReport>();\n+    for (int i = 0; i < 7; i++) {\n+      Set<String> msgs = new HashSet<String>();\n+      ValidationReport report = new ValidationReport();\n+      msgs.add(\"test message.\");\n+      // If i is even, make an error report, otherwise make a warning report\n+      if (i % 2 == 0) {\n+        report.addErrorMsgs(msgs);\n+      }\n+      else {\n+        report.addWarningMsgs(msgs);\n+      }\n+      reports.put(\"test \" + i, report);\n+    }\n+\n+    // We expect that a RestLiServiceException is thrown given a\n+    // report with errors. Uncaught exceptions will result in failure\n+    try {\n+      resource.checkReport(reports);\n+    } catch (RestLiServiceException e) {\n+      //Ensure we have the right status code and exit\n+      assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);\n+    }\n+  }\n+\n+  /**\n+   * Test that an error message is attached to the exception on an error\n+   * Note that there are two spaces between \"error\" and \"reports\"\n+   */\n+  @Test\n+  public void testErrorMessageDeploy() {\n+    ProjectManagerResource resource = new ProjectManagerResource();\n+    Map<String, ValidationReport> reports = new LinkedHashMap<String, ValidationReport>();\n+\n+    Set<String> errorMsgs = new HashSet<String>();\n+    ValidationReport errorRpt = new ValidationReport();\n+    errorMsgs.add(\"This should show up\");\n+    errorRpt.addErrorMsgs(errorMsgs);\n+    reports.put(\"error \", errorRpt);\n+\n+    // We expect that a RestLiServiceException is thrown given a\n+    // report with errors. Uncaught exceptions will result in failure\n+    try {\n+      resource.checkReport(reports);\n+    } catch (RestLiServiceException e) {\n+      //Ensure we have the right status code and exit\n+      assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);\n+      assertEquals(e.getMessage(), \"Validator error  reports errors: This should show up\"\n+          + System.getProperty(\"line.separator\"));\n+    }\n+  }\n+}","path":"azkaban-web-server/src/test/java/azkaban/restli/DeployProjectTest.java","position":132,"original_position":132,"commit_id":"7a6667191eb5cad98a723ed5b55dc7c9ddb38841","original_commit_id":"7a6667191eb5cad98a723ed5b55dc7c9ddb38841","user":{"login":"suvodeep-pyne","id":2577714,"avatar_url":"https://avatars.githubusercontent.com/u/2577714?v=3","gravatar_id":"","url":"https://api.github.com/users/suvodeep-pyne","html_url":"https://github.com/suvodeep-pyne","followers_url":"https://api.github.com/users/suvodeep-pyne/followers","following_url":"https://api.github.com/users/suvodeep-pyne/following{/other_user}","gists_url":"https://api.github.com/users/suvodeep-pyne/gists{/gist_id}","starred_url":"https://api.github.com/users/suvodeep-pyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suvodeep-pyne/subscriptions","organizations_url":"https://api.github.com/users/suvodeep-pyne/orgs","repos_url":"https://api.github.com/users/suvodeep-pyne/repos","events_url":"https://api.github.com/users/suvodeep-pyne/events{/privacy}","received_events_url":"https://api.github.com/users/suvodeep-pyne/received_events","type":"User","site_admin":false},"body":"nit: newline missing","created_at":"2016-09-16T19:11:59Z","updated_at":"2016-09-16T19:11:59Z","html_url":"https://github.com/azkaban/azkaban/pull/733#discussion_r79233228","pull_request_url":"https://api.github.com/repos/azkaban/azkaban/pulls/733","_links":{"self":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/comments/79233228"},"html":{"href":"https://github.com/azkaban/azkaban/pull/733#discussion_r79233228"},"pull_request":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/733"}}},"pull_request":{"url":"https://api.github.com/repos/azkaban/azkaban/pulls/733","id":85307370,"html_url":"https://github.com/azkaban/azkaban/pull/733","diff_url":"https://github.com/azkaban/azkaban/pull/733.diff","patch_url":"https://github.com/azkaban/azkaban/pull/733.patch","issue_url":"https://api.github.com/repos/azkaban/azkaban/issues/733","number":733,"state":"open","locked":false,"title":"Throw exception on deploy action fail. Added unit tests to make sure this behaviour happens (#725)","user":{"login":"KyleFung","id":5490754,"avatar_url":"https://avatars.githubusercontent.com/u/5490754?v=3","gravatar_id":"","url":"https://api.github.com/users/KyleFung","html_url":"https://github.com/KyleFung","followers_url":"https://api.github.com/users/KyleFung/followers","following_url":"https://api.github.com/users/KyleFung/following{/other_user}","gists_url":"https://api.github.com/users/KyleFung/gists{/gist_id}","starred_url":"https://api.github.com/users/KyleFung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyleFung/subscriptions","organizations_url":"https://api.github.com/users/KyleFung/orgs","repos_url":"https://api.github.com/users/KyleFung/repos","events_url":"https://api.github.com/users/KyleFung/events{/privacy}","received_events_url":"https://api.github.com/users/KyleFung/received_events","type":"User","site_admin":false},"body":"Fixed issues mentioned in comments on last pull request to (#725). Also added unit tests.\r\n\r\nException type in this action needed to be changed to RestLiServiceException because RestLi code ultimately catches them and sends a response back to the user. Before, we were throwing exception types RestLi cannot handle, so it always returned a status 500 response to the user, even if it wasn't an internal server error. If we throw a RestLiServiceException, we can specify what status code is sent to the user, in this case that is status 400.","created_at":"2016-09-14T21:20:18Z","updated_at":"2016-09-16T19:11:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0dceeffd0a66502394d767e9edbc9a000062661","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/azkaban/azkaban/pulls/733/commits","review_comments_url":"https://api.github.com/repos/azkaban/azkaban/pulls/733/comments","review_comment_url":"https://api.github.com/repos/azkaban/azkaban/pulls/comments{/number}","comments_url":"https://api.github.com/repos/azkaban/azkaban/issues/733/comments","statuses_url":"https://api.github.com/repos/azkaban/azkaban/statuses/7a6667191eb5cad98a723ed5b55dc7c9ddb38841","head":{"label":"KyleFung:8777-blacklist","ref":"8777-blacklist","sha":"7a6667191eb5cad98a723ed5b55dc7c9ddb38841","user":{"login":"KyleFung","id":5490754,"avatar_url":"https://avatars.githubusercontent.com/u/5490754?v=3","gravatar_id":"","url":"https://api.github.com/users/KyleFung","html_url":"https://github.com/KyleFung","followers_url":"https://api.github.com/users/KyleFung/followers","following_url":"https://api.github.com/users/KyleFung/following{/other_user}","gists_url":"https://api.github.com/users/KyleFung/gists{/gist_id}","starred_url":"https://api.github.com/users/KyleFung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyleFung/subscriptions","organizations_url":"https://api.github.com/users/KyleFung/orgs","repos_url":"https://api.github.com/users/KyleFung/repos","events_url":"https://api.github.com/users/KyleFung/events{/privacy}","received_events_url":"https://api.github.com/users/KyleFung/received_events","type":"User","site_admin":false},"repo":{"id":67742239,"name":"azkaban","full_name":"KyleFung/azkaban","owner":{"login":"KyleFung","id":5490754,"avatar_url":"https://avatars.githubusercontent.com/u/5490754?v=3","gravatar_id":"","url":"https://api.github.com/users/KyleFung","html_url":"https://github.com/KyleFung","followers_url":"https://api.github.com/users/KyleFung/followers","following_url":"https://api.github.com/users/KyleFung/following{/other_user}","gists_url":"https://api.github.com/users/KyleFung/gists{/gist_id}","starred_url":"https://api.github.com/users/KyleFung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KyleFung/subscriptions","organizations_url":"https://api.github.com/users/KyleFung/orgs","repos_url":"https://api.github.com/users/KyleFung/repos","events_url":"https://api.github.com/users/KyleFung/events{/privacy}","received_events_url":"https://api.github.com/users/KyleFung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KyleFung/azkaban","description":"Azkaban workflow manager.","fork":true,"url":"https://api.github.com/repos/KyleFung/azkaban","forks_url":"https://api.github.com/repos/KyleFung/azkaban/forks","keys_url":"https://api.github.com/repos/KyleFung/azkaban/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KyleFung/azkaban/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KyleFung/azkaban/teams","hooks_url":"https://api.github.com/repos/KyleFung/azkaban/hooks","issue_events_url":"https://api.github.com/repos/KyleFung/azkaban/issues/events{/number}","events_url":"https://api.github.com/repos/KyleFung/azkaban/events","assignees_url":"https://api.github.com/repos/KyleFung/azkaban/assignees{/user}","branches_url":"https://api.github.com/repos/KyleFung/azkaban/branches{/branch}","tags_url":"https://api.github.com/repos/KyleFung/azkaban/tags","blobs_url":"https://api.github.com/repos/KyleFung/azkaban/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KyleFung/azkaban/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KyleFung/azkaban/git/refs{/sha}","trees_url":"https://api.github.com/repos/KyleFung/azkaban/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KyleFung/azkaban/statuses/{sha}","languages_url":"https://api.github.com/repos/KyleFung/azkaban/languages","stargazers_url":"https://api.github.com/repos/KyleFung/azkaban/stargazers","contributors_url":"https://api.github.com/repos/KyleFung/azkaban/contributors","subscribers_url":"https://api.github.com/repos/KyleFung/azkaban/subscribers","subscription_url":"https://api.github.com/repos/KyleFung/azkaban/subscription","commits_url":"https://api.github.com/repos/KyleFung/azkaban/commits{/sha}","git_commits_url":"https://api.github.com/repos/KyleFung/azkaban/git/commits{/sha}","comments_url":"https://api.github.com/repos/KyleFung/azkaban/comments{/number}","issue_comment_url":"https://api.github.com/repos/KyleFung/azkaban/issues/comments{/number}","contents_url":"https://api.github.com/repos/KyleFung/azkaban/contents/{+path}","compare_url":"https://api.github.com/repos/KyleFung/azkaban/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KyleFung/azkaban/merges","archive_url":"https://api.github.com/repos/KyleFung/azkaban/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KyleFung/azkaban/downloads","issues_url":"https://api.github.com/repos/KyleFung/azkaban/issues{/number}","pulls_url":"https://api.github.com/repos/KyleFung/azkaban/pulls{/number}","milestones_url":"https://api.github.com/repos/KyleFung/azkaban/milestones{/number}","notifications_url":"https://api.github.com/repos/KyleFung/azkaban/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KyleFung/azkaban/labels{/name}","releases_url":"https://api.github.com/repos/KyleFung/azkaban/releases{/id}","deployments_url":"https://api.github.com/repos/KyleFung/azkaban/deployments","created_at":"2016-09-08T21:40:06Z","updated_at":"2016-09-08T21:40:10Z","pushed_at":"2016-09-16T19:04:38Z","git_url":"git://github.com/KyleFung/azkaban.git","ssh_url":"git@github.com:KyleFung/azkaban.git","clone_url":"https://github.com/KyleFung/azkaban.git","svn_url":"https://github.com/KyleFung/azkaban","homepage":"https://azkaban.github.io","size":33018,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"azkaban:master","ref":"master","sha":"a7821a7ba3fc25e6cadf29e268d8bba620901dec","user":{"login":"azkaban","id":213618,"avatar_url":"https://avatars.githubusercontent.com/u/213618?v=3","gravatar_id":"","url":"https://api.github.com/users/azkaban","html_url":"https://github.com/azkaban","followers_url":"https://api.github.com/users/azkaban/followers","following_url":"https://api.github.com/users/azkaban/following{/other_user}","gists_url":"https://api.github.com/users/azkaban/gists{/gist_id}","starred_url":"https://api.github.com/users/azkaban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azkaban/subscriptions","organizations_url":"https://api.github.com/users/azkaban/orgs","repos_url":"https://api.github.com/users/azkaban/repos","events_url":"https://api.github.com/users/azkaban/events{/privacy}","received_events_url":"https://api.github.com/users/azkaban/received_events","type":"Organization","site_admin":false},"repo":{"id":6271421,"name":"azkaban","full_name":"azkaban/azkaban","owner":{"login":"azkaban","id":213618,"avatar_url":"https://avatars.githubusercontent.com/u/213618?v=3","gravatar_id":"","url":"https://api.github.com/users/azkaban","html_url":"https://github.com/azkaban","followers_url":"https://api.github.com/users/azkaban/followers","following_url":"https://api.github.com/users/azkaban/following{/other_user}","gists_url":"https://api.github.com/users/azkaban/gists{/gist_id}","starred_url":"https://api.github.com/users/azkaban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azkaban/subscriptions","organizations_url":"https://api.github.com/users/azkaban/orgs","repos_url":"https://api.github.com/users/azkaban/repos","events_url":"https://api.github.com/users/azkaban/events{/privacy}","received_events_url":"https://api.github.com/users/azkaban/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/azkaban/azkaban","description":"Azkaban workflow manager.","fork":false,"url":"https://api.github.com/repos/azkaban/azkaban","forks_url":"https://api.github.com/repos/azkaban/azkaban/forks","keys_url":"https://api.github.com/repos/azkaban/azkaban/keys{/key_id}","collaborators_url":"https://api.github.com/repos/azkaban/azkaban/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/azkaban/azkaban/teams","hooks_url":"https://api.github.com/repos/azkaban/azkaban/hooks","issue_events_url":"https://api.github.com/repos/azkaban/azkaban/issues/events{/number}","events_url":"https://api.github.com/repos/azkaban/azkaban/events","assignees_url":"https://api.github.com/repos/azkaban/azkaban/assignees{/user}","branches_url":"https://api.github.com/repos/azkaban/azkaban/branches{/branch}","tags_url":"https://api.github.com/repos/azkaban/azkaban/tags","blobs_url":"https://api.github.com/repos/azkaban/azkaban/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/azkaban/azkaban/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/azkaban/azkaban/git/refs{/sha}","trees_url":"https://api.github.com/repos/azkaban/azkaban/git/trees{/sha}","statuses_url":"https://api.github.com/repos/azkaban/azkaban/statuses/{sha}","languages_url":"https://api.github.com/repos/azkaban/azkaban/languages","stargazers_url":"https://api.github.com/repos/azkaban/azkaban/stargazers","contributors_url":"https://api.github.com/repos/azkaban/azkaban/contributors","subscribers_url":"https://api.github.com/repos/azkaban/azkaban/subscribers","subscription_url":"https://api.github.com/repos/azkaban/azkaban/subscription","commits_url":"https://api.github.com/repos/azkaban/azkaban/commits{/sha}","git_commits_url":"https://api.github.com/repos/azkaban/azkaban/git/commits{/sha}","comments_url":"https://api.github.com/repos/azkaban/azkaban/comments{/number}","issue_comment_url":"https://api.github.com/repos/azkaban/azkaban/issues/comments{/number}","contents_url":"https://api.github.com/repos/azkaban/azkaban/contents/{+path}","compare_url":"https://api.github.com/repos/azkaban/azkaban/compare/{base}...{head}","merges_url":"https://api.github.com/repos/azkaban/azkaban/merges","archive_url":"https://api.github.com/repos/azkaban/azkaban/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/azkaban/azkaban/downloads","issues_url":"https://api.github.com/repos/azkaban/azkaban/issues{/number}","pulls_url":"https://api.github.com/repos/azkaban/azkaban/pulls{/number}","milestones_url":"https://api.github.com/repos/azkaban/azkaban/milestones{/number}","notifications_url":"https://api.github.com/repos/azkaban/azkaban/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/azkaban/azkaban/labels{/name}","releases_url":"https://api.github.com/repos/azkaban/azkaban/releases{/id}","deployments_url":"https://api.github.com/repos/azkaban/azkaban/deployments","created_at":"2012-10-18T01:34:53Z","updated_at":"2016-09-16T15:58:57Z","pushed_at":"2016-09-16T19:04:38Z","git_url":"git://github.com/azkaban/azkaban.git","ssh_url":"git@github.com:azkaban/azkaban.git","clone_url":"https://github.com/azkaban/azkaban.git","svn_url":"https://github.com/azkaban/azkaban","homepage":"https://azkaban.github.io","size":34359,"stargazers_count":789,"watchers_count":789,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":447,"mirror_url":null,"open_issues_count":261,"forks":447,"open_issues":261,"watchers":789,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/733"},"html":{"href":"https://github.com/azkaban/azkaban/pull/733"},"issue":{"href":"https://api.github.com/repos/azkaban/azkaban/issues/733"},"comments":{"href":"https://api.github.com/repos/azkaban/azkaban/issues/733/comments"},"review_comments":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/733/comments"},"review_comment":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/azkaban/azkaban/pulls/733/commits"},"statuses":{"href":"https://api.github.com/repos/azkaban/azkaban/statuses/7a6667191eb5cad98a723ed5b55dc7c9ddb38841"}}}}
{"actor":{"display_login":"suvodeep-pyne"}}