Search in sources :

Example 41 with BibDatabase

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

the class OOBibStyleTest method testGetCitationMarkerInParenthesisUniquefiers.

@Test
public void testGetCitationMarkerInParenthesisUniquefiers() throws IOException {
    OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
    Map<BibEntry, BibDatabase> entryDBMap = new HashMap<>();
    List<BibEntry> entries = new ArrayList<>();
    BibDatabase database = new BibDatabase();
    BibEntry entry1 = new BibEntry();
    entry1.setField("author", "Alpha Beta");
    entry1.setField("title", "Paper 1");
    entry1.setField("year", "2000");
    entries.add(entry1);
    database.insertEntry(entry1);
    BibEntry entry3 = new BibEntry();
    entry3.setField("author", "Alpha Beta");
    entry3.setField("title", "Paper 2");
    entry3.setField("year", "2000");
    entries.add(entry3);
    database.insertEntry(entry3);
    BibEntry entry2 = new BibEntry();
    entry2.setField("author", "Gamma Epsilon");
    entry2.setField("year", "2001");
    entries.add(entry2);
    database.insertEntry(entry2);
    for (BibEntry entry : database.getEntries()) {
        entryDBMap.put(entry, database);
    }
    assertEquals("[Beta, 2000; Beta, 2000; Epsilon, 2001]", style.getCitationMarker(entries, entryDBMap, true, null, null));
    assertEquals("[Beta, 2000a,b; Epsilon, 2001]", style.getCitationMarker(entries, entryDBMap, true, new String[] { "a", "b", "" }, new int[] { 1, 1, 1 }));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 42 with BibDatabase

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

the class OOBibStyleTest method testGetCitationMarkerInTextUniquefiers.

@Test
public void testGetCitationMarkerInTextUniquefiers() throws IOException {
    OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
    Map<BibEntry, BibDatabase> entryDBMap = new HashMap<>();
    List<BibEntry> entries = new ArrayList<>();
    BibDatabase database = new BibDatabase();
    BibEntry entry1 = new BibEntry();
    entry1.setField("author", "Alpha Beta");
    entry1.setField("title", "Paper 1");
    entry1.setField("year", "2000");
    entries.add(entry1);
    database.insertEntry(entry1);
    BibEntry entry3 = new BibEntry();
    entry3.setField("author", "Alpha Beta");
    entry3.setField("title", "Paper 2");
    entry3.setField("year", "2000");
    entries.add(entry3);
    database.insertEntry(entry3);
    BibEntry entry2 = new BibEntry();
    entry2.setField("author", "Gamma Epsilon");
    entry2.setField("year", "2001");
    entries.add(entry2);
    database.insertEntry(entry2);
    for (BibEntry entry : database.getEntries()) {
        entryDBMap.put(entry, database);
    }
    assertEquals("Beta [2000]; Beta [2000]; Epsilon [2001]", style.getCitationMarker(entries, entryDBMap, false, null, null));
    assertEquals("Beta [2000a,b]; Epsilon [2001]", style.getCitationMarker(entries, entryDBMap, false, new String[] { "a", "b", "" }, new int[] { 1, 1, 1 }));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 43 with BibDatabase

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

the class OOBibStyleTest method testVonAuthorMarker.

@Test
public void testVonAuthorMarker() throws IOException {
    OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
    Map<BibEntry, BibDatabase> entryDBMap = new HashMap<>();
    List<BibEntry> entries = new ArrayList<>();
    BibDatabase database = new BibDatabase();
    BibEntry entry = new BibEntry();
    entry.setType("article");
    entry.setField("author", "Alpha von Beta");
    entry.setField("title", "JabRef Manual");
    entry.setField("year", "2016");
    database.insertEntry(entry);
    entries.add(entry);
    entryDBMap.put(entry, database);
    assertEquals("[von Beta, 2016]", style.getCitationMarker(entries, entryDBMap, true, null, null));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 44 with BibDatabase

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

the class OOBibStyleTest method testGetCitationMarker.

@Test
public void testGetCitationMarker() throws IOException {
    Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib");
    ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8));
    OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
    Map<BibEntry, BibDatabase> entryDBMap = new HashMap<>();
    BibDatabase db = result.getDatabase();
    for (BibEntry entry : db.getEntries()) {
        entryDBMap.put(entry, db);
    }
    BibEntry entry = db.getEntryByKey("1137631").get();
    assertEquals("[Boström et al., 2006]", style.getCitationMarker(Arrays.asList(entry), entryDBMap, true, null, null));
    assertEquals("Boström et al. [2006]", style.getCitationMarker(Arrays.asList(entry), entryDBMap, false, null, new int[] { 3 }));
    assertEquals("[Boström, Wäyrynen, Bodén, Beznosov & Kruchten, 2006]", style.getCitationMarker(Arrays.asList(entry), entryDBMap, true, null, new int[] { 5 }));
}
Also used : Path(java.nio.file.Path) ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) HashMap(java.util.HashMap) BibtexParser(org.jabref.logic.importer.fileformat.BibtexParser) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 45 with BibDatabase

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

the class OOBibStyleTest method testLayout.

@Test
public void testLayout() throws IOException {
    Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib");
    ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, StandardCharsets.UTF_8));
    OOBibStyle style = new OOBibStyle(StyleLoader.DEFAULT_NUMERICAL_STYLE_PATH, layoutFormatterPreferences);
    BibDatabase db = result.getDatabase();
    Layout l = style.getReferenceFormat("default");
    l.setPostFormatter(new OOPreFormatter());
    BibEntry entry = db.getEntryByKey("1137631").get();
    assertEquals("Boström, G.; Wäyrynen, J.; Bodén, M.; Beznosov, K. and Kruchten, P. (<b>2006</b>). <i>Extending XP practices to support security requirements engineering</i>,   : 11-18.", l.doLayout(entry, db));
    l = style.getReferenceFormat("incollection");
    l.setPostFormatter(new OOPreFormatter());
    assertEquals("Boström, G.; Wäyrynen, J.; Bodén, M.; Beznosov, K. and Kruchten, P. (<b>2006</b>). <i>Extending XP practices to support security requirements engineering</i>. In:  (Ed.), <i>SESS '06: Proceedings of the 2006 international workshop on Software engineering for secure systems</i>, ACM.", l.doLayout(entry, db));
}
Also used : Path(java.nio.file.Path) ParserResult(org.jabref.logic.importer.ParserResult) BibEntry(org.jabref.model.entry.BibEntry) Layout(org.jabref.logic.layout.Layout) BibtexParser(org.jabref.logic.importer.fileformat.BibtexParser) 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