Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into dbsync
Browse files Browse the repository at this point in the history
* 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
Siedlerchr committed Feb 14, 2022
2 parents c1f74a5 + bbe4bf1 commit 08f243a
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

- We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614)
- 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)
- 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)

### Removed

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0'
implementation 'com.h2database:h2-mvstore:2.1.210'

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

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

implementation 'com.vladsch.flexmark:flexmark:0.62.2'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.62.2'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.64.0'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.62.2'

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

testImplementation 'io.github.classgraph:classgraph:4.8.138'
testImplementation 'io.github.classgraph:classgraph:4.8.139'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.8.2'

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
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
10 changes: 8 additions & 2 deletions src/main/java/org/jabref/gui/OpenConsoleAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public class OpenConsoleAction extends SimpleCommand {
private final StateManager stateManager;
private final PreferencesService preferencesService;

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

/**
* Using this constructor will result in executing the command on the active database
* Using this constructor will result in executing the command on the active database.
*/
public OpenConsoleAction(StateManager stateManager, PreferencesService preferencesService) {
this(null, stateManager, preferencesService);
this(() -> null, stateManager, preferencesService);
}

@Override
Expand Down
56 changes: 56 additions & 0 deletions src/test/java/org/jabref/gui/util/OpenConsoleActionTest.java
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();
}

}

0 comments on commit 08f243a

Please sign in to comment.