-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into fix-rpm-uninstall
* upstream/main: [OO] Major performance improvements & fixes (#12221) move check for invalid characters to linked files editor (#12219) Update Gradle Wrapper from 8.11 to 8.11.1 (#12218)
- Loading branch information
Showing
10 changed files
with
133 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.jabref.gui.linkedfile; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.TreeSet; | ||
|
||
import javafx.collections.FXCollections; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.externalfiletype.ExternalFileTypes; | ||
import org.jabref.gui.frame.ExternalApplicationsPreferences; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.FilePreferences; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.LinkedFile; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
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.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class LinkedFileEditDialogViewModelTest { | ||
private final GuiPreferences preferences = mock(GuiPreferences.class, Answers.RETURNS_DEEP_STUBS); | ||
private final FilePreferences filePreferences = mock(FilePreferences.class, Answers.RETURNS_DEEP_STUBS); | ||
private final BibDatabaseContext bibDatabaseContext = mock(BibDatabaseContext.class); | ||
private final DialogService dialogService = mock(DialogService.class); | ||
private final ExternalApplicationsPreferences externalApplicationsPreferences = mock(ExternalApplicationsPreferences.class); | ||
|
||
@BeforeEach | ||
void setup() { | ||
when(externalApplicationsPreferences.getExternalFileTypes()).thenReturn(FXCollections.observableSet(new TreeSet<>(ExternalFileTypes.getDefaultExternalFileTypes()))); | ||
when(preferences.getExternalApplicationsPreferences()).thenReturn(externalApplicationsPreferences); | ||
when(preferences.getFilePreferences()).thenReturn(filePreferences); | ||
} | ||
|
||
@Test | ||
void badFilenameCharWillBeReplacedByUnderscore(@TempDir Path tempDir) throws Exception { | ||
|
||
Path invalidFile = tempDir.resolve("?invalid.pdf"); | ||
Files.createFile(invalidFile); | ||
when(dialogService.showConfirmationDialogAndWait(any(), any(), any())).thenReturn(true); | ||
|
||
LinkedFileEditDialogViewModel viewModel = new LinkedFileEditDialogViewModel(new LinkedFile("", "", ""), bibDatabaseContext, dialogService, externalApplicationsPreferences, filePreferences); | ||
|
||
viewModel.checkForBadFileNameAndAdd(invalidFile); | ||
|
||
LinkedFile expectedFile = new LinkedFile("", tempDir.resolve("_invalid.pdf").toString(), "PDF"); | ||
assertEquals(expectedFile, viewModel.getNewLinkedFile()); | ||
} | ||
} |
Oops, something went wrong.