use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method integrationTestSaveOrderConfig.
@Test
public void integrationTestSaveOrderConfig() throws IOException {
ParserResult result = BibtexParser.parse(new StringReader("@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"), importFormatPreferences);
Optional<SaveOrderConfig> saveOrderConfig = result.getMetaData().getSaveOrderConfig();
assertEquals(new SaveOrderConfig(false, new SaveOrderConfig.SortCriterion("author", false), new SaveOrderConfig.SortCriterion("year", true), new SaveOrderConfig.SortCriterion("abstract", false)), saveOrderConfig.get());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesUppercasePreamble.
@Test
public void parseRecognizesUppercasePreamble() throws IOException {
ParserResult result = parser.parse(new StringReader("@PREAMBLE{some text and \\latex}"));
assertEquals(Optional.of("some text and \\latex"), result.getDatabase().getPreamble());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseSavesNewlinesBetweenEntriesInParsedSerialization.
@Test
public void parseSavesNewlinesBetweenEntriesInParsedSerialization() throws IOException {
String testEntryOne = "@article{test1,author={Ed von Test}}";
String testEntryTwo = "@article{test2,author={Ed von Test}}";
ParserResult result = parser.parse(new StringReader(testEntryOne + OS.NEWLINE + OS.NEWLINE + OS.NEWLINE + testEntryTwo));
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(2, c.size());
Iterator<BibEntry> i = c.iterator();
BibEntry a = i.next();
BibEntry b = i.next();
// Sort them because we can't be sure about the order
if (a.getCiteKeyOptional().equals(Optional.of("test2"))) {
BibEntry tmp = a;
a = b;
b = tmp;
}
assertEquals(testEntryOne + OS.NEWLINE, a.getParsedSerialization());
assertEquals(OS.NEWLINE + OS.NEWLINE + testEntryTwo, b.getParsedSerialization());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseHandlesAccentsCorrectly.
/**
* Test for #650
*/
@Test
public void parseHandlesAccentsCorrectly() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author = {H\'{e}lne Fiaux}}"));
assertFalse(result.hasWarnings());
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 parseIgnoresCommentsAfterEntry.
@Test
public void parseIgnoresCommentsAfterEntry() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author={Ed von Test}}" + "@comment{some text and \\latex}"));
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(2, e.getFieldNames().size());
assertEquals(Optional.of("Ed von Test"), e.getField("author"));
}
Aggregations