use of org.jabref.model.Defaults in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtripWithUnknownMetaData.
@Test
public void roundtripWithUnknownMetaData() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/unknownMetaData.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
use of org.jabref.model.Defaults 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.Defaults in project jabref by JabRef.
the class SynchronizationTestSimulator method setUp.
@Before
public void setUp() throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
this.dbmsConnection = TestConnector.getTestDBMSConnection(dbmsType);
GlobalBibtexKeyPattern pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
clientContextA = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
clientContextA.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
clientContextB = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX), DatabaseLocation.SHARED, ',', pattern);
clientContextB.getDBMSSynchronizer().openSharedDatabase(dbmsConnection);
eventListenerB = new SynchronizationTestEventListener();
clientContextB.getDBMSSynchronizer().registerListener(eventListenerB);
}
use of org.jabref.model.Defaults 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.Defaults 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