Search in sources :

Example 16 with BibtexString

use of org.jabref.model.entry.BibtexString in project jabref by JabRef.

the class BibDatabaseTest method addSameStringLabelTwiceThrowsKeyCollisionException.

@Test(expected = KeyCollisionException.class)
public void addSameStringLabelTwiceThrowsKeyCollisionException() {
    BibtexString string = new BibtexString("DSP", "Digital Signal Processing");
    database.addString(string);
    string = new BibtexString("DSP", "Digital Signal Processor");
    database.addString(string);
    fail();
}
Also used : BibtexString(org.jabref.model.entry.BibtexString) Test(org.junit.Test)

Example 17 with BibtexString

use of org.jabref.model.entry.BibtexString in project jabref by JabRef.

the class BibDatabaseTest method removeStringUpdatesStringList.

@Test
public void removeStringUpdatesStringList() {
    BibtexString string = new BibtexString("DSP", "Digital Signal Processing");
    database.addString(string);
    database.removeString(string.getId());
    assertTrue(database.hasNoStrings());
    assertEquals(database.getStringKeySet().size(), 0);
    assertEquals(database.getStringCount(), 0);
    assertFalse(database.getStringValues().contains(string));
    assertFalse(database.getStringKeySet().contains(string.getId()));
    assertNull(database.getString(string.getId()));
}
Also used : BibtexString(org.jabref.model.entry.BibtexString) Test(org.junit.Test)

Example 18 with BibtexString

use of org.jabref.model.entry.BibtexString in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesStringWithWhitespace.

@Test
public void parseRecognizesStringWithWhitespace() throws IOException {
    ParserResult result = parser.parse(new StringReader("@string {bourdieu = {Bourdieu, Pierre}}"));
    assertEquals(1, result.getDatabase().getStringCount());
    BibtexString s = result.getDatabase().getStringValues().iterator().next();
    assertEquals("bourdieu", s.getName());
    assertEquals("Bourdieu, Pierre", s.getContent());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) BibtexString(org.jabref.model.entry.BibtexString) Test(org.junit.Test)

Example 19 with BibtexString

use of org.jabref.model.entry.BibtexString in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesMultipleStrings.

@Test
public void parseRecognizesMultipleStrings() throws IOException {
    ParserResult result = parser.parse(new StringReader("@string{bourdieu = {Bourdieu, Pierre}}" + "@string{adieu = {Adieu, Pierre}}"));
    assertEquals(2, result.getDatabase().getStringCount());
    Iterator<BibtexString> iterator = result.getDatabase().getStringValues().iterator();
    BibtexString s = iterator.next();
    BibtexString t = iterator.next();
    // Sort them because we can't be sure about the order
    if (s.getName().equals("adieu")) {
        BibtexString tmp = s;
        s = t;
        t = tmp;
    }
    assertEquals("bourdieu", s.getName());
    assertEquals("Bourdieu, Pierre", s.getContent());
    assertEquals("adieu", t.getName());
    assertEquals("Adieu, Pierre", t.getContent());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) BibtexString(org.jabref.model.entry.BibtexString) Test(org.junit.Test)

Example 20 with BibtexString

use of org.jabref.model.entry.BibtexString in project jabref by JabRef.

the class BibtexParserTest method parseRecognizesString.

@Test
public void parseRecognizesString() throws IOException {
    ParserResult result = parser.parse(new StringReader("@string{bourdieu = {Bourdieu, Pierre}}"));
    assertEquals(1, result.getDatabase().getStringCount());
    BibtexString s = result.getDatabase().getStringValues().iterator().next();
    assertEquals("bourdieu", s.getName());
    assertEquals("Bourdieu, Pierre", s.getContent());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) BibtexString(org.jabref.model.entry.BibtexString) Test(org.junit.Test)

Aggregations

BibtexString (org.jabref.model.entry.BibtexString)40 Test (org.junit.Test)24 ParserResult (org.jabref.logic.importer.ParserResult)8 BibEntry (org.jabref.model.entry.BibEntry)7 StringReader (java.io.StringReader)6 KeyCollisionException (org.jabref.model.database.KeyCollisionException)5 UndoableInsertString (org.jabref.gui.undo.UndoableInsertString)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 NamedCompound (org.jabref.gui.undo.NamedCompound)2 UndoableStringChange (org.jabref.gui.undo.UndoableStringChange)2 BibDatabase (org.jabref.model.database.BibDatabase)2 IOException (java.io.IOException)1 Charset (java.nio.charset.Charset)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Scanner (java.util.Scanner)1 Matcher (java.util.regex.Matcher)1