From 73ec321895fb07e131bfd3cc560d0d8f4214cf3c Mon Sep 17 00:00:00 2001 From: Nivedha Date: Mon, 15 Oct 2018 03:11:26 +0530 Subject: [PATCH] Fixed testExportAsModsAndThenImportAsMods (#4369) * Fixed testExportAsModsAndThenImportAsMods * Fixed indentation * Fixed indentation --- .../exporter/ModsExportFormatTestFiles.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java index dfce7d716e1..1c0bbbca22f 100644 --- a/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java +++ b/src/test/java/org/jabref/logic/exporter/ModsExportFormatTestFiles.java @@ -1,5 +1,8 @@ package org.jabref.logic.exporter; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; + import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -16,7 +19,6 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.extension.ExtendWith; @@ -24,15 +26,13 @@ import org.junit.jupiter.params.provider.MethodSource; import org.junitpioneer.jupiter.TempDirectory; import org.mockito.Answers; +import org.mockito.Mockito; import org.xmlunit.builder.Input; import org.xmlunit.builder.Input.Builder; import org.xmlunit.diff.DefaultNodeMatcher; import org.xmlunit.diff.ElementSelectors; import org.xmlunit.matchers.CompareMatcher; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; - @ExtendWith(TempDirectory.class) public class ModsExportFormatTestFiles { @@ -65,8 +65,10 @@ public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception { Path path = testFolder.resolve("ARandomlyNamedFile.tmp"); Files.createFile(path); tempFile = path.toAbsolutePath(); - bibtexImporter = new BibtexImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor()); - modsImporter = new ModsImporter(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); + ImportFormatPreferences mock = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + bibtexImporter = new BibtexImporter(mock, new DummyFileUpdateMonitor()); + Mockito.when(mock.getKeywordSeparator()).thenReturn(','); + modsImporter = new ModsImporter(mock); } @Disabled @@ -78,17 +80,16 @@ public final void testPerformExport(String filename) throws Exception { Path tempFilename = tempFile.toAbsolutePath(); List entries = bibtexImporter.importDatabase(importFile, charset).getDatabase().getEntries(); Path xmlFile = Paths.get(ModsExportFormatTestFiles.class.getResource(xmlFileName).toURI()); - + modsExportFormat.export(databaseContext, tempFile, charset, entries); Builder control = Input.from(Files.newInputStream(xmlFile)); Builder test = Input.from(Files.newInputStream(tempFilename)); - assertThat(test, CompareMatcher.isSimilarTo(control) .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure()); } - @Disabled + @ParameterizedTest @MethodSource("fileNames") public final void testExportAsModsAndThenImportAsMods(String filename) throws Exception {