Skip to content

Commit

Permalink
Fixed testExportAsModsAndThenImportAsMods (#4369)
Browse files Browse the repository at this point in the history
* Fixed testExportAsModsAndThenImportAsMods

* Fixed indentation

* Fixed indentation
  • Loading branch information
NivedhaSunderraj authored and tobiasdiez committed Oct 14, 2018
1 parent 79ba040 commit 73ec321
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,23 +19,20 @@
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;
import org.junit.jupiter.params.ParameterizedTest;
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 {

Expand Down Expand Up @@ -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
Expand All @@ -78,17 +80,16 @@ public final void testPerformExport(String filename) throws Exception {
Path tempFilename = tempFile.toAbsolutePath();
List<BibEntry> 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 {
Expand Down

0 comments on commit 73ec321

Please sign in to comment.