use of org.jabref.model.Defaults 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));
}
use of org.jabref.model.Defaults 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);
}
use of org.jabref.model.Defaults 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);
}
use of org.jabref.model.Defaults in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtripWithUserComment.
@Test
public void roundtripWithUserComment() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/bibWithUserComments.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
use of org.jabref.model.Defaults in project jabref by JabRef.
the class BibtexDatabaseWriterTest method roundtrip.
@Test
public void roundtrip() throws Exception {
Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib");
Charset encoding = StandardCharsets.UTF_8;
ParserResult result = new BibtexParser(importFormatPreferences).parse(Importer.getReader(testBibtexFile, encoding));
SavePreferences preferences = new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
BibDatabaseContext context = new BibDatabaseContext(result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));
StringSaveSession session = databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);
try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
}
}
Aggregations