-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathAuxCommandLineTest.java
More file actions
47 lines (37 loc) · 1.69 KB
/
AuxCommandLineTest.java
File metadata and controls
47 lines (37 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package org.jabref.cli;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.fileformat.BibtexParser;
import org.jabref.model.database.BibDatabase;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Answers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.mock;
class AuxCommandLineTest {
private ImportFormatPreferences importFormatPreferences;
@BeforeEach
void setUp() throws Exception {
importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS);
}
@Test
void test() throws URISyntaxException, IOException {
InputStream originalStream = AuxCommandLineTest.class.getResourceAsStream("origin.bib");
File auxFile = Path.of(AuxCommandLineTest.class.getResource("paper.aux").toURI()).toFile();
try (InputStreamReader originalReader = new InputStreamReader(originalStream, StandardCharsets.UTF_8)) {
ParserResult result = new BibtexParser(importFormatPreferences).parse(originalReader);
AuxCommandLine auxCommandLine = new AuxCommandLine(auxFile.getAbsolutePath(), result.getDatabase());
BibDatabase newDB = auxCommandLine.perform();
assertNotNull(newDB);
assertEquals(2, newDB.getEntries().size());
}
}
}