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