1
1
package org .jabref .logic .exporter ;
2
2
3
+ import static org .hamcrest .MatcherAssert .assertThat ;
4
+ import static org .mockito .Mockito .mock ;
5
+
3
6
import java .nio .charset .Charset ;
4
7
import java .nio .charset .StandardCharsets ;
5
8
import java .nio .file .Files ;
16
19
import org .jabref .model .database .BibDatabaseContext ;
17
20
import org .jabref .model .entry .BibEntry ;
18
21
import org .jabref .model .util .DummyFileUpdateMonitor ;
19
-
20
22
import org .junit .jupiter .api .BeforeEach ;
21
23
import org .junit .jupiter .api .Disabled ;
22
24
import org .junit .jupiter .api .extension .ExtendWith ;
23
25
import org .junit .jupiter .params .ParameterizedTest ;
24
26
import org .junit .jupiter .params .provider .MethodSource ;
25
27
import org .junitpioneer .jupiter .TempDirectory ;
26
28
import org .mockito .Answers ;
29
+ import org .mockito .Mockito ;
27
30
import org .xmlunit .builder .Input ;
28
31
import org .xmlunit .builder .Input .Builder ;
29
32
import org .xmlunit .diff .DefaultNodeMatcher ;
30
33
import org .xmlunit .diff .ElementSelectors ;
31
34
import org .xmlunit .matchers .CompareMatcher ;
32
35
33
- import static org .hamcrest .MatcherAssert .assertThat ;
34
- import static org .mockito .Mockito .mock ;
35
-
36
36
@ ExtendWith (TempDirectory .class )
37
37
public class ModsExportFormatTestFiles {
38
38
@@ -65,8 +65,10 @@ public void setUp(@TempDirectory.TempDir Path testFolder) throws Exception {
65
65
Path path = testFolder .resolve ("ARandomlyNamedFile.tmp" );
66
66
Files .createFile (path );
67
67
tempFile = path .toAbsolutePath ();
68
- bibtexImporter = new BibtexImporter (mock (ImportFormatPreferences .class , Answers .RETURNS_DEEP_STUBS ), new DummyFileUpdateMonitor ());
69
- modsImporter = new ModsImporter (mock (ImportFormatPreferences .class , Answers .RETURNS_DEEP_STUBS ));
68
+ ImportFormatPreferences mock = mock (ImportFormatPreferences .class , Answers .RETURNS_DEEP_STUBS );
69
+ bibtexImporter = new BibtexImporter (mock , new DummyFileUpdateMonitor ());
70
+ Mockito .when (mock .getKeywordSeparator ()).thenReturn (',' );
71
+ modsImporter = new ModsImporter (mock );
70
72
}
71
73
72
74
@ Disabled
@@ -78,17 +80,16 @@ public final void testPerformExport(String filename) throws Exception {
78
80
Path tempFilename = tempFile .toAbsolutePath ();
79
81
List <BibEntry > entries = bibtexImporter .importDatabase (importFile , charset ).getDatabase ().getEntries ();
80
82
Path xmlFile = Paths .get (ModsExportFormatTestFiles .class .getResource (xmlFileName ).toURI ());
81
-
83
+
82
84
modsExportFormat .export (databaseContext , tempFile , charset , entries );
83
85
84
86
Builder control = Input .from (Files .newInputStream (xmlFile ));
85
87
Builder test = Input .from (Files .newInputStream (tempFilename ));
86
-
87
88
assertThat (test , CompareMatcher .isSimilarTo (control )
88
89
.withNodeMatcher (new DefaultNodeMatcher (ElementSelectors .byNameAndText )).throwComparisonFailure ());
89
90
}
90
91
91
- @ Disabled
92
+
92
93
@ ParameterizedTest
93
94
@ MethodSource ("fileNames" )
94
95
public final void testExportAsModsAndThenImportAsMods (String filename ) throws Exception {
0 commit comments