Skip to content

Commit

Permalink
Follow variable convention of MSBibExportFormatTestfiles at ModsExpor…
Browse files Browse the repository at this point in the history
…tFormatTestFiles
  • Loading branch information
koppor committed Aug 25, 2019
1 parent 7f970bc commit 2ace3dd
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ModsExportFormatTestFiles {
private static Path resourceDir;
public Charset charset;
private BibDatabaseContext databaseContext;
private Path tempFile;
private Path exportedFile;
private ModsExporter exporter;
private BibtexImporter bibtexImporter;
private ModsImporter modsImporter;
Expand All @@ -56,7 +56,7 @@ public void setUp(@TempDir Path testFolder) throws Exception {
exporter = new ModsExporter();
Path path = testFolder.resolve("ARandomlyNamedFile.tmp");
Files.createFile(path);
tempFile = path.toAbsolutePath();
exportedFile = path.toAbsolutePath();
ImportFormatPreferences mock = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS);
bibtexImporter = new BibtexImporter(mock, new DummyFileUpdateMonitor());
Mockito.when(mock.getKeywordSeparator()).thenReturn(',');
Expand All @@ -69,13 +69,13 @@ public final void testPerformExport(String filename) throws Exception {
importFile = Paths.get(ModsExportFormatTestFiles.class.getResource(filename).toURI());
String xmlFileName = filename.replace(".bib", ".xml");
List<BibEntry> entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();
Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());
Path expectedFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI());

exporter.export(databaseContext, tempFile, charset, entries);
exporter.export(databaseContext, exportedFile, charset, entries);

assertEquals(
String.join("\n", Files.readAllLines(xmlFile)),
String.join("\n", Files.readAllLines(tempFile)));
String.join("\n", Files.readAllLines(expectedFile)),
String.join("\n", Files.readAllLines(exportedFile)));
}

@ParameterizedTest
Expand All @@ -84,8 +84,8 @@ public final void testExportAsModsAndThenImportAsMods(String filename) throws Ex
importFile = Paths.get(ModsExportFormatTestFiles.class.getResource(filename).toURI());
List<BibEntry> entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries();

exporter.export(databaseContext, tempFile, charset, entries);
BibEntryAssert.assertEquals(entries, tempFile, modsImporter);
exporter.export(databaseContext, exportedFile, charset, entries);
BibEntryAssert.assertEquals(entries, exportedFile, modsImporter);
}

@ParameterizedTest
Expand All @@ -97,10 +97,10 @@ public final void testImportAsModsAndExportAsMods(String filename) throws Except

List<BibEntry> entries = modsImporter.importDatabase(xmlFile, charset).getDatabase().getEntries();

exporter.export(databaseContext, tempFile, charset, entries);
exporter.export(databaseContext, exportedFile, charset, entries);

assertEquals(
String.join("\n", Files.readAllLines(xmlFile)),
String.join("\n", Files.readAllLines(tempFile)));
String.join("\n", Files.readAllLines(exportedFile)));
}
}

0 comments on commit 2ace3dd

Please sign in to comment.