use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class AuxParserTest method testNotAllFound.
@Test
public void testNotAllFound() throws URISyntaxException, IOException {
InputStream originalStream = AuxParserTest.class.getResourceAsStream("origin.bib");
File auxFile = Paths.get(AuxParserTest.class.getResource("badpaper.aux").toURI()).toFile();
try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) {
ParserResult result = new BibtexParser(importFormatPreferences).parse(originalReader);
AuxParser auxParser = new AuxParser(auxFile.getAbsolutePath(), result.getDatabase());
AuxParserResult auxResult = auxParser.parse();
assertTrue(auxResult.getGeneratedBibDatabase().hasEntries());
assertEquals(1, auxResult.getUnresolvedKeysCount());
BibDatabase newDB = auxResult.getGeneratedBibDatabase();
assertEquals(2, newDB.getEntries().size());
assertEquals(2, auxResult.getResolvedKeysCount());
assertEquals(3, auxResult.getFoundKeysInAux());
assertEquals(auxResult.getFoundKeysInAux() + auxResult.getCrossRefEntriesCount(), auxResult.getResolvedKeysCount() + auxResult.getUnresolvedKeysCount());
assertEquals(0, auxResult.getCrossRefEntriesCount());
}
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class MakeLabelWithDatabaseTest method setUp.
@Before
public void setUp() {
database = new BibDatabase();
entry = new BibEntry();
entry.setField("author", "John Doe");
entry.setField("year", "2016");
entry.setField("title", "An awesome paper on JabRef");
database.insertEntry(entry);
pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
bibtexKeyPattern = new DatabaseBibtexKeyPattern(pattern);
preferences = new BibtexKeyPatternPreferences("", "", false, true, true, pattern, ',');
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class BibtexKeyPatternUtilTest method keywordNKeywordsSeparatedBySpace.
@Test
public void keywordNKeywordsSeparatedBySpace() {
BibEntry entry = new BibEntry();
entry.setField("keywords", "w1, w2a w2b, w3");
String result = BibtexKeyPatternUtil.makeLabel(entry, "keyword1", ',', new BibDatabase());
assertEquals("w1", result);
// check keywords with space
result = BibtexKeyPatternUtil.makeLabel(entry, "keyword2", ',', new BibDatabase());
assertEquals("w2a w2b", result);
// check out of range
result = BibtexKeyPatternUtil.makeLabel(entry, "keyword4", ',', new BibDatabase());
assertEquals("", result);
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class BibtexKeyPatternUtilTest method testAndInAuthorName.
@Test
public void testAndInAuthorName() throws ParseException {
Optional<BibEntry> entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Simon Holland}}", importFormatPreferences);
assertEquals("Holland", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth", ',', new BibDatabase()), true));
}
use of org.jabref.model.database.BibDatabase in project jabref by JabRef.
the class BibtexKeyPatternUtilTest method testMakeLabelAndCheckLegalKeys.
/**
* Test for https://sourceforge.net/forum/message.php?msg_id=4498555 Test the Labelmaker and all kind of accents Á á
* Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź
*/
@Test
public void testMakeLabelAndCheckLegalKeys() throws ParseException {
Optional<BibEntry> entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Köning}, year={2000}}", importFormatPreferences);
assertEquals("Koen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
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("Loen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ńöning}, year={2000}}", importFormatPreferences);
assertEquals("Noen", 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("Roen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Śöning}, year={2000}}", importFormatPreferences);
assertEquals("Soen", 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));
entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Ýöning}, year={2000}}", importFormatPreferences);
assertEquals("Yoen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
entry0 = BibtexParser.singleFromString("@ARTICLE{kohn, author={Andreas Źöning}, year={2000}}", importFormatPreferences);
assertEquals("Zoen", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry0.get(), "auth3", ',', new BibDatabase()), true));
}
Aggregations