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());
}
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);
}
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());
}
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);
}
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);
}
Aggregations