use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibtexDatabaseWriterTest method writeStringAndEncoding.
@Test
public void writeStringAndEncoding() throws Exception {
SavePreferences preferences = new SavePreferences().withEncoding(Charsets.US_ASCII);
database.addString(new BibtexString("name", "content"));
StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), preferences);
assertEquals("% Encoding: US-ASCII" + OS.NEWLINE + OS.NEWLINE + "@String{name = {content}}" + OS.NEWLINE, session.getStringValue());
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibtexParserTest method parseSavesOneNewlineAfterStringInParsedSerialization.
@Test
public void parseSavesOneNewlineAfterStringInParsedSerialization() throws IOException {
String string = "@string{bourdieu = {Bourdieu, Pierre}}" + OS.NEWLINE;
ParserResult result = parser.parse(new StringReader(string + OS.NEWLINE + OS.NEWLINE));
assertEquals(1, result.getDatabase().getStringCount());
BibtexString s = result.getDatabase().getStringValues().iterator().next();
assertEquals(string, s.getParsedSerialization());
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesStringInParenthesis.
@Test
public void parseRecognizesStringInParenthesis() 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());
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibtexParserTest method parseRecognizesStringAndEntry.
@Test
public void parseRecognizesStringAndEntry() throws IOException {
ParserResult result = BibtexParser.parse(new StringReader("" + "@string{bourdieu = {Bourdieu, Pierre}}" + "@book{bourdieu-2002-questions-sociologie, " + " Address = {Paris}," + " Author = bourdieu," + " Isbn = 2707318256," + " Publisher = {Minuit}," + " Title = {Questions de sociologie}," + " Year = 2002" + "}"), importFormatPreferences);
assertEquals(1, result.getDatabase().getStringCount());
BibtexString s = result.getDatabase().getStringValues().iterator().next();
assertEquals("bourdieu", s.getName());
assertEquals("Bourdieu, Pierre", s.getContent());
Collection<BibEntry> c = result.getDatabase().getEntries();
assertEquals(1, c.size());
BibEntry e = c.iterator().next();
assertEquals("book", e.getType());
assertEquals(Optional.of("bourdieu-2002-questions-sociologie"), e.getCiteKeyOptional());
assertEquals(Optional.of("Paris"), e.getField("address"));
assertEquals(Optional.of("#bourdieu#"), e.getField("author"));
assertEquals(Optional.of("2707318256"), e.getField("isbn"));
assertEquals(Optional.of("Minuit"), e.getField("publisher"));
assertEquals(Optional.of("Questions de sociologie"), e.getField("title"));
assertEquals(Optional.of("2002"), e.getField("year"));
}
use of org.jabref.model.entry.BibtexString in project jabref by JabRef.
the class BibDatabaseTest method resolveForStringsSurroundingContent.
@Test
public void resolveForStringsSurroundingContent() {
BibtexString string = new BibtexString("AAA", "aaa");
database.addString(string);
assertEquals(database.resolveForStrings("aa#AAA#AAA"), "aaaaaAAA");
}
Aggregations