Search in sources :

Example 31 with BibDatabase

use of org.jabref.model.database.BibDatabase in project jabref by JabRef.

the class BibtexKeyPatternUtilTest method testSchool.

@Test
public void testSchool() throws ParseException {
    Optional<BibEntry> entry = BibtexParser.singleFromString("@ARTICLE{kohn, author={{Link{\\\"{o}}ping University, School of Computer Engineering}}}", importFormatPreferences);
    assertEquals("UniLinkoepingCE", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry.get(), "auth", ',', new BibDatabase()), true));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 32 with BibDatabase

use of org.jabref.model.database.BibDatabase in project jabref by JabRef.

the class BibtexKeyPatternUtilTest method testMakeLabelAndCheckLegalKeysAccentGrave.

/**
     * Test the Labelmaker and with accent grave Chars to test: "ÀÈÌÒÙ";
     */
@Test
public void testMakeLabelAndCheckLegalKeysAccentGrave() throws ParseException {
    Optional<BibEntry> entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Àöning}, year={2000}}", importFormatPreferences);
    assertEquals("Aoen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
    entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Èöning}, year={2000}}", importFormatPreferences);
    assertEquals("Eoen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
    entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ìöning}, year={2000}}", importFormatPreferences);
    assertEquals("Ioen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
    entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Òöning}, year={2000}}", importFormatPreferences);
    assertEquals("Ooen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
    entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ùöning}, year={2000}}", importFormatPreferences);
    assertEquals("Uoen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 33 with BibDatabase

use of org.jabref.model.database.BibDatabase in project jabref by JabRef.

the class RenamePdfCleanupTest method setUp.

@Before
public void setUp() throws Exception {
    MetaData metaData = new MetaData();
    context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
    context.setDatabaseFile(testFolder.newFile("test.bib"));
    fileDirPrefs = mock(FileDirectoryPreferences.class);
    //Set Biblocation as Primary Directory, otherwise the tmp folders won't be cleaned up correctly
    when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(true);
    entry = new BibEntry();
    entry.setCiteKey("Toot");
    layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS);
}
Also used : FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) BibEntry(org.jabref.model.entry.BibEntry) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Defaults(org.jabref.model.Defaults) MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Example 34 with BibDatabase

use of org.jabref.model.database.BibDatabase in project jabref by JabRef.

the class MoveFilesCleanupTest method setUp.

@Before
public void setUp() throws IOException {
    MetaData metaData = new MetaData();
    pdfFolder = bibFolder.newFolder();
    metaData.setDefaultFileDirectory(pdfFolder.getAbsolutePath());
    databaseContext = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
    databaseContext.setDatabaseFile(bibFolder.newFile("test.bib"));
    entry = new BibEntry();
    entry.setCiteKey("Toot");
    entry.setField("title", "test title");
    fileDirPrefs = mock(FileDirectoryPreferences.class);
    //Biblocation as Primary overwrites all other dirs, therefore we set it to false here
    when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(false);
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) Defaults(org.jabref.model.Defaults) MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Example 35 with BibDatabase

use of org.jabref.model.database.BibDatabase in project jabref by JabRef.

the class OpenDatabaseTest method entriesAreParsedHeader.

@Test
public void entriesAreParsedHeader() throws IOException {
    ParserResult result = OpenDatabase.loadDatabase(bibHeader, 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)

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