Search in sources :

Example 26 with BibDatabase

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

the class BibtexKeyPatternUtilTest method testSpecialLatexCharacterInAuthorName.

@Test
public void testSpecialLatexCharacterInAuthorName() throws ParseException {
    Optional<BibEntry> entry = BibtexParser.singleFromString("@ARTICLE{kohn, author={Simon Popovi\\v{c}ov\\'{a}}}", importFormatPreferences);
    assertEquals("Popovicova", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry.get(), "auth", ',', new BibDatabase()), true));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 27 with BibDatabase

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

the class BibtexKeyPatternUtilTest method testApplyModifiers.

@Test
public void testApplyModifiers() {
    BibEntry entry = new BibEntry();
    entry.setField("title", "Green Scheduling of Whatever");
    assertEquals("GSo", BibtexKeyPatternUtil.makeLabel(entry, "shorttitleINI", ',', new BibDatabase()));
    assertEquals("GreenSchedulingof", BibtexKeyPatternUtil.makeLabel(entry, "shorttitle", ',', new BibDatabase()));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 28 with BibDatabase

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

the class BibtexKeyPatternUtilTest method testDepartment.

@Test
public void testDepartment() throws ParseException {
    Optional<BibEntry> entry = BibtexParser.singleFromString("@ARTICLE{kohn, author={{Link{\\\"{o}}ping University, Department of Electrical Engineering}}}", importFormatPreferences);
    assertEquals("UniLinkoepingEE", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry.get(), "auth", ',', new BibDatabase()), true));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 29 with BibDatabase

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

the class BibtexKeyPatternUtilTest method keywordsNKeywordsSeparatedBySpace.

@Test
public void keywordsNKeywordsSeparatedBySpace() {
    BibEntry entry = new BibEntry();
    entry.setField("keywords", "w1, w2a w2b, w3");
    // all keywords
    String result = BibtexKeyPatternUtil.makeLabel(entry, "keywords", ',', new BibDatabase());
    assertEquals("w1w2aw2bw3", result);
    // check keywords with space
    result = BibtexKeyPatternUtil.makeLabel(entry, "keywords2", ',', new BibDatabase());
    assertEquals("w1w2aw2b", result);
    // check out of range
    result = BibtexKeyPatternUtil.makeLabel(entry, "keywords55", ',', new BibDatabase());
    assertEquals("w1w2aw2bw3", result);
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 30 with BibDatabase

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

the class BibtexKeyPatternUtilTest method testUniversity.

@Test
public void testUniversity() throws ParseException {
    Optional<BibEntry> entry = BibtexParser.singleFromString("@ARTICLE{kohn, author={{Link{\\\"{o}}ping University}}}", importFormatPreferences);
    assertEquals("UniLinkoeping", BibtexKeyPatternUtil.checkLegalKey(BibtexKeyPatternUtil.makeLabel(entry.get(), "auth", ',', new BibDatabase()), true));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Aggregations

BibDatabase (org.jabref.model.database.BibDatabase)88 BibEntry (org.jabref.model.entry.BibEntry)60 Test (org.junit.Test)44 ParserResult (org.jabref.logic.importer.ParserResult)20 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)15 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)15 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)13 MetaData (org.jabref.model.metadata.MetaData)12 IOException (java.io.IOException)10 Defaults (org.jabref.model.Defaults)9 Before (org.junit.Before)9 File (java.io.File)8 InputStreamReader (java.io.InputStreamReader)8 InputStream (java.io.InputStream)7 PropertyVetoException (com.sun.star.beans.PropertyVetoException)6 UnknownPropertyException (com.sun.star.beans.UnknownPropertyException)6 WrappedTargetException (com.sun.star.lang.WrappedTargetException)6 LinkedHashMap (java.util.LinkedHashMap)5 BasePanel (org.jabref.gui.BasePanel)5