use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseCombinesMultipleKeywordsFields.
/**
* Test for SF Bug #1269
*/
@Test
public void parseCombinesMultipleKeywordsFields() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,Keywords={Test},Keywords={Second Keyword},Keywords={Third Keyword}}"));
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("Test, Second Keyword, Third Keyword"), e.getField("keywords"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesFieldsWithBracketsEnclosedInQuotationMarks.
@Test
public void parseRecognizesFieldsWithBracketsEnclosedInQuotationMarks() throws IOException {
ParserResult result = parser.parse(new StringReader("@article{test,author=\"Test {Ed {von} Test}\"}"));
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("Test {Ed {von} Test}"), e.getField("author"));
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesSaveActionsAfterEntry.
@Test
public void parseRecognizesSaveActionsAfterEntry() throws IOException {
BibtexParser parser = this.parser;
ParserResult parserResult = parser.parse(new StringReader("@InProceedings{6055279,\n" + " Title = {Educational session 1},\n" + " Booktitle = {Custom Integrated Circuits Conference (CICC), 2011 IEEE},\n" + " Year = {2011},\n" + " Month = {Sept},\n" + " Pages = {1-7},\n" + " Abstract = {Start of the above-titled section of the conference proceedings record.},\n" + " DOI = {10.1109/CICC.2011.6055279},\n" + " ISSN = {0886-5930}\n" + "}\n" + "\n" + "@comment{jabref-meta: saveActions:enabled;title[lower_case]}"));
FieldFormatterCleanups saveActions = parserResult.getMetaData().getSaveActions().get();
assertTrue(saveActions.isEnabled());
assertEquals(Collections.singletonList(new FieldFormatterCleanup("title", new LowerCaseFormatter())), saveActions.getConfiguredActions());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseCommentContainingEntries.
@Test
public void parseCommentContainingEntries() throws IOException {
// @formatter:off
String bibtexEntry = "@Comment{@article{myarticle,}" + OS.NEWLINE + "@inproceedings{blabla, title={the proceedings of blabla}; }" + OS.NEWLINE + "} " + OS.NEWLINE + "@Article{test," + OS.NEWLINE + " Author = {Foo Bar}," + OS.NEWLINE + " Journal = {International Journal of Something}," + OS.NEWLINE + " Note = {some note}," + OS.NEWLINE + " Number = {1}" + OS.NEWLINE + "}";
// @formatter:on
ParserResult result = parser.parse(new StringReader(bibtexEntry));
Collection<BibEntry> entries = result.getDatabase().getEntries();
BibEntry entry = entries.iterator().next();
assertEquals(bibtexEntry, entry.getParsedSerialization());
}
use of org.jabref.logic.importer.ParserResult in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesFieldsWithEscapedQuotationMarks.
@Test
public void parseRecognizesFieldsWithEscapedQuotationMarks() throws IOException {
// Quotes in fields of the form key = "value" have to be escaped by putting them into braces
ParserResult result = parser.parse(new StringReader("@article{test,author=\"Test {\" Test}\"}"));
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("Test {\" Test}"), e.getField("author"));
}
Aggregations