{"action":"created","comment":{"url":"https://api.github.com/repos/hmrc/file-upload/pulls/comments/107438535","pull_request_review_id":28410586,"id":107438535,"diff_hunk":"@@ -0,0 +1,86 @@\n+/*\n+ * Copyright 2017 HM Revenue & Customs\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of 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,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package uk.gov.hmrc.fileupload.controllers\n+\n+import play.api.libs.json._\n+import uk.gov.hmrc.play.test.UnitSpec\n+\n+class EnvelopeConstraintsSpec extends UnitSpec {\n+\n+  \"translatetoByte \" should {\n+\n+    \"should parse a constraint in MB or KB to Long\" in {\n+      CreateEnvelopeRequest translateToByteSize \"10MB\" shouldBe (10 * 1024 * 1024)\n+\n+      CreateEnvelopeRequest translateToByteSize \"100KB\" shouldBe (100 * 1024)\n+\n+      CreateEnvelopeRequest translateToByteSize \"08MB\" shouldBe (8 * 1024 * 1024)\n+\n+      an[scala.MatchError] should be thrownBy (CreateEnvelopeRequest translateToByteSize \"1000MB\")\n+    }\n+  }\n+\n+  \"envelopeConstraintReader \" should {\n+    import uk.gov.hmrc.fileupload.controllers.CreateEnvelopeRequest.envelopeConstraintsReads\n+    \"should parse a valid envelope constraint json\" in {\n+      val constraintJson =\n+        \"\"\"\n+          {\n+            \"maxItems\": 56,\n+            \"maxSize\": \"12KB\",\n+            \"maxSizePerItem\": \"08KB\"\n+          }\n+          \"\"\"\n+      val expectedConstraint = EnvelopeConstraints(56, 12 * 1024, 8 * 1024)\n+\n+      val parsedConstraint = Json.parse(constraintJson).validate\n+      parsedConstraint.get shouldBe expectedConstraint\n+    }\n+  }\n+\n+  \"envelopeConstraintReader \" should {\n+    import uk.gov.hmrc.fileupload.controllers.CreateEnvelopeRequest.envelopeConstraintsReads\n+    \"should parse empty json to default constraint values\" in {\n+      val constraintJson =\n+        \"\"\"{}\"\"\"\n+      val expectedConstraint = EnvelopeConstraints(100, 25 * 1024 * 1024, 10 * 1024 * 1024)\n+\n+      val parsedConstraint = Json.parse(constraintJson).validate\n+      parsedConstraint.get shouldBe expectedConstraint\n+    }\n+  }\n+\n+  \"envelopeConstraintReader \" should {\n+    import uk.gov.hmrc.fileupload.controllers.CreateEnvelopeRequest.envelopeConstraintsReads\n+    \"should fail the parsing when invalid constraint value is passed\" in {\n+      val constraintJson =\n+        \"\"\"\n+          {\n+            \"maxItems\": 56,\n+            \"maxSize\": \"12GB\",\n+            \"maxSizePerItem\": \"08KB\"\n+          }\n+          \"\"\"\n+      val expectedConstraint = EnvelopeConstraints(100, 25 * 1024 * 1024, 10 * 1024 * 1024)","path":"test/uk/gov/hmrc/fileupload/controllers/EnvelopeConstraintsSpec.scala","position":78,"original_position":78,"commit_id":"ad8c96e5f232468ed8febd4be551a3143bc36603","original_commit_id":"ad8c96e5f232468ed8febd4be551a3143bc36603","user":{"login":"konradwudkowski","id":11072914,"avatar_url":"https://avatars2.githubusercontent.com/u/11072914?v=3","gravatar_id":"","url":"https://api.github.com/users/konradwudkowski","html_url":"https://github.com/konradwudkowski","followers_url":"https://api.github.com/users/konradwudkowski/followers","following_url":"https://api.github.com/users/konradwudkowski/following{/other_user}","gists_url":"https://api.github.com/users/konradwudkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/konradwudkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/konradwudkowski/subscriptions","organizations_url":"https://api.github.com/users/konradwudkowski/orgs","repos_url":"https://api.github.com/users/konradwudkowski/repos","events_url":"https://api.github.com/users/konradwudkowski/events{/privacy}","received_events_url":"https://api.github.com/users/konradwudkowski/received_events","type":"User","site_admin":false},"body":"this `expectedConstraint` is actually not expected so could be removed","created_at":"2017-03-22T15:04:59Z","updated_at":"2017-03-22T15:04:59Z","html_url":"https://github.com/hmrc/file-upload/pull/79#discussion_r107438535","pull_request_url":"https://api.github.com/repos/hmrc/file-upload/pulls/79","_links":{"self":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/comments/107438535"},"html":{"href":"https://github.com/hmrc/file-upload/pull/79#discussion_r107438535"},"pull_request":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/79"}}},"pull_request":{"url":"https://api.github.com/repos/hmrc/file-upload/pulls/79","id":111295951,"html_url":"https://github.com/hmrc/file-upload/pull/79","diff_url":"https://github.com/hmrc/file-upload/pull/79.diff","patch_url":"https://github.com/hmrc/file-upload/pull/79.patch","issue_url":"https://api.github.com/repos/hmrc/file-upload/issues/79","number":79,"state":"open","locked":false,"title":"File upload constraints","user":{"login":"KorhanOzturk90","id":12673427,"avatar_url":"https://avatars0.githubusercontent.com/u/12673427?v=3","gravatar_id":"","url":"https://api.github.com/users/KorhanOzturk90","html_url":"https://github.com/KorhanOzturk90","followers_url":"https://api.github.com/users/KorhanOzturk90/followers","following_url":"https://api.github.com/users/KorhanOzturk90/following{/other_user}","gists_url":"https://api.github.com/users/KorhanOzturk90/gists{/gist_id}","starred_url":"https://api.github.com/users/KorhanOzturk90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KorhanOzturk90/subscriptions","organizations_url":"https://api.github.com/users/KorhanOzturk90/orgs","repos_url":"https://api.github.com/users/KorhanOzturk90/repos","events_url":"https://api.github.com/users/KorhanOzturk90/events{/privacy}","received_events_url":"https://api.github.com/users/KorhanOzturk90/received_events","type":"User","site_admin":false},"body":"Still wip but early feedback is always appreciated","created_at":"2017-03-17T14:45:46Z","updated_at":"2017-03-22T15:04:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"399dc11dfbb0038fd06b2a7cc767b9e0cd5b0eef","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmrc/file-upload/pulls/79/commits","review_comments_url":"https://api.github.com/repos/hmrc/file-upload/pulls/79/comments","review_comment_url":"https://api.github.com/repos/hmrc/file-upload/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmrc/file-upload/issues/79/comments","statuses_url":"https://api.github.com/repos/hmrc/file-upload/statuses/ad8c96e5f232468ed8febd4be551a3143bc36603","head":{"label":"hmrc:File-Upload-Constraints","ref":"File-Upload-Constraints","sha":"ad8c96e5f232468ed8febd4be551a3143bc36603","user":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"repo":{"id":55410088,"name":"file-upload","full_name":"hmrc/file-upload","owner":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmrc/file-upload","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/file-upload","forks_url":"https://api.github.com/repos/hmrc/file-upload/forks","keys_url":"https://api.github.com/repos/hmrc/file-upload/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/file-upload/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/file-upload/teams","hooks_url":"https://api.github.com/repos/hmrc/file-upload/hooks","issue_events_url":"https://api.github.com/repos/hmrc/file-upload/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/file-upload/events","assignees_url":"https://api.github.com/repos/hmrc/file-upload/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/file-upload/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/file-upload/tags","blobs_url":"https://api.github.com/repos/hmrc/file-upload/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/file-upload/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/file-upload/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/file-upload/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/file-upload/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/file-upload/languages","stargazers_url":"https://api.github.com/repos/hmrc/file-upload/stargazers","contributors_url":"https://api.github.com/repos/hmrc/file-upload/contributors","subscribers_url":"https://api.github.com/repos/hmrc/file-upload/subscribers","subscription_url":"https://api.github.com/repos/hmrc/file-upload/subscription","commits_url":"https://api.github.com/repos/hmrc/file-upload/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/file-upload/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/file-upload/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/file-upload/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/file-upload/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/file-upload/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/file-upload/merges","archive_url":"https://api.github.com/repos/hmrc/file-upload/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/file-upload/downloads","issues_url":"https://api.github.com/repos/hmrc/file-upload/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/file-upload/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/file-upload/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/file-upload/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/file-upload/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/file-upload/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/file-upload/deployments","created_at":"2016-04-04T12:39:26Z","updated_at":"2017-02-02T19:55:04Z","pushed_at":"2017-03-21T14:29:12Z","git_url":"git://github.com/hmrc/file-upload.git","ssh_url":"git@github.com:hmrc/file-upload.git","clone_url":"https://github.com/hmrc/file-upload.git","svn_url":"https://github.com/hmrc/file-upload","homepage":"","size":1228,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"hmrc:master","ref":"master","sha":"3342dadccd53a89d7456923787b02871597c5c42","user":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"repo":{"id":55410088,"name":"file-upload","full_name":"hmrc/file-upload","owner":{"login":"hmrc","id":5755339,"avatar_url":"https://avatars2.githubusercontent.com/u/5755339?v=3","gravatar_id":"","url":"https://api.github.com/users/hmrc","html_url":"https://github.com/hmrc","followers_url":"https://api.github.com/users/hmrc/followers","following_url":"https://api.github.com/users/hmrc/following{/other_user}","gists_url":"https://api.github.com/users/hmrc/gists{/gist_id}","starred_url":"https://api.github.com/users/hmrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmrc/subscriptions","organizations_url":"https://api.github.com/users/hmrc/orgs","repos_url":"https://api.github.com/users/hmrc/repos","events_url":"https://api.github.com/users/hmrc/events{/privacy}","received_events_url":"https://api.github.com/users/hmrc/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmrc/file-upload","description":null,"fork":false,"url":"https://api.github.com/repos/hmrc/file-upload","forks_url":"https://api.github.com/repos/hmrc/file-upload/forks","keys_url":"https://api.github.com/repos/hmrc/file-upload/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmrc/file-upload/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmrc/file-upload/teams","hooks_url":"https://api.github.com/repos/hmrc/file-upload/hooks","issue_events_url":"https://api.github.com/repos/hmrc/file-upload/issues/events{/number}","events_url":"https://api.github.com/repos/hmrc/file-upload/events","assignees_url":"https://api.github.com/repos/hmrc/file-upload/assignees{/user}","branches_url":"https://api.github.com/repos/hmrc/file-upload/branches{/branch}","tags_url":"https://api.github.com/repos/hmrc/file-upload/tags","blobs_url":"https://api.github.com/repos/hmrc/file-upload/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmrc/file-upload/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmrc/file-upload/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmrc/file-upload/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmrc/file-upload/statuses/{sha}","languages_url":"https://api.github.com/repos/hmrc/file-upload/languages","stargazers_url":"https://api.github.com/repos/hmrc/file-upload/stargazers","contributors_url":"https://api.github.com/repos/hmrc/file-upload/contributors","subscribers_url":"https://api.github.com/repos/hmrc/file-upload/subscribers","subscription_url":"https://api.github.com/repos/hmrc/file-upload/subscription","commits_url":"https://api.github.com/repos/hmrc/file-upload/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmrc/file-upload/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmrc/file-upload/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmrc/file-upload/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmrc/file-upload/contents/{+path}","compare_url":"https://api.github.com/repos/hmrc/file-upload/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmrc/file-upload/merges","archive_url":"https://api.github.com/repos/hmrc/file-upload/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmrc/file-upload/downloads","issues_url":"https://api.github.com/repos/hmrc/file-upload/issues{/number}","pulls_url":"https://api.github.com/repos/hmrc/file-upload/pulls{/number}","milestones_url":"https://api.github.com/repos/hmrc/file-upload/milestones{/number}","notifications_url":"https://api.github.com/repos/hmrc/file-upload/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmrc/file-upload/labels{/name}","releases_url":"https://api.github.com/repos/hmrc/file-upload/releases{/id}","deployments_url":"https://api.github.com/repos/hmrc/file-upload/deployments","created_at":"2016-04-04T12:39:26Z","updated_at":"2017-02-02T19:55:04Z","pushed_at":"2017-03-21T14:29:12Z","git_url":"git://github.com/hmrc/file-upload.git","ssh_url":"git@github.com:hmrc/file-upload.git","clone_url":"https://github.com/hmrc/file-upload.git","svn_url":"https://github.com/hmrc/file-upload","homepage":"","size":1228,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/79"},"html":{"href":"https://github.com/hmrc/file-upload/pull/79"},"issue":{"href":"https://api.github.com/repos/hmrc/file-upload/issues/79"},"comments":{"href":"https://api.github.com/repos/hmrc/file-upload/issues/79/comments"},"review_comments":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/79/comments"},"review_comment":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmrc/file-upload/pulls/79/commits"},"statuses":{"href":"https://api.github.com/repos/hmrc/file-upload/statuses/ad8c96e5f232468ed8febd4be551a3143bc36603"}}}}
{"actor":{"display_login":"konradwudkowski"}}