Skip to content

Commit 08f243a

Browse files
committed
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)
2 parents c1f74a5 + bbe4bf1 commit 08f243a

File tree

6 files changed

+70
-7
lines changed

6 files changed

+70
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2323

2424
- We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614)
2525
- We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389)
26+
- We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466)
2627

2728
### Removed
2829

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ dependencies {
121121
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0'
122122
implementation 'com.h2database:h2-mvstore:2.1.210'
123123

124-
implementation group: 'org.apache.tika', name: 'tika-core', version: '2.2.1'
124+
implementation group: 'org.apache.tika', name: 'tika-core', version: '2.3.0'
125125

126126
// required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635
127127
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
@@ -197,12 +197,12 @@ dependencies {
197197
}
198198

199199
implementation 'com.vladsch.flexmark:flexmark:0.62.2'
200-
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.62.2'
200+
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.64.0'
201201
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.62.2'
202202

203203
implementation group: 'net.harawata', name: 'appdirs', version: '1.2.1'
204204

205-
testImplementation 'io.github.classgraph:classgraph:4.8.138'
205+
testImplementation 'io.github.classgraph:classgraph:4.8.139'
206206
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
207207
testImplementation 'org.junit.platform:junit-platform-launcher:1.8.2'
208208

gradle/wrapper/gradle-wrapper.jar

285 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionSha256Sum=8cc27038d5dbd815759851ba53e70cf62e481b87494cc97cfd97982ada5ba634
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/java/org/jabref/gui/OpenConsoleAction.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public class OpenConsoleAction extends SimpleCommand {
2020
private final StateManager stateManager;
2121
private final PreferencesService preferencesService;
2222

23+
/**
24+
* Creates a command that opens the console at the path of the supplied database,
25+
* or defaults to the active database. Use
26+
* {@link #OpenConsoleAction(StateManager, PreferencesService)} if not supplying
27+
* another database.
28+
*/
2329
public OpenConsoleAction(Supplier<BibDatabaseContext> databaseContext, StateManager stateManager, PreferencesService preferencesService) {
2430
this.databaseContext = databaseContext;
2531
this.stateManager = stateManager;
@@ -29,10 +35,10 @@ public OpenConsoleAction(Supplier<BibDatabaseContext> databaseContext, StateMana
2935
}
3036

3137
/**
32-
* Using this constructor will result in executing the command on the active database
38+
* Using this constructor will result in executing the command on the active database.
3339
*/
3440
public OpenConsoleAction(StateManager stateManager, PreferencesService preferencesService) {
35-
this(null, stateManager, preferencesService);
41+
this(() -> null, stateManager, preferencesService);
3642
}
3743

3844
@Override
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.jabref.gui.util;
2+
3+
import java.util.Optional;
4+
5+
import org.jabref.gui.OpenConsoleAction;
6+
import org.jabref.gui.StateManager;
7+
import org.jabref.model.database.BibDatabaseContext;
8+
import org.jabref.preferences.PreferencesService;
9+
10+
import org.junit.jupiter.api.BeforeEach;
11+
import org.junit.jupiter.api.Test;
12+
13+
import static org.mockito.Mockito.mock;
14+
import static org.mockito.Mockito.never;
15+
import static org.mockito.Mockito.times;
16+
import static org.mockito.Mockito.verify;
17+
import static org.mockito.Mockito.when;
18+
19+
public class OpenConsoleActionTest {
20+
21+
private final StateManager stateManager = mock(StateManager.class);
22+
private final PreferencesService preferences = mock(PreferencesService.class);
23+
private final BibDatabaseContext current = mock(BibDatabaseContext.class);
24+
private final BibDatabaseContext other = mock(BibDatabaseContext.class);
25+
26+
@BeforeEach
27+
public void setup() {
28+
when(stateManager.activeDatabaseProperty()).thenReturn(OptionalObjectProperty.empty());
29+
when(stateManager.getActiveDatabase()).thenReturn(Optional.of(current));
30+
}
31+
32+
@Test
33+
public void newActionGetsCurrentDatabase() {
34+
OpenConsoleAction action = new OpenConsoleAction(stateManager, preferences);
35+
action.execute();
36+
verify(stateManager, times(1)).getActiveDatabase();
37+
verify(current, times(1)).getDatabasePath();
38+
}
39+
40+
@Test
41+
public void newActionGetsSuppliedDatabase() {
42+
OpenConsoleAction action = new OpenConsoleAction(() -> other, stateManager, preferences);
43+
action.execute();
44+
verify(stateManager, never()).getActiveDatabase();
45+
verify(other, times(1)).getDatabasePath();
46+
}
47+
48+
@Test
49+
public void actionDefaultsToCurrentDatabase() {
50+
OpenConsoleAction action = new OpenConsoleAction(() -> null, stateManager, preferences);
51+
action.execute();
52+
verify(stateManager, times(1)).getActiveDatabase();
53+
verify(current, times(1)).getDatabasePath();
54+
}
55+
56+
}

0 commit comments

Comments
 (0)