-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created MedlinePlainImporter test class and fixed IndexOutOfBoundsExc…
…eption
- Loading branch information
Showing
4 changed files
with
217 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/test/java/net/sf/jabref/importer/fileformat/MedlinePlainImporterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package net.sf.jabref.importer.fileformat; | ||
|
||
import java.io.InputStream; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import net.sf.jabref.Globals; | ||
import net.sf.jabref.JabRefPreferences; | ||
import net.sf.jabref.importer.OutputPrinterToNull; | ||
import net.sf.jabref.model.entry.BibtexEntry; | ||
|
||
/** | ||
* | ||
* @author tschechlovdev,bocekts | ||
* | ||
*/ | ||
|
||
public class MedlinePlainImporterTest { | ||
|
||
private MedlinePlainImporter importer; | ||
|
||
|
||
@Before | ||
public void setUp() throws Exception { | ||
if (Globals.prefs == null) { | ||
Globals.prefs = JabRefPreferences.getInstance(); | ||
} | ||
importer = new MedlinePlainImporter(); | ||
} | ||
|
||
@Test | ||
public void testIsRecognizedFormat() throws Exception { | ||
|
||
LinkedList<String> list = new LinkedList<>(); | ||
list.add("CopacImporterTest1.txt"); | ||
list.add("CopacImporterTest2.txt"); | ||
list.add("IsiImporterTest1.isi"); | ||
list.add("IsiImporterTestInspec.isi"); | ||
list.add("IsiImporterTestWOS.isi"); | ||
list.add("IsiImporterTestMedline.isi"); | ||
list.add("MedlinePlainImporterTestEmpty.txt"); | ||
|
||
//Test with txt Files which are not in recognized Format | ||
for (String str : list) { | ||
try (InputStream is = MedlinePlainImporter.class.getResourceAsStream(str)) { | ||
Assert.assertFalse(importer.isRecognizedFormat(is)); | ||
} | ||
} | ||
|
||
//Test with txt File which is in recognized Format | ||
Assert.assertTrue(importer.isRecognizedFormat(MedlinePlainImporter.class | ||
.getResourceAsStream("MedlinePlainImporterTest.txt"))); | ||
|
||
} | ||
|
||
@Test | ||
public void testImportEntries() throws Exception { | ||
|
||
//create entries list from the txt file | ||
List<BibtexEntry> entries = importer.importEntries( | ||
MedlinePlainImporter.class.getResourceAsStream("MedlinePLainImporterTest.txt"), | ||
new OutputPrinterToNull()); | ||
Assert.assertEquals(7, entries.size()); | ||
|
||
//create Bibtexentry from first/second object in the entry list | ||
//and test with getField | ||
BibtexEntry test1 = entries.get(0); | ||
Assert.assertNull(test1.getField("month")); | ||
Assert.assertEquals("Long, Vicky and Marland, Hilary", test1.getField("author")); | ||
Assert.assertEquals( | ||
"From danger and motherhood to health and beauty: health advice for the factory girl in early twentieth-century Britain.", | ||
test1.getField("title")); | ||
BibtexEntry test2 = entries.get(1); | ||
Assert.assertEquals("06", test2.getField("month")); | ||
Assert.assertNull(test2.getField("author")); | ||
Assert.assertNull(test2.getField("title")); | ||
|
||
//Test entries with empty txt File | ||
List<BibtexEntry> emptyEntries = importer.importEntries( | ||
MedlinePlainImporter.class.getResourceAsStream("MedlinePLainImporterTestEmpty.txt"), | ||
new OutputPrinterToNull()); | ||
Assert.assertEquals(0, emptyEntries.size()); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetFormatName() { | ||
Assert.assertNotEquals("", importer.getFormatName()); | ||
Assert.assertNotEquals("medlineplain", importer.getFormatName()); | ||
Assert.assertEquals("MedlinePlain", importer.getFormatName()); | ||
} | ||
|
||
@Test | ||
public void testGetCLIId() { | ||
Assert.assertNotEquals("", importer.getCLIId()); | ||
Assert.assertNotEquals("MedlinePlain", importer.getCLIId()); | ||
Assert.assertEquals("medlineplain", importer.getCLIId()); | ||
} | ||
|
||
} |
109 changes: 109 additions & 0 deletions
109
src/test/resources/net/sf/jabref/importer/fileformat/MedlinePLainImporterTest.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
PMID- 20481061 | ||
OWN - NLM | ||
STAT- MEDLINE | ||
DA - 20100520 | ||
DCOM- 20100526 | ||
LR - 20150731 | ||
IS - 0955-2359 (Print) | ||
IS - 0955-2359 (Linking) | ||
VI - 20 | ||
IP - 4 | ||
DP - 2009 | ||
TI - From danger and motherhood to health and beauty: health advice for the factory | ||
girl in early twentieth-century Britain. | ||
PG - 454-81 | ||
AB - A survey of government reports and the archives and journals of other agencies | ||
interested in industrial health in early twentieth-century Britain has led us to | ||
conclude that, in addition to apprehension about the potentially harmful impact | ||
of industrial work on the reproductive health of women, there was a great deal of | ||
interest in the health of young, unmarried girls in the workplace, particularly | ||
the factory. Adopting a broader time frame, we suggest that the First World War, | ||
with its emphasis on the reproductive health of women, was an anomalous | ||
experience in a broader trend which stressed the growing acceptability of women's | ||
work within industry. Concern with girls' health and welfare embraced hygiene, | ||
diet, exercise, recreation, fashion and beauty within and outside of the | ||
workplace, as well as the impact of the boredom and monotony associated with | ||
industrial work. The health problems of young women workers tended to be | ||
associated with behaviour and environment rather than biology, as were anxieties | ||
about the impact of work on morals, habits and character. Efforts to ensure that | ||
young female factory workers would be equipped to take their place as citizens | ||
and parents, we argue, often dovetailed rather than diverged with the 'boy | ||
labour' question. | ||
FAU - Long, Vicky | ||
AU - Long V | ||
AD - Centre for the History of Science, Technology and Medicine, University of | ||
Manchester. Vicky.Long@manchester.ac.uk | ||
FAU - Marland, Hilary | ||
AU - Marland H | ||
LA - eng | ||
GR - /076053/Z/04/Z/Wellcome Trust/United Kingdom | ||
GR - 076053/Wellcome Trust/United Kingdom | ||
PT - Historical Article | ||
PT - Journal Article | ||
PT - Research Support, Non-U.S. Gov't | ||
PL - England | ||
TA - 20 Century Br Hist | ||
JT - 20 century British history | ||
JID - 9015384 | ||
SB - QIS | ||
MH - Attitude to Health | ||
MH - Employment/psychology | ||
MH - Female | ||
MH - Gender Identity | ||
MH - Great Britain | ||
MH - History, 20th Century | ||
MH - Humans | ||
MH - Occupational Health/*history | ||
MH - Reproductive Medicine/*history | ||
MH - Women, Working/*history/psychology | ||
PMC - PMC4513071 | ||
MID - EMS54115 | ||
OID - NLM: EMS54115 | ||
OID - NLM: PMC4513071 | ||
EDAT- 2009/01/01 00:00 | ||
MHDA- 2010/05/27 06:00 | ||
CRDT- 2010/05/21 06:00 | ||
PST - ppublish | ||
SO - 20 Century Br Hist. 2009;20(4):454-81. | ||
|
||
This line should be omitted by the importer. | ||
|
||
PMC -22664230 | ||
TI- | ||
BTI - | ||
FAU - | ||
FED - Some Editor | ||
PT - Clinical Conference | ||
FED - Some test data | ||
JT - Test Journal | ||
PG - | ||
PL - | ||
IS - | ||
VI - | ||
AB - Old Abstract | ||
AB - new abstract | ||
DP - 2013 06 10 | ||
MH - | ||
AID - | ||
CON - First Comment | ||
CIN - Different Comment | ||
|
||
PMCR- 20481061 | ||
TI - This is a Testtitle | ||
TI - This title should be appended: | ||
TI - This title should also be appended | ||
PT - Book | ||
|
||
PMID-22664220 | ||
PT - Technical Report | ||
AID - doi:10.1016/j.cpr.2005.02.002 | ||
|
||
PMID-22664238 | ||
PT - Editorial | ||
JT - Inproceedings book title | ||
|
||
PMID-96578310 | ||
PT - Overall | ||
|
||
PMID-45984220 | ||
PT - |
Empty file.