{"action":"created","comment":{"url":"https://api.github.com/repos/openregister/presentation/pulls/comments/35087026","id":35087026,"diff_hunk":"@@ -0,0 +1,37 @@\n+package uk.gov.register.presentation.entity;\n+\n+import com.fasterxml.jackson.databind.JsonNode;\n+import com.google.common.collect.ImmutableMap;\n+import org.junit.Test;\n+import uk.gov.register.presentation.mapper.JsonObjectMapper;\n+import uk.gov.register.presentation.view.AbstractView;\n+import uk.gov.register.presentation.view.SingleResultView;\n+\n+import java.util.Map;\n+\n+import static org.hamcrest.core.IsEqual.equalTo;\n+import static org.junit.Assert.assertThat;\n+\n+public class CsvEntityTest {\n+    @Test\n+    public void csv_entriesAreEscaped() {\n+        CsvEntity csvEntity = new CsvEntity();\n+\n+        Map jsonMap = ImmutableMap.of(\n+                \"hash\", \"hash1\",\n+                \"entry\", ImmutableMap.of(\n+                        \"key1\", \"valu\\te1\",\n+                        \"key2\", \"val,ue2\",\n+                        \"key3\", \"val\\\"ue3\",\n+                        \"key4\", \"val\\nue4\"\n+                )\n+        );\n+        JsonNode node = JsonObjectMapper.convert(jsonMap, JsonNode.class);\n+\n+        AbstractView view = new SingleResultView(\"foo\", node);\n+        Object result = csvEntity.convert(view);\n+\n+        assertThat(result.toString(), equalTo(\"hash,key1,key2,key3,key4\\nhash1,valu\\te1,\\\"val,ue2\\\",\\\"val\\\"\\\"ue3\\\",\\\"val\\nue4\\\"\"));","path":"src/test/java/uk/gov/register/presentation/entity/CsvEntityTest.java","position":null,"original_position":34,"commit_id":"6e06c723bfe911575849d228b57d3c1eeaa631b0","original_commit_id":"85aa3ae090653130d10d3d64e5b2e02ec6789aa7","user":{"login":"philandstuff","id":581269,"avatar_url":"https://avatars.githubusercontent.com/u/581269?v=3","gravatar_id":"","url":"https://api.github.com/users/philandstuff","html_url":"https://github.com/philandstuff","followers_url":"https://api.github.com/users/philandstuff/followers","following_url":"https://api.github.com/users/philandstuff/following{/other_user}","gists_url":"https://api.github.com/users/philandstuff/gists{/gist_id}","starred_url":"https://api.github.com/users/philandstuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philandstuff/subscriptions","organizations_url":"https://api.github.com/users/philandstuff/orgs","repos_url":"https://api.github.com/users/philandstuff/repos","events_url":"https://api.github.com/users/philandstuff/events{/privacy}","received_events_url":"https://api.github.com/users/philandstuff/received_events","type":"User","site_admin":false},"body":"@om-sharma and I checked this together and it opens in libreoffice so this is fine.","created_at":"2015-07-21T09:58:24Z","updated_at":"2015-07-21T09:58:24Z","html_url":"https://github.com/openregister/presentation/pull/11#discussion_r35087026","pull_request_url":"https://api.github.com/repos/openregister/presentation/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments/35087026"},"html":{"href":"https://github.com/openregister/presentation/pull/11#discussion_r35087026"},"pull_request":{"href":"https://api.github.com/repos/openregister/presentation/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/openregister/presentation/pulls/11","id":40343972,"html_url":"https://github.com/openregister/presentation/pull/11","diff_url":"https://github.com/openregister/presentation/pull/11.diff","patch_url":"https://github.com/openregister/presentation/pull/11.patch","issue_url":"https://api.github.com/repos/openregister/presentation/issues/11","number":11,"state":"open","locked":false,"title":"Escaping csv and tsv entries","user":{"login":"om-sharma","id":8011952,"avatar_url":"https://avatars.githubusercontent.com/u/8011952?v=3","gravatar_id":"","url":"https://api.github.com/users/om-sharma","html_url":"https://github.com/om-sharma","followers_url":"https://api.github.com/users/om-sharma/followers","following_url":"https://api.github.com/users/om-sharma/following{/other_user}","gists_url":"https://api.github.com/users/om-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/om-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/om-sharma/subscriptions","organizations_url":"https://api.github.com/users/om-sharma/orgs","repos_url":"https://api.github.com/users/om-sharma/repos","events_url":"https://api.github.com/users/om-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/om-sharma/received_events","type":"User","site_admin":false},"body":"Refactored the CsvEntity class in two classes, one for Csv representation and second for tsv representation. Earlier implementation was not escaping any data.","created_at":"2015-07-20T11:45:52Z","updated_at":"2015-07-21T09:58:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83b8975bca50cfaaf1deabbc63d586c6ea8118b6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openregister/presentation/pulls/11/commits","review_comments_url":"https://api.github.com/repos/openregister/presentation/pulls/11/comments","review_comment_url":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openregister/presentation/issues/11/comments","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/6e06c723bfe911575849d228b57d3c1eeaa631b0","head":{"label":"openregister:escape_csv_tsv_entries","ref":"escape_csv_tsv_entries","sha":"6e06c723bfe911575849d228b57d3c1eeaa631b0","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-07-21T09:50:38Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1132,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"openregister:master","ref":"master","sha":"c69ede639f4d873bedfb7839a68deaa30ae6c03c","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-07-21T09:50:38Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1132,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/11"},"html":{"href":"https://github.com/openregister/presentation/pull/11"},"issue":{"href":"https://api.github.com/repos/openregister/presentation/issues/11"},"comments":{"href":"https://api.github.com/repos/openregister/presentation/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/openregister/presentation/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openregister/presentation/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/openregister/presentation/statuses/6e06c723bfe911575849d228b57d3c1eeaa631b0"}}}}