-
-
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 dbsync
* upstream/main: Update Gradle Wrapper from 7.3.3 to 7.4. (#8499) Bump flexmark-ext-gfm-strikethrough from 0.62.2 to 0.64.0 (#8500) Bump tika-core from 2.2.1 to 2.3.0 (#8501) Bump classgraph from 4.8.138 to 4.8.139 (#8502) Fix for opening console on active database (#8492)
- Loading branch information
Showing
6 changed files
with
70 additions
and
7 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
Binary file not shown.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
distributionSha256Sum=8cc27038d5dbd815759851ba53e70cf62e481b87494cc97cfd97982ada5ba634 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
56 changes: 56 additions & 0 deletions
56
src/test/java/org/jabref/gui/util/OpenConsoleActionTest.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,56 @@ | ||
package org.jabref.gui.util; | ||
|
||
import java.util.Optional; | ||
|
||
import org.jabref.gui.OpenConsoleAction; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class OpenConsoleActionTest { | ||
|
||
private final StateManager stateManager = mock(StateManager.class); | ||
private final PreferencesService preferences = mock(PreferencesService.class); | ||
private final BibDatabaseContext current = mock(BibDatabaseContext.class); | ||
private final BibDatabaseContext other = mock(BibDatabaseContext.class); | ||
|
||
@BeforeEach | ||
public void setup() { | ||
when(stateManager.activeDatabaseProperty()).thenReturn(OptionalObjectProperty.empty()); | ||
when(stateManager.getActiveDatabase()).thenReturn(Optional.of(current)); | ||
} | ||
|
||
@Test | ||
public void newActionGetsCurrentDatabase() { | ||
OpenConsoleAction action = new OpenConsoleAction(stateManager, preferences); | ||
action.execute(); | ||
verify(stateManager, times(1)).getActiveDatabase(); | ||
verify(current, times(1)).getDatabasePath(); | ||
} | ||
|
||
@Test | ||
public void newActionGetsSuppliedDatabase() { | ||
OpenConsoleAction action = new OpenConsoleAction(() -> other, stateManager, preferences); | ||
action.execute(); | ||
verify(stateManager, never()).getActiveDatabase(); | ||
verify(other, times(1)).getDatabasePath(); | ||
} | ||
|
||
@Test | ||
public void actionDefaultsToCurrentDatabase() { | ||
OpenConsoleAction action = new OpenConsoleAction(() -> null, stateManager, preferences); | ||
action.execute(); | ||
verify(stateManager, times(1)).getActiveDatabase(); | ||
verify(current, times(1)).getDatabasePath(); | ||
} | ||
|
||
} |