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