use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseSavesOneNewlineAfterEntryInParsedSerialization.
@Test
public void parseSavesOneNewlineAfterEntryInParsedSerialization() throws IOException {
String testEntry = "@article{test,author={Ed von Test}}";
ParserResult result = parser.parse(new StringReader(testEntry + OS.NEWLINE + OS.NEWLINE));
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals(testEntry + OS.NEWLINE, e.getParsedSerialization());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesEntryWithUnknownType.
@Test
public void parseRecognizesEntryWithUnknownType() throws IOException {
ParserResult result = parser.parse(new StringReader("@unknown{test,author={Ed von Test}}"));
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals("unknown", 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 parseRecognizesEntryWithAtInField.
@Test
public void parseRecognizesEntryWithAtInField() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author={Ed von T@st}}"));
List<BibEntry> parsed = result.getDatabase().getEntries();
BibEntry expected = new BibEntry("article").withField(BibEntry.KEY_FIELD, "test").withField("author", "Ed von T@st");
assertEquals(Collections.singletonList(expected), parsed);
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseFileHeaderAndPreambleWithoutNewLine.
/**
* Test for #669
*/
@Test
public void parseFileHeaderAndPreambleWithoutNewLine() throws IOException {
ParserResult result = parser.parse(new StringReader("% Encoding: US-ASCII@preamble{some text and \\latex}"));
assertFalse(result.hasWarnings());
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 parseIgnoresUpercaseComments.
@Test
public void parseIgnoresUpercaseComments() throws IOException {
ParserResult result = parser.parse(new StringReader("@COMMENT{some text and \\latex}"));
assertEquals(0, result.getDatabase().getEntries().size());
}
Aggregations