use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method getUsedStrings.
@Test
public void getUsedStrings() {
BibEntry entry = new BibEntry(IdGenerator.next());
entry.setField("author", "#AAA#");
BibtexString tripleA = new BibtexString("AAA", "Some other #BBB#");
BibtexString tripleB = new BibtexString("BBB", "Some more text");
BibtexString tripleC = new BibtexString("CCC", "Even more text");
Set<BibtexString> stringSet = new HashSet<>();
stringSet.add(tripleA);
stringSet.add(tripleB);
database.addString(tripleA);
database.addString(tripleB);
database.addString(tripleC);
database.insertEntry(entry);
Set<BibtexString> usedStrings = new HashSet<>(database.getUsedStrings(Arrays.asList(entry)));
assertEquals(stringSet, usedStrings);
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method insertStringUpdatesStringList.
@Test
public void insertStringUpdatesStringList() {
BibtexString string = new BibtexString("DSP", "Digital Signal Processing");
database.addString(string);
assertFalse(database.hasNoStrings());
assertEquals(database.getStringKeySet().size(), 1);
assertEquals(database.getStringCount(), 1);
assertTrue(database.getStringValues().contains(string));
assertTrue(database.getStringKeySet().contains(string.getId()));
assertEquals(string, database.getString(string.getId()));
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method addSameStringIdTwiceThrowsKeyCollisionException.
@Test(expected = KeyCollisionException.class)
public void addSameStringIdTwiceThrowsKeyCollisionException() {
BibtexString string = new BibtexString("DSP", "Digital Signal Processing");
string.setId("duplicateid");
database.addString(string);
string = new BibtexString("VLSI", "Very Large Scale Integration");
string.setId("duplicateid");
database.addString(string);
fail();
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method getUsedStringsSingleString.
@Test
public void getUsedStringsSingleString() {
BibEntry entry = new BibEntry();
entry.setField("author", "#AAA#");
BibtexString tripleA = new BibtexString("AAA", "Some other text");
BibtexString tripleB = new BibtexString("BBB", "Some more text");
List<BibtexString> strings = new ArrayList<>(1);
strings.add(tripleA);
database.addString(tripleA);
database.addString(tripleB);
database.insertEntry(entry);
List<BibtexString> usedStrings = (List<BibtexString>) database.getUsedStrings(Arrays.asList(entry));
assertEquals(strings, usedStrings);
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method circularStringResolving.
@Test
public void circularStringResolving() {
BibtexString string = new BibtexString("AAA", "#BBB#");
database.addString(string);
string = new BibtexString("BBB", "#AAA#");
database.addString(string);
assertEquals(database.resolveForStrings("#AAA#"), "AAA");
assertEquals(database.resolveForStrings("#BBB#"), "BBB");
}
Aggregations