{"action":"created","comment":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/comments/59843029","id":59843029,"diff_hunk":"@@ -0,0 +1,128 @@\n+package net.sf.jabref.importer.fileformat;\n+\n+import java.io.ByteArrayInputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.nio.charset.StandardCharsets;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import net.sf.jabref.Globals;\n+import net.sf.jabref.JabRefPreferences;\n+import net.sf.jabref.bibtex.BibtexEntryAssert;\n+import net.sf.jabref.importer.OutputPrinterToNull;\n+import net.sf.jabref.model.entry.BibEntry;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertNotNull;\n+\n+/**\n+ * Articles in the medline format can be downloaded from http://www.ncbi.nlm.nih.gov/pubmed/.\n+ * 1. Search for a term and make sure you have selected the PubMed database\n+ * 2. Select the results you want to export by checking their checkboxes\n+ * 3. Press on the 'Send to' drop down menu on top of the search results\n+ * 4. Select 'File' as Destination and 'XML' as Format\n+ * 5. Press 'Create File' to download your search results in a medline xml file\n+ *\n+ * @author Daniel Mair/Bruehl\n+ *\n+ */\n+public class MedlineImporterTest {\n+\n+    private final InputStream emptyFileStream = new ByteArrayInputStream(\"\".getBytes(StandardCharsets.UTF_8));\n+    private MedlineImporter medlineImporter;\n+\n+\n+    @Before\n+    public void setUp() throws Exception {\n+        Globals.prefs = JabRefPreferences.getInstance();\n+        this.medlineImporter = new MedlineImporter();\n+    }\n+\n+    @Test\n+    public void testIsRecognizedFormatAccept() throws Throwable {\n+        List<String> list = Arrays.asList(\"MedlineImporterMinimalEntryTest.xml\", \"MedlineImporterSingleEntryTest.xml\",\n+                \"MedlineImporterArticleIDTest.xml\");\n+        for (String str : list) {\n+            try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) {\n+                Assert.assertTrue(medlineImporter.isRecognizedFormat(is));\n+            }\n+        }\n+    }\n+\n+    @Test\n+    public void testIsRecognizedFormatReject() throws Throwable {\n+        List<String> list = Arrays.asList(\"CopacImporterTest1.txt\", \"CopacImporterTest2.txt\", \"IEEEImport1.txt\",\n+                \"IsiImporterTestWOS.isi\", \"oai2.xml\", \"oai22.xml\", \"RisImporterTest1.ris\");\n+        for (String str : list) {\n+            try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) {\n+                Assert.assertFalse(medlineImporter.isRecognizedFormat(is));\n+            }\n+        }\n+    }\n+\n+    @Test\n+    public void testIsRecognizedFormatEmptyFile() throws IOException {\n+        Assert.assertFalse(medlineImporter.isRecognizedFormat(emptyFileStream));\n+    }\n+\n+    @Test\n+    public void testImportMalformedEntry() throws IOException {\n+        try (InputStream is = MedlineImporter.class.getResourceAsStream(\"MedlineImporterMalformedEntryTest.xml\")) {\n+            medlineImporter.importEntries(is, new OutputPrinterToNull());\n+        }\n+    }\n+\n+    @Test\n+    public void testImportEntryWithArticleID() throws IOException {\n+        checkImportEntriesAgainstBibFileEntries(\"MedlineImporterArticleIDTest.xml\",\n+                \"MedlineImporterArticleIDTestBib.bib\");\n+        try (InputStream shouldBeIs = MedlineImporter.class.getResourceAsStream(\"MedlineImporterArticleIDTest.xml\");\n+                InputStream bibIn = MedlineImporter.class.getResourceAsStream(\"MedlineImporterArticleIDTestBib.bib\")) {\n+            List<BibEntry> entries = medlineImporter.importEntries(shouldBeIs, new OutputPrinterToNull());\n+            BibtexEntryAssert.assertEquals(bibIn, entries);\n+        }\n+    }\n+\n+    @Test\n+    public void testImportSingleEntry() throws IOException {\n+        checkImportEntriesAgainstBibFileEntries(\"MedlineImporterSingleEntryTest.xml\",\n+                \"MedlineImporterSingleEntryTestBib.bib\");\n+    }\n+\n+    @Test\n+    public void testEntriesWithMinimalFields() throws IOException {\n+        checkImportEntriesAgainstBibFileEntries(\"MedlineImporterMinimalEntryTest.xml\",\n+                \"MedlineImporterMinimalEntryTestBib.bib\");\n+    }\n+\n+    private void checkImportEntriesAgainstBibFileEntries(String medlineFile, String bibTexFile) throws IOException {\n+        try (InputStream is = MedlineImporter.class.getResourceAsStream(medlineFile);\n+                InputStream nis = MedlineImporter.class.getResourceAsStream(bibTexFile)) {\n+            List<BibEntry> entries = medlineImporter.importEntries(is, new OutputPrinterToNull());\n+            BibtexEntryAssert.assertEquals(nis, entries);\n+        }\n+    }\n+\n+    @Test\n+    public void testGetFormatName() {\n+        assertEquals(\"Medline\", medlineImporter.getFormatName());\n+    }\n+\n+    @Test\n+    public void testGetCLIId() {\n+        assertEquals(\"medline\", medlineImporter.getCLIId());\n+    }\n+\n+    @Test\n+    public void testFetchMedline() {\n+        List<BibEntry> validMedLine = medlineImporter.fetchMedline(\"1\", new OutputPrinterToNull());\n+        List<BibEntry> emptyMedLine = medlineImporter.fetchMedline(\"zzzzzz\", new OutputPrinterToNull());\n+        assertNotNull(validMedLine);\n+        assertEquals(0, emptyMedLine.size());","path":"src/test/java/net/sf/jabref/importer/fileformat/MedlineImporterTest.java","position":125,"original_position":125,"commit_id":"421f5f4ce1df5ec1a4bb235d3709a5880ac7bc8f","original_commit_id":"421f5f4ce1df5ec1a4bb235d3709a5880ac7bc8f","user":{"login":"tschechlovdev","id":15339876,"avatar_url":"https://avatars.githubusercontent.com/u/15339876?v=3","gravatar_id":"","url":"https://api.github.com/users/tschechlovdev","html_url":"https://github.com/tschechlovdev","followers_url":"https://api.github.com/users/tschechlovdev/followers","following_url":"https://api.github.com/users/tschechlovdev/following{/other_user}","gists_url":"https://api.github.com/users/tschechlovdev/gists{/gist_id}","starred_url":"https://api.github.com/users/tschechlovdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschechlovdev/subscriptions","organizations_url":"https://api.github.com/users/tschechlovdev/orgs","repos_url":"https://api.github.com/users/tschechlovdev/repos","events_url":"https://api.github.com/users/tschechlovdev/events{/privacy}","received_events_url":"https://api.github.com/users/tschechlovdev/received_events","type":"User","site_admin":false},"body":"Use assertEquals(Collections.EMPTY_LIST, emptyMedline) instead","created_at":"2016-04-15T08:37:34Z","updated_at":"2016-04-15T08:37:34Z","html_url":"https://github.com/JabRef/jabref/pull/547#discussion_r59843029","pull_request_url":"https://api.github.com/repos/JabRef/jabref/pulls/547","_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments/59843029"},"html":{"href":"https://github.com/JabRef/jabref/pull/547#discussion_r59843029"},"pull_request":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/547"}}},"pull_request":{"url":"https://api.github.com/repos/JabRef/jabref/pulls/547","id":54203716,"html_url":"https://github.com/JabRef/jabref/pull/547","diff_url":"https://github.com/JabRef/jabref/pull/547.diff","patch_url":"https://github.com/JabRef/jabref/pull/547.patch","issue_url":"https://api.github.com/repos/JabRef/jabref/issues/547","number":547,"state":"open","locked":false,"title":"[WIP] MedlineImporterTest","user":{"login":"bruehldev","id":15344369,"avatar_url":"https://avatars.githubusercontent.com/u/15344369?v=3","gravatar_id":"","url":"https://api.github.com/users/bruehldev","html_url":"https://github.com/bruehldev","followers_url":"https://api.github.com/users/bruehldev/followers","following_url":"https://api.github.com/users/bruehldev/following{/other_user}","gists_url":"https://api.github.com/users/bruehldev/gists{/gist_id}","starred_url":"https://api.github.com/users/bruehldev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruehldev/subscriptions","organizations_url":"https://api.github.com/users/bruehldev/orgs","repos_url":"https://api.github.com/users/bruehldev/repos","events_url":"https://api.github.com/users/bruehldev/events{/privacy}","received_events_url":"https://api.github.com/users/bruehldev/received_events","type":"User","site_admin":false},"body":"New PR started because the old one was on a wrong branch.\r\n\r\nMedlineImporTest + Testfile added\r\n\r\nCouldn't cover two exceptions in importEntries.\r\n","created_at":"2015-12-20T17:26:13Z","updated_at":"2016-04-15T08:37:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6cba239e545aa4179c748aa7c1434fbaf269460","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JabRef/jabref/pulls/547/commits","review_comments_url":"https://api.github.com/repos/JabRef/jabref/pulls/547/comments","review_comment_url":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JabRef/jabref/issues/547/comments","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/421f5f4ce1df5ec1a4bb235d3709a5880ac7bc8f","head":{"label":"mairdl:MedlineImporter","ref":"MedlineImporter","sha":"421f5f4ce1df5ec1a4bb235d3709a5880ac7bc8f","user":{"login":"mairdl","id":15333533,"avatar_url":"https://avatars.githubusercontent.com/u/15333533?v=3","gravatar_id":"","url":"https://api.github.com/users/mairdl","html_url":"https://github.com/mairdl","followers_url":"https://api.github.com/users/mairdl/followers","following_url":"https://api.github.com/users/mairdl/following{/other_user}","gists_url":"https://api.github.com/users/mairdl/gists{/gist_id}","starred_url":"https://api.github.com/users/mairdl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mairdl/subscriptions","organizations_url":"https://api.github.com/users/mairdl/orgs","repos_url":"https://api.github.com/users/mairdl/repos","events_url":"https://api.github.com/users/mairdl/events{/privacy}","received_events_url":"https://api.github.com/users/mairdl/received_events","type":"User","site_admin":false},"repo":{"id":47971362,"name":"jabref","full_name":"mairdl/jabref","owner":{"login":"mairdl","id":15333533,"avatar_url":"https://avatars.githubusercontent.com/u/15333533?v=3","gravatar_id":"","url":"https://api.github.com/users/mairdl","html_url":"https://github.com/mairdl","followers_url":"https://api.github.com/users/mairdl/followers","following_url":"https://api.github.com/users/mairdl/following{/other_user}","gists_url":"https://api.github.com/users/mairdl/gists{/gist_id}","starred_url":"https://api.github.com/users/mairdl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mairdl/subscriptions","organizations_url":"https://api.github.com/users/mairdl/orgs","repos_url":"https://api.github.com/users/mairdl/repos","events_url":"https://api.github.com/users/mairdl/events{/privacy}","received_events_url":"https://api.github.com/users/mairdl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mairdl/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":true,"url":"https://api.github.com/repos/mairdl/jabref","forks_url":"https://api.github.com/repos/mairdl/jabref/forks","keys_url":"https://api.github.com/repos/mairdl/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mairdl/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mairdl/jabref/teams","hooks_url":"https://api.github.com/repos/mairdl/jabref/hooks","issue_events_url":"https://api.github.com/repos/mairdl/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/mairdl/jabref/events","assignees_url":"https://api.github.com/repos/mairdl/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/mairdl/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/mairdl/jabref/tags","blobs_url":"https://api.github.com/repos/mairdl/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mairdl/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mairdl/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/mairdl/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mairdl/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/mairdl/jabref/languages","stargazers_url":"https://api.github.com/repos/mairdl/jabref/stargazers","contributors_url":"https://api.github.com/repos/mairdl/jabref/contributors","subscribers_url":"https://api.github.com/repos/mairdl/jabref/subscribers","subscription_url":"https://api.github.com/repos/mairdl/jabref/subscription","commits_url":"https://api.github.com/repos/mairdl/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/mairdl/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/mairdl/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/mairdl/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/mairdl/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/mairdl/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mairdl/jabref/merges","archive_url":"https://api.github.com/repos/mairdl/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mairdl/jabref/downloads","issues_url":"https://api.github.com/repos/mairdl/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/mairdl/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/mairdl/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/mairdl/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mairdl/jabref/labels{/name}","releases_url":"https://api.github.com/repos/mairdl/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/mairdl/jabref/deployments","created_at":"2015-12-14T11:34:23Z","updated_at":"2016-04-13T13:56:19Z","pushed_at":"2016-04-14T22:40:11Z","git_url":"git://github.com/mairdl/jabref.git","ssh_url":"git@github.com:mairdl/jabref.git","clone_url":"https://github.com/mairdl/jabref.git","svn_url":"https://github.com/mairdl/jabref","homepage":"http://www.jabref.org/","size":76718,"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":"JabRef:master","ref":"master","sha":"416d8494955e06c58ccad8b868563baab56a86d2","user":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"repo":{"id":17634071,"name":"jabref","full_name":"JabRef/jabref","owner":{"login":"JabRef","id":3914421,"avatar_url":"https://avatars.githubusercontent.com/u/3914421?v=3","gravatar_id":"","url":"https://api.github.com/users/JabRef","html_url":"https://github.com/JabRef","followers_url":"https://api.github.com/users/JabRef/followers","following_url":"https://api.github.com/users/JabRef/following{/other_user}","gists_url":"https://api.github.com/users/JabRef/gists{/gist_id}","starred_url":"https://api.github.com/users/JabRef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JabRef/subscriptions","organizations_url":"https://api.github.com/users/JabRef/orgs","repos_url":"https://api.github.com/users/JabRef/repos","events_url":"https://api.github.com/users/JabRef/events{/privacy}","received_events_url":"https://api.github.com/users/JabRef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JabRef/jabref","description":"Graphical Java application for managing bibtex (.bib) databases","fork":false,"url":"https://api.github.com/repos/JabRef/jabref","forks_url":"https://api.github.com/repos/JabRef/jabref/forks","keys_url":"https://api.github.com/repos/JabRef/jabref/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JabRef/jabref/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JabRef/jabref/teams","hooks_url":"https://api.github.com/repos/JabRef/jabref/hooks","issue_events_url":"https://api.github.com/repos/JabRef/jabref/issues/events{/number}","events_url":"https://api.github.com/repos/JabRef/jabref/events","assignees_url":"https://api.github.com/repos/JabRef/jabref/assignees{/user}","branches_url":"https://api.github.com/repos/JabRef/jabref/branches{/branch}","tags_url":"https://api.github.com/repos/JabRef/jabref/tags","blobs_url":"https://api.github.com/repos/JabRef/jabref/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JabRef/jabref/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JabRef/jabref/git/refs{/sha}","trees_url":"https://api.github.com/repos/JabRef/jabref/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JabRef/jabref/statuses/{sha}","languages_url":"https://api.github.com/repos/JabRef/jabref/languages","stargazers_url":"https://api.github.com/repos/JabRef/jabref/stargazers","contributors_url":"https://api.github.com/repos/JabRef/jabref/contributors","subscribers_url":"https://api.github.com/repos/JabRef/jabref/subscribers","subscription_url":"https://api.github.com/repos/JabRef/jabref/subscription","commits_url":"https://api.github.com/repos/JabRef/jabref/commits{/sha}","git_commits_url":"https://api.github.com/repos/JabRef/jabref/git/commits{/sha}","comments_url":"https://api.github.com/repos/JabRef/jabref/comments{/number}","issue_comment_url":"https://api.github.com/repos/JabRef/jabref/issues/comments{/number}","contents_url":"https://api.github.com/repos/JabRef/jabref/contents/{+path}","compare_url":"https://api.github.com/repos/JabRef/jabref/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JabRef/jabref/merges","archive_url":"https://api.github.com/repos/JabRef/jabref/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JabRef/jabref/downloads","issues_url":"https://api.github.com/repos/JabRef/jabref/issues{/number}","pulls_url":"https://api.github.com/repos/JabRef/jabref/pulls{/number}","milestones_url":"https://api.github.com/repos/JabRef/jabref/milestones{/number}","notifications_url":"https://api.github.com/repos/JabRef/jabref/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JabRef/jabref/labels{/name}","releases_url":"https://api.github.com/repos/JabRef/jabref/releases{/id}","deployments_url":"https://api.github.com/repos/JabRef/jabref/deployments","created_at":"2014-03-11T14:48:42Z","updated_at":"2016-04-13T19:57:31Z","pushed_at":"2016-04-15T07:23:31Z","git_url":"git://github.com/JabRef/jabref.git","ssh_url":"git@github.com:JabRef/jabref.git","clone_url":"https://github.com/JabRef/jabref.git","svn_url":"https://github.com/JabRef/jabref","homepage":"http://www.jabref.org/","size":81484,"stargazers_count":262,"watchers_count":262,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":179,"mirror_url":null,"open_issues_count":177,"forks":179,"open_issues":177,"watchers":262,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/547"},"html":{"href":"https://github.com/JabRef/jabref/pull/547"},"issue":{"href":"https://api.github.com/repos/JabRef/jabref/issues/547"},"comments":{"href":"https://api.github.com/repos/JabRef/jabref/issues/547/comments"},"review_comments":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/547/comments"},"review_comment":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JabRef/jabref/pulls/547/commits"},"statuses":{"href":"https://api.github.com/repos/JabRef/jabref/statuses/421f5f4ce1df5ec1a4bb235d3709a5880ac7bc8f"}}}}