use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class BibDatabaseTestsWithFiles method resolveStrings.
@Test
public void resolveStrings() throws IOException {
try (FileInputStream stream = new FileInputStream("src/test/resources/org/jabref/util/twente.bib");
InputStreamReader fr = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
ParserResult result = new BibtexParser(importFormatPreferences).parse(fr);
BibDatabase db = result.getDatabase();
assertEquals("Arvind", db.resolveForStrings("#Arvind#"));
assertEquals("Patterson, David", db.resolveForStrings("#Patterson#"));
assertEquals("Arvind and Patterson, David", db.resolveForStrings("#Arvind# and #Patterson#"));
// Strings that are not found return just the given string.
assertEquals("#unknown#", db.resolveForStrings("#unknown#"));
}
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class OpenDatabaseTest method entriesAreParsedNoHeader.
@Test
public void entriesAreParsedNoHeader() throws IOException {
ParserResult result = OpenDatabase.loadDatabase(bibNoHeader, importFormatPreferences);
BibDatabase db = result.getDatabase();
// Entry
Assert.assertEquals(1, db.getEntryCount());
Assert.assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year"));
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class OpenDatabaseTest method entriesAreParsedHeaderAndSignature.
@Test
public void entriesAreParsedHeaderAndSignature() throws IOException {
ParserResult result = OpenDatabase.loadDatabase(bibHeaderAndSignature, importFormatPreferences);
BibDatabase db = result.getDatabase();
// Entry
Assert.assertEquals(1, db.getEntryCount());
Assert.assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year"));
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class IntegrityCheckTest method createContext.
private BibDatabaseContext createContext(String field, String value, MetaData metaData) {
BibEntry entry = new BibEntry();
entry.setField(field, value);
BibDatabase bibDatabase = new BibDatabase();
bibDatabase.insertEntry(entry);
return new BibDatabaseContext(bibDatabase, metaData, new Defaults());
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class OOBibStyleTest method testEmptyEntryMarker.
@Test
public void testEmptyEntryMarker() throws IOException {
OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
Map<BibEntry, BibDatabase> entryDBMap = new HashMap<>();
List<BibEntry> entries = new ArrayList<>();
BibDatabase database = new BibDatabase();
BibEntry entry = new BibEntry();
entry.setType("article");
database.insertEntry(entry);
entries.add(entry);
entryDBMap.put(entry, database);
assertEquals("[, ]", style.getCitationMarker(entries, entryDBMap, true, null, null));
}
Aggregations