-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed testExportAsModsAndThenImportAsMods #4369
Merged
tobiasdiez
merged 3 commits into
JabRef:master
from
NivedhaSunderraj:fix-exporter-tests
Oct 14, 2018
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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 { | ||
|
||
|
@@ -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,17 @@ 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()); | ||
CompareMatcher matcher = CompareMatcher.isSimilarTo(control) | ||
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be an indent here (or put everything on one line). |
||
assertThat(test, matcher); | ||
} | ||
|
||
@Disabled | ||
|
||
@ParameterizedTest | ||
@MethodSource("fileNames") | ||
public final void testExportAsModsAndThenImportAsMods(String filename) throws Exception { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the indent here.