Search in sources :

Example 6 with MetaData

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

the class CleanupWorkerTest method setUp.

@Before
public void setUp() throws IOException {
    pdfFolder = bibFolder.newFolder();
    MetaData metaData = new MetaData();
    metaData.setDefaultFileDirectory(pdfFolder.getAbsolutePath());
    BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
    context.setDatabaseFile(bibFolder.newFile("test.bib"));
    FileDirectoryPreferences fileDirPrefs = mock(FileDirectoryPreferences.class);
    //Biblocation as Primary overwrites all other dirs
    when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(true);
    worker = new CleanupWorker(context, new CleanupPreferences("\\bibtexkey", //empty fileDirPattern for backwards compatibility
    "", mock(LayoutFormatterPreferences.class), fileDirPrefs));
}
Also used : FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Defaults(org.jabref.model.Defaults) MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Example 7 with MetaData

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

the class RenamePdfCleanupTest method setUp.

@Before
public void setUp() throws Exception {
    MetaData metaData = new MetaData();
    context = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
    context.setDatabaseFile(testFolder.newFile("test.bib"));
    fileDirPrefs = mock(FileDirectoryPreferences.class);
    //Set Biblocation as Primary Directory, otherwise the tmp folders won't be cleaned up correctly
    when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(true);
    entry = new BibEntry();
    entry.setCiteKey("Toot");
    layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS);
}
Also used : FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) BibEntry(org.jabref.model.entry.BibEntry) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Defaults(org.jabref.model.Defaults) MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Example 8 with MetaData

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

the class MoveFilesCleanupTest method setUp.

@Before
public void setUp() throws IOException {
    MetaData metaData = new MetaData();
    pdfFolder = bibFolder.newFolder();
    metaData.setDefaultFileDirectory(pdfFolder.getAbsolutePath());
    databaseContext = new BibDatabaseContext(new BibDatabase(), metaData, new Defaults());
    databaseContext.setDatabaseFile(bibFolder.newFile("test.bib"));
    entry = new BibEntry();
    entry.setCiteKey("Toot");
    entry.setField("title", "test title");
    fileDirPrefs = mock(FileDirectoryPreferences.class);
    //Biblocation as Primary overwrites all other dirs, therefore we set it to false here
    when(fileDirPrefs.isBibLocationAsPrimary()).thenReturn(false);
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) Defaults(org.jabref.model.Defaults) MetaData(org.jabref.model.metadata.MetaData) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) BibDatabase(org.jabref.model.database.BibDatabase) Before(org.junit.Before)

Example 9 with MetaData

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

the class MetaDataSerializerTest method setUp.

@Before
public void setUp() {
    metaData = new MetaData();
    pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]");
}
Also used : MetaData(org.jabref.model.metadata.MetaData) Before(org.junit.Before)

Example 10 with MetaData

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

the class IntegrityCheckTest method testFileChecks.

@Test
public void testFileChecks() {
    MetaData metaData = mock(MetaData.class);
    Mockito.when(metaData.getDefaultFileDirectory()).thenReturn(Optional.of("."));
    Mockito.when(metaData.getUserFileDirectory(any(String.class))).thenReturn(Optional.empty());
    // FIXME: must be set as checkBibtexDatabase only activates title checker based on database mode
    Mockito.when(metaData.getMode()).thenReturn(Optional.of(BibDatabaseMode.BIBTEX));
    assertCorrect(createContext("file", ":build.gradle:gradle", metaData));
    assertCorrect(createContext("file", "description:build.gradle:gradle", metaData));
    assertWrong(createContext("file", ":asflakjfwofja:PDF", metaData));
}
Also used : MetaData(org.jabref.model.metadata.MetaData) Test(org.junit.Test)

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