Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Jan 13, 2025
1 parent 9b38b78 commit 31a4ff2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static Collection<String> getTestFiles(Predicate<String> fileNamePredicat
return stream
.map(path -> path.getFileName().toString())
.filter(fileNamePredicate)
.filter(name -> !name.equals("pdf")) // There is a `pdf` in {@link TEST_RESOURCES}.
.collect(Collectors.toList());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ void isRecognizedFormatReject() throws IOException, URISyntaxException {

@Test
void getCommandLineId() {
assertEquals("grobidPdf", importer.getId());
assertEquals("pdfGrobid", importer.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.jabref.logic.importer.ImportFormatPreferences;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;

Expand Down Expand Up @@ -51,7 +50,6 @@ void importTwiceWorksAsExpected() throws Exception {
expected.setField(StandardField.JOURNAL, "Some Journal");
expected.setField(StandardField.YEAR, "2021");
expected.setField(StandardField.ISBN, "0134685997");
expected.setFiles(Collections.singletonList(new LinkedFile("", file.toAbsolutePath(), "PDF")));

List<BibEntry> resultSecondImport = importer.importDatabase(file).getDatabase().getEntries();
assertEquals(Collections.singletonList(expected), result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.fileformat.ImporterTestEngine;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -28,11 +23,6 @@ class PdfXmpImporterTest {

private PdfXmpImporter importer;

private static Stream<String> invalidFileNames() throws IOException {
Predicate<String> fileName = name -> !name.contains("annotated.pdf");
return ImporterTestEngine.getTestFiles(fileName).stream();
}

@BeforeEach
void setUp() {
importer = new PdfXmpImporter(mock(XmpPreferences.class));
Expand Down Expand Up @@ -65,10 +55,4 @@ void isRecognizedFormat() throws IOException, URISyntaxException {
Path file = Path.of(PdfXmpImporterTest.class.getResource("annotated.pdf").toURI());
assertTrue(importer.isRecognizedFormat(file));
}

@ParameterizedTest
@MethodSource("invalidFileNames")
void isRecognizedFormatReject(String fileName) throws IOException, URISyntaxException {
ImporterTestEngine.testIsNotRecognizedFormat(importer, fileName);
}
}

0 comments on commit 31a4ff2

Please sign in to comment.