Skip to content

Commit

Permalink
fix: fixed round-trip test to use mock citatioKeyPatternPreferences c…
Browse files Browse the repository at this point in the history
…orrectly (#10995)
  • Loading branch information
jeanprbt committed Mar 20, 2024
1 parent ca9c0dc commit 359237d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/test/java/org/jabref/logic/exporter/CffExporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.stream.Stream;

import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences;
import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern;
import org.jabref.logic.importer.fileformat.CffImporter;
import org.jabref.logic.importer.fileformat.CffImporterTest;
import org.jabref.model.database.BibDatabaseContext;
Expand All @@ -20,9 +21,11 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class CffExporterTest {

Expand Down Expand Up @@ -236,7 +239,9 @@ public final void passesModifiedCharset(@TempDir Path tempDir) throws Exception
public final void roundTripTest(@TempDir Path tempDir) throws Exception {

// First, import the file which will be parsed as two entries
CffImporter importer = new CffImporter(mock(CitationKeyPatternPreferences.class));
CitationKeyPatternPreferences citationKeyPatternPreferences = mock(CitationKeyPatternPreferences.class, Answers.RETURNS_SMART_NULLS);
when(citationKeyPatternPreferences.getKeyPattern()).thenReturn(GlobalCitationKeyPattern.fromPattern("[auth][year]"));
CffImporter importer = new CffImporter(citationKeyPatternPreferences);
Path file = Path.of(CffImporterTest.class.getResource("CITATION.cff").toURI());
List<BibEntry> bibEntries = importer.importDatabase(file).getDatabase().getEntries();
BibEntry softwareEntry = bibEntries.getFirst();
Expand Down

0 comments on commit 359237d

Please sign in to comment.