Search in sources :

Example 36 with BibDatabase

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#"));
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BibtexParser(org.jabref.logic.importer.fileformat.BibtexParser) BibDatabase(org.jabref.model.database.BibDatabase) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 37 with BibDatabase

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"));
}
Also used : BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 38 with BibDatabase

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"));
}
Also used : BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 39 with BibDatabase

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());
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Defaults(org.jabref.model.Defaults) BibDatabase(org.jabref.model.database.BibDatabase) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext)

Example 40 with BibDatabase

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));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Aggregations

BibDatabase (org.jabref.model.database.BibDatabase)88 BibEntry (org.jabref.model.entry.BibEntry)60 Test (org.junit.Test)44 ParserResult (org.jabref.logic.importer.ParserResult)20 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)15 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)15 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)13 MetaData (org.jabref.model.metadata.MetaData)12 IOException (java.io.IOException)10 Defaults (org.jabref.model.Defaults)9 Before (org.junit.Before)9 File (java.io.File)8 InputStreamReader (java.io.InputStreamReader)8 InputStream (java.io.InputStream)7 PropertyVetoException (com.sun.star.beans.PropertyVetoException)6 UnknownPropertyException (com.sun.star.beans.UnknownPropertyException)6 WrappedTargetException (com.sun.star.lang.WrappedTargetException)6 LinkedHashMap (java.util.LinkedHashMap)5 BasePanel (org.jabref.gui.BasePanel)5