Search in sources :

Example 6 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class BibtexDatabaseWriterTest method writeCustomKeyPattern.

@Test
public void writeCustomKeyPattern() throws Exception {
    AbstractBibtexKeyPattern pattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class));
    pattern.setDefaultValue("test");
    pattern.addBibtexKeyPattern("article", "articleTest");
    metaData.setCiteKeyPattern(pattern);
    StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
    assertEquals(OS.NEWLINE + "@Comment{jabref-meta: keypattern_article:articleTest;}" + OS.NEWLINE + OS.NEWLINE + "@Comment{jabref-meta: keypatterndefault:test;}" + OS.NEWLINE, session.getStringValue());
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) AbstractBibtexKeyPattern(org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern) Test(org.junit.Test)

Example 7 with DatabaseBibtexKeyPattern

use of org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern in project jabref by JabRef.

the class BibtexDatabaseWriterTest method writeMetadataAndEncoding.

@Test
public void writeMetadataAndEncoding() throws Exception {
    SavePreferences preferences = new SavePreferences().withEncoding(Charsets.US_ASCII);
    DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(mock(GlobalBibtexKeyPattern.class));
    bibtexKeyPattern.setDefaultValue("test");
    metaData.setCiteKeyPattern(bibtexKeyPattern);
    StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), preferences);
    assertEquals("% Encoding: US-ASCII" + OS.NEWLINE + OS.NEWLINE + "@Comment{jabref-meta: keypatterndefault:test;}" + OS.NEWLINE, session.getStringValue());
}
Also used : GlobalBibtexKeyPattern(org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern) DatabaseBibtexKeyPattern(org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern) Test(org.junit.Test)

Aggregations

DatabaseBibtexKeyPattern (org.jabref.model.bibtexkeypattern.DatabaseBibtexKeyPattern)7 GlobalBibtexKeyPattern (org.jabref.model.bibtexkeypattern.GlobalBibtexKeyPattern)4 Test (org.junit.Test)4 AbstractBibtexKeyPattern (org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern)3 StringReader (java.io.StringReader)1 ParserResult (org.jabref.logic.importer.ParserResult)1 BibDatabase (org.jabref.model.database.BibDatabase)1 BibEntry (org.jabref.model.entry.BibEntry)1 Before (org.junit.Before)1