Skip to content

Commit f5f4039

Browse files
committed
Add ArgumentProcessor Test class
Add test for aux files
1 parent cd70582 commit f5f4039

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.jabref.cli;
2+
3+
import java.nio.file.Files;
4+
import java.nio.file.Path;
5+
import java.util.List;
6+
7+
import org.jabref.cli.ArgumentProcessor.Mode;
8+
import org.jabref.logic.exporter.SavePreferences;
9+
import org.jabref.model.metadata.SaveOrderConfig;
10+
import org.jabref.preferences.PreferencesService;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.Test;
13+
import org.junit.jupiter.api.io.TempDir;
14+
import org.mockito.Answers;
15+
16+
import static org.junit.jupiter.api.Assertions.assertTrue;
17+
import static org.mockito.Mockito.mock;
18+
import static org.mockito.Mockito.when;
19+
20+
21+
class ArgumentProcessorTest {
22+
23+
private ArgumentProcessor processor;
24+
25+
private final PreferencesService preferencesService = mock(PreferencesService.class, Answers.RETURNS_DEEP_STUBS);
26+
private final SavePreferences savePreferences = mock(SavePreferences.class, Answers.RETURNS_DEEP_STUBS);
27+
28+
29+
@BeforeEach()
30+
void setup() {
31+
when(savePreferences.getSaveOrder()).thenReturn(SaveOrderConfig.getDefaultSaveOrder());
32+
when(preferencesService.getSavePreferences()).thenReturn(savePreferences);
33+
}
34+
35+
36+
@Test
37+
void testAux(@TempDir Path tempDir) throws Exception {
38+
39+
String auxFile = Path.of(AuxCommandLineTest.class.getResource("paper.aux").toURI()).toAbsolutePath().toString();
40+
String originBib = Path.of(AuxCommandLineTest.class.getResource("origin.bib").toURI()).toAbsolutePath().toString();
41+
42+
Path outputBib = tempDir.resolve("output.bib").toAbsolutePath();
43+
String outputBibFile = outputBib.toAbsolutePath().toString();
44+
45+
List<String> args = List.of("--nogui", "--debug", "--aux", auxFile + "," + outputBibFile, originBib);
46+
47+
processor = new ArgumentProcessor(args.toArray(String[]::new), Mode.INITIAL_START, preferencesService);
48+
49+
assertTrue(Files.exists(outputBib));
50+
51+
}
52+
53+
}

0 commit comments

Comments
 (0)