Search in sources :

Example 26 with BibDatabaseContext

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

the class BibDatabaseContextTest method testTypeBasedOnDefaultBiblatex.

@Test
public void testTypeBasedOnDefaultBiblatex() {
    BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new BibDatabase(), new MetaData(), new Defaults(BibDatabaseMode.BIBLATEX));
    assertEquals(BibDatabaseMode.BIBLATEX, bibDatabaseContext.getMode());
    bibDatabaseContext.setMode(BibDatabaseMode.BIBTEX);
    assertEquals(BibDatabaseMode.BIBTEX, bibDatabaseContext.getMode());
}
Also used : MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 27 with BibDatabaseContext

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

the class DBMSSynchronizerTest method setUp.

@Before
public void setUp() throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
    dbmsConnection = TestConnector.getTestDBMSConnection(dbmsType);
    bibDatabase = new BibDatabase();
    BibDatabaseContext context = new BibDatabaseContext(bibDatabase);
    pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
    dbmsSynchronizer = new DBMSSynchronizer(context, ',', pattern);
    dbmsProcessor = DBMSProcessor.getProcessorInstance(dbmsConnection);
    bibDatabase.registerListener(dbmsSynchronizer);
    dbmsSynchronizer.openSharedDatabase(dbmsConnection);
}
Also used : BibDatabase(org.jabref.model.database.BibDatabase) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Example 28 with BibDatabaseContext

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

the class IntegrityCheckTest method createContext.

private BibDatabaseContext createContext(String field, String value, String type) {
    BibEntry entry = new BibEntry();
    entry.setField(field, value);
    entry.setType(type);
    BibDatabase bibDatabase = new BibDatabase();
    bibDatabase.insertEntry(entry);
    return new BibDatabaseContext(bibDatabase, 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 29 with BibDatabaseContext

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

the class IntegrityCheckTest method fileCheckFindsFilesRelativeToBibFile.

@Test
public void fileCheckFindsFilesRelativeToBibFile() throws IOException {
    File bibFile = testFolder.newFile("lit.bib");
    testFolder.newFile("file.pdf");
    BibDatabaseContext databaseContext = createContext("file", ":file.pdf:PDF");
    databaseContext.setDatabaseFile(bibFile);
    assertCorrect(databaseContext);
}
Also used : File(java.io.File) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Test(org.junit.Test)

Example 30 with BibDatabaseContext

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

the class IntegrityCheckTest method testEntryIsUnchangedAfterChecks.

@Test
public void testEntryIsUnchangedAfterChecks() {
    BibEntry entry = new BibEntry();
    // populate with all known fields
    for (String fieldName : InternalBibtexFields.getAllPublicAndInternalFieldNames()) {
        entry.setField(fieldName, UUID.randomUUID().toString());
    }
    // add a random field
    entry.setField(UUID.randomUUID().toString(), UUID.randomUUID().toString());
    // duplicate entry
    BibEntry clonedEntry = (BibEntry) entry.clone();
    BibDatabase bibDatabase = new BibDatabase();
    bibDatabase.insertEntry(entry);
    BibDatabaseContext context = new BibDatabaseContext(bibDatabase, new Defaults());
    new IntegrityCheck(context, mock(FileDirectoryPreferences.class), createBibtexKeyPatternPreferences(), new JournalAbbreviationRepository(new Abbreviation("IEEE Software", "IEEE SW"))).checkBibtexDatabase();
    assertEquals(clonedEntry, entry);
}
Also used : Abbreviation(org.jabref.logic.journals.Abbreviation) BibEntry(org.jabref.model.entry.BibEntry) Defaults(org.jabref.model.Defaults) JournalAbbreviationRepository(org.jabref.logic.journals.JournalAbbreviationRepository) BibDatabase(org.jabref.model.database.BibDatabase) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Test(org.junit.Test)

Aggregations

BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)48 Defaults (org.jabref.model.Defaults)24 Before (org.junit.Before)16 BibDatabase (org.jabref.model.database.BibDatabase)15 Test (org.junit.Test)13 BibEntry (org.jabref.model.entry.BibEntry)11 ParserResult (org.jabref.logic.importer.ParserResult)9 MetaData (org.jabref.model.metadata.MetaData)8 Charset (java.nio.charset.Charset)6 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)6 Path (java.nio.file.Path)5 Scanner (java.util.Scanner)5 BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)5 SavePreferences (org.jabref.logic.exporter.SavePreferences)5 IOException (java.io.IOException)4 SaveException (org.jabref.logic.exporter.SaveException)4 BibtexImporter (org.jabref.logic.importer.fileformat.BibtexImporter)4 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)4 FileSaveSession (org.jabref.logic.exporter.FileSaveSession)3 SaveSession (org.jabref.logic.exporter.SaveSession)3