Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SilverPlatterImporterTest #510

Merged
merged 1 commit into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public List<BibEntry> importEntries(InputStream stream, OutputPrinter status) th
h.put("editor",
AuthorList.fixAuthorLastNameFirst(ed.replace(",-", ", ").replace(";", " and ")));
} else {
h.put("author", AuthorList
.fixAuthorLastNameFirst(frest.replace(",-", ", ").replace(";", " and ")));
h.put("author",
AuthorList.fixAuthorLastNameFirst(frest.replace(",-", ", ").replace(";", " and ")));
}
} else if ("AB".equals(f3)) {
h.put("abstract", frest);
Expand All @@ -143,10 +143,13 @@ public List<BibEntry> importEntries(InputStream stream, OutputPrinter status) th
h.put("year", yr);
frest = frest.substring(m);
m = frest.indexOf(':');
int issueIndex = frest.indexOf('(');
int endIssueIndex = frest.indexOf(')');
if (m >= 0) {
String pg = frest.substring(m + 1).trim();
h.put("pages", pg);
h.put("volume", frest.substring(1, m));
h.put("volume", frest.substring(1, issueIndex).trim());
h.put("issue", frest.substring(issueIndex + 1, endIssueIndex).trim());
}
}
}
Expand Down Expand Up @@ -197,14 +200,9 @@ public List<BibEntry> importEntries(InputStream stream, OutputPrinter status) th
if (titleO != null) {
String title = ((String) titleO).trim();
int inPos = title.indexOf("\" in ");
int pgPos = title.lastIndexOf(' ');
if (inPos > 1) {
h.put("title", title.substring(1, inPos));
h.put("title", title.substring(0, inPos));
}
if (pgPos > inPos) {
h.put("pages", title.substring(pgPos).replace("-", "--"));
}

}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package net.sf.jabref.importer.fileformat;

import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.bibtex.BibtexEntryAssert;
import net.sf.jabref.importer.OutputPrinterToNull;
import net.sf.jabref.model.entry.BibEntry;

@RunWith(Parameterized.class)
public class SilverPlatterImporterTest {

private SilverPlatterImporter testImporter;

@Parameter
public String filename;

public String txtName;
public String bibName;


@Before
public void setUp() throws Exception {
Globals.prefs = JabRefPreferences.getInstance();
testImporter = new SilverPlatterImporter();
txtName = filename + ".txt";
bibName = filename + ".bib";
}

@Parameters(name = "{index}: {0}")
public static Collection<Object[]> fileNames() {
Object[][] data = new Object[][] {{"SilverPlatterImporterTest1"}, {"SilverPlatterImporterTest2"}};
return Arrays.asList(data);
}

@Test
public final void testIsRecognizedFormat() throws Exception {
try (InputStream stream = SilverPlatterImporterTest.class.getResourceAsStream(txtName)) {
Assert.assertTrue(testImporter.isRecognizedFormat(stream));
}
}

@Test
public final void testImportEntries() throws Exception {
try (InputStream in = SilverPlatterImporter.class.getResourceAsStream(txtName);
InputStream bibIn = SilverPlatterImporterTest.class.getResourceAsStream(bibName)) {
List<BibEntry> entries = testImporter.importEntries(in, new OutputPrinterToNull());
BibtexEntryAssert.assertEquals(bibIn, entries);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.sf.jabref.importer.fileformat;

import java.io.InputStream;
import java.util.Arrays;
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;

public class SilverPlatterImporterTestNotRecognized {

public SilverPlatterImporter testImporter;


@Before
public void setUp() throws Exception {
Globals.prefs = JabRefPreferences.getInstance();
testImporter = new SilverPlatterImporter();
}

@Test
public final void testIsNotRecognizedFormat() throws Exception {
List<String> notAccept = Arrays.asList("emptyFile.xml", "IsiImporterTest1.isi",
"InspecSilverPlatterImporterTest.txt", "oai2.xml", "RisImporterTest1.ris");
for (String s : notAccept) {
try (InputStream stream = SilverPlatterImporter.class.getResourceAsStream(s)) {
Assert.assertFalse(testImporter.isRecognizedFormat(stream));
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Record INSPEC
TI- Simulation studies of multiple dipole neuromagnetic source localization: model order and limits of source resolution.

AU- Supek-S; Aine-CJ

AD- Neuromagnetism Laboratory, Los Alamos National Laboratory, NM 87545.

SO- IEEE-Trans-Biomed-Eng. 1993 Jun; 40(6): 529-40

ISSN- 0018-9294

PY- 1993

LA- ENGLISH

CP- UNITED-STATES

AB- Numerical

MESH- Data-Interpretation,-Statistical; Electromagnetic-Fields; Monte-Carlo-Method

MESH- *Magnetoencephalography-; *Models,-Biological; *Models,-Statistical

TG- Support,-U.S.-Gov't,-Non-P.H.S.; Support,-U.S.-Gov't,-P.H.S.

PT- JOURNAL-ARTICLE

CN- NEIEY08610EYNEI

AN- 94085977
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Article{,
author = {Supek-S and Aine-CJ},
issue = {6},
journal = {IEEE Trans Biomed Eng},
pages = {529-540},
title = {Simulation studies of multiple dipole neuromagnetic source localization, model order and limits of source resolution. },
volume = {40},
year = {1993},
abstract = {Numerical},
journal = {IEEE Trans Biomed Eng}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

TI: Simulation studies of multiple dipole neuromagnetic source localization, model order and limits of source resolution.
AU: Supek-S; Aine-CJ
AD: Neuromagnetism Laboratory, Los Alamos National Laboratory, NM 87545.
SO: IEEE-Trans-Biomed-Eng. , 1993;40(6) : 529-540
DT: journal
ISSN: 0018-9294
PY: 1993
LA: ENGLISH
CP: UNITED-STATES
AB: Numerical
MESH: Data-Interpretation,-Statistical; Electromagnetic-Fields; Monte-Carlo-Method
MESH: *Magnetoencephalography-; *Models,-Biological; *Models,-Statistical
TG: Support,-U.S.-Gov't,-Non-P.H.S.; Support,-U.S.-Gov't,-P.H.S.
PT: JOURNAL-ARTICLE
CN: NEIEY08610EYNEI
AN: 94085977
UD: 9403
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@Article{,
editor = {Supek-S and Aine-CJ},
journal = {IEEE Trans Biomed Eng},
keywords = {many-much-more-i don't know},
publisher = {New York publishment},
school = {Gymnasium Unterrieden},
title = {Simulation studies of multiple dipole neuromagnetic },
year = {3 Jun}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

TI: Simulation studies of multiple dipole neuromagnetic " in source localization: model order and limits of source resolution.
DT: journal
AU: Supek-S; Aine-CJ(ed)
DE: Many-much-more-i don't know
PB: New York publishment : 1993
PB: New York publishment : jdaksla
PB: New York publishment 1993
AF: Gymnasium Unterrieden
DT: Monograph
DT: Dissertation
DT: journal
DT: Contribution
DT: Chapter
DT: journal
SO: IEEE-Trans-Biomed-Eng 1993 Jun 40(6): 529-40
SO: IEEE-Trans-Biomed-Eng., 1993 Jun 40(6): 529-40
SO IEEE-Trans-Biomed-Eng., 1993 Jun; 40(6) 529-40
ISSN: 0018-9294
PY: 1993
LA: ENGLISH
CP: UNITED-STATES
MESH: Data-Interpretation,-Statistical; Electromagnetic-Fields; Monte-Carlo-Method
MESH: *Magnetoencephalography-; *Models,-Biological; *Models,-Statistical
TG: Support,-U.S.-Gov't,-Non-P.H.S.; Support,-U.S.-Gov't,-P.H.S.
PT: JOURNAL-ARTICLE
CN: NEIEY08610EYNEI
AN: 94085977
UD: 9403
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<child></child>