Search in sources :

Example 11 with MetaData

use of org.jabref.model.metadata.MetaData in project jabref by JabRef.

the class BibDatabaseContextTest method testTypeBasedOnDefaultBiblatex.

@Test
public void testTypeBasedOnDefaultBiblatex() {
    BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new BibDatabase(), new MetaData(), new Defaults(BibDatabaseMode.BIBLATEX));
    assertEquals(BibDatabaseMode.BIBLATEX, bibDatabaseContext.getMode());
    bibDatabaseContext.setMode(BibDatabaseMode.BIBTEX);
    assertEquals(BibDatabaseMode.BIBTEX, bibDatabaseContext.getMode());
}
Also used : MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 12 with MetaData

use of org.jabref.model.metadata.MetaData in project jabref by JabRef.

the class DBMSSynchronizerTest method testMetaDataChangedEventListener.

@Test
public void testMetaDataChangedEventListener() {
    MetaData testMetaData = new MetaData();
    testMetaData.registerListener(dbmsSynchronizer);
    dbmsSynchronizer.setMetaData(testMetaData);
    testMetaData.setMode(BibDatabaseMode.BIBTEX);
    Map<String, String> expectedMap = MetaDataSerializer.getSerializedStringMap(testMetaData, pattern);
    Map<String, String> actualMap = dbmsProcessor.getSharedMetaData();
    Assert.assertEquals(expectedMap, actualMap);
}
Also used : MetaData(org.jabref.model.metadata.MetaData) Test(org.junit.Test)

Example 13 with MetaData

use of org.jabref.model.metadata.MetaData in project jabref by JabRef.

the class BibDatabaseContextTest method testTypeBasedOnDefaultBibtex.

@Test
public void testTypeBasedOnDefaultBibtex() {
    BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new BibDatabase(), new MetaData(), new Defaults(BibDatabaseMode.BIBTEX));
    assertEquals(BibDatabaseMode.BIBTEX, bibDatabaseContext.getMode());
    bibDatabaseContext.setMode(BibDatabaseMode.BIBLATEX);
    assertEquals(BibDatabaseMode.BIBLATEX, bibDatabaseContext.getMode());
}
Also used : MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Test(org.junit.Test)

Example 14 with MetaData

use of org.jabref.model.metadata.MetaData in project jabref by JabRef.

the class DBMSSynchronizerTest method testApplyMetaData.

@Test
public void testApplyMetaData() {
    BibEntry bibEntry = getBibEntryExample(1);
    bibDatabase.insertEntry(bibEntry);
    MetaData testMetaData = new MetaData();
    testMetaData.setSaveActions(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("author", new LowerCaseFormatter()))));
    dbmsSynchronizer.setMetaData(testMetaData);
    dbmsSynchronizer.applyMetaData();
    Assert.assertEquals("wirthlin, michael j1", bibEntry.getField("author").get());
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) MetaData(org.jabref.model.metadata.MetaData) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 15 with MetaData

use of org.jabref.model.metadata.MetaData in project jabref by JabRef.

the class Benchmarks method init.

@Setup
public void init() throws Exception {
    Globals.prefs = JabRefPreferences.getInstance();
    Random randomizer = new Random();
    for (int i = 0; i < 1000; i++) {
        BibEntry entry = new BibEntry();
        entry.setCiteKey("id" + i);
        entry.setField("title", "This is my title " + i);
        entry.setField("author", "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
        entry.setField("journal", "Journal Title " + i);
        entry.setField("keyword", "testkeyword");
        entry.setField("year", "1" + i);
        entry.setField("rnd", "2" + randomizer.nextInt());
        database.insertEntry(entry);
    }
    BibtexDatabaseWriter<StringSaveSession> databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new);
    StringSaveSession saveSession = databaseWriter.savePartOfDatabase(new BibDatabaseContext(database, new MetaData(), new Defaults()), database.getEntries(), new SavePreferences());
    bibtexString = saveSession.getStringValue();
    latexConversionString = "{A} \\textbf{bold} approach {\\it to} ${{\\Sigma}}{\\Delta}$ modulator \\textsuperscript{2} \\$";
    htmlConversionString = "<b>&Ouml;sterreich</b> &#8211; &amp; characters &#x2aa2; <i>italic</i>";
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Defaults(org.jabref.model.Defaults) Random(java.util.Random) BibtexDatabaseWriter(org.jabref.logic.exporter.BibtexDatabaseWriter) MetaData(org.jabref.model.metadata.MetaData) SavePreferences(org.jabref.logic.exporter.SavePreferences) StringSaveSession(org.jabref.logic.exporter.StringSaveSession) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

MetaData (org.jabref.model.metadata.MetaData)19 BibDatabase (org.jabref.model.database.BibDatabase)12 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)8 BibEntry (org.jabref.model.entry.BibEntry)7 Defaults (org.jabref.model.Defaults)6 Before (org.junit.Before)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 ParserResult (org.jabref.logic.importer.ParserResult)3 FileDirectoryPreferences (org.jabref.model.metadata.FileDirectoryPreferences)3 BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)2 SavePreferences (org.jabref.logic.exporter.SavePreferences)2 StringSaveSession (org.jabref.logic.exporter.StringSaveSession)2 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)2 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)2 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)2 ContentSelector (org.jabref.model.metadata.ContentSelector)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Collections (java.util.Collections)1