use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parsePreambleAndEntryWithoutNewLine.
/**
* Test for #669
*/
@Test
public void parsePreambleAndEntryWithoutNewLine() throws IOException {
ParserResult result = parser.parse(new StringReader("@preamble{some text and \\latex}@article{test,author = {H\'{e}lne Fiaux}}"));
assertFalse(result.hasWarnings());
assertEquals(Optional.of("some text and \\latex"), result.getDatabase().getPreamble());
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals("article", e.getType());
assertEquals(Optional.of("test"), e.getCiteKeyOptional());
assertEquals(Optional.of("H\'{e}lne Fiaux"), e.getField("author"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesFormatedEntry.
@Test
public void parseRecognizesFormatedEntry() throws IOException {
ParserResult result = BibtexParser.parse(new StringReader("" + "@INPROCEEDINGS{CroAnnHow05," + "\n" + " author = {Crowston, K. and Annabi, H. and Howison, J. and Masango, C.}," + "\n" + " title = {Effective work practices for floss development: A model and propositions}," + "\n" + " booktitle = {Hawaii International Conference On System Sciences (HICSS)}," + "\n" + " year = {2005}," + "\n" + " owner = {oezbek}," + "\n" + " timestamp = {2006.05.29}," + "\n" + " url = {http://james.howison.name/publications.html}" + "\n" + "}))"), importFormatPreferences);
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals("inproceedings", e.getType());
assertEquals(8, e.getFieldNames().size());
assertEquals(Optional.of("CroAnnHow05"), e.getCiteKeyOptional());
assertEquals(Optional.of("Crowston, K. and Annabi, H. and Howison, J. and Masango, C."), e.getField("author"));
assertEquals(Optional.of("Effective work practices for floss development: A model and propositions"), e.getField("title"));
assertEquals(Optional.of("Hawaii International Conference On System Sciences (HICSS)"), e.getField("booktitle"));
assertEquals(Optional.of("2005"), e.getField("year"));
assertEquals(Optional.of("oezbek"), e.getField("owner"));
assertEquals(Optional.of("2006.05.29"), e.getField("timestamp"));
assertEquals(Optional.of("http://james.howison.name/publications.html"), e.getField("url"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesEntryWithWhitespace.
@Test
public void parseRecognizesEntryWithWhitespace() throws IOException {
ParserResult result = parser.parse(new StringReader("@article { test,author={Ed von Test}}"));
List<BibEntry> parsed = result.getDatabase().getEntries();
assertEquals(1, parsed.size());
BibEntry e = parsed.iterator().next();
assertEquals("article", e.getType());
assertEquals(Optional.of("test"), e.getCiteKeyOptional());
assertEquals(2, e.getFieldNames().size());
assertEquals(Optional.of("Ed von Test"), e.getField("author"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseNotWarnsAboutEntryWithoutBibtexKey.
@Test
public void parseNotWarnsAboutEntryWithoutBibtexKey() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{,author={Ed von Test}}"));
assertFalse(result.hasWarnings());
Collection<BibEntry> c = result.getDatabase().getEntries();
BibEntry e = new BibEntry();
e.setField("author", "Ed von Test");
e.setType("article");
assertEquals(Collections.singletonList(e), c);
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseIgnoresAndWarnsAboutEntryWithUnmatchedOpenBracket.
@Test
public void parseIgnoresAndWarnsAboutEntryWithUnmatchedOpenBracket() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author={author missing bracket}"));
assertTrue(result.hasWarnings());
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(0, c.size());
}
Aggregations