Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ooPanel
Browse files Browse the repository at this point in the history
* upstream/master:
  Correct PNAS abbrev. (#4524)
  Create test (#4518)
  Bump junit-jupiter-params from 5.3.1 to 5.3.2 (#4514)
  Bump junit-vintage-engine from 5.3.1 to 5.3.2 (#4511)
  Bump junit-jupiter-engine from 5.3.1 to 5.3.2 (#4513)
  Bump richtextfx from 0.9.1 to 0.9.2 (#4512)
  Bump junit-jupiter-api from 5.3.1 to 5.3.2 (#4510)
  Bump junit-platform-launcher from 1.3.1 to 1.3.2 (#4515)
  • Loading branch information
Siedlerchr committed Dec 1, 2018
2 parents 3b9d6c4 + 65a1a03 commit 8be8bdc
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 14 deletions.
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ dependencies {
compile 'de.saxsys:mvvmfx:1.7.0'
compile 'org.fxmisc.easybind:easybind:1.0.3'
compile 'org.fxmisc.flowless:flowless:0.6.1'
compile 'org.fxmisc.richtext:richtextfx:0.9.1'
compile 'org.fxmisc.richtext:richtextfx:0.9.2'
compile 'com.sibvisions.external.jvxfx:dndtabpane:0.1'
compile 'javax.inject:javax.inject:1'
compile 'com.jfoenix:jfoenix:8.0.7'
Expand All @@ -160,11 +160,12 @@ dependencies {
compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.2.1'
compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.2.1'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.1'
testCompile 'org.junit.platform:junit-platform-launcher:1.3.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.3.2'
testCompile 'org.junit.platform:junit-platform-launcher:1.3.2'

testCompile 'org.junit-pioneer:junit-pioneer:0.3.0'
testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1'
testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.1'
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/org/jabref/gui/exporter/SaveAllAction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.exporter;

import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.Actions;
import org.jabref.gui.actions.SimpleCommand;
Expand All @@ -9,23 +10,27 @@
public class SaveAllAction extends SimpleCommand {

private final JabRefFrame frame;
private final DialogService dialogService;

public SaveAllAction(JabRefFrame frame) {
this.frame = frame;
this.dialogService = frame.getDialogService();
}

@Override
public void execute() {
frame.output(Localization.lang("Saving all libraries..."));
dialogService.notify(Localization.lang("Saving all libraries..."));

for (BasePanel panel : frame.getBasePanelList()) {
if (!panel.getBibDatabaseContext().getDatabasePath().isPresent()) {
frame.showBasePanel(panel);

// TODO: Ask for path
//It will ask a path before saving.
panel.runCommand(Actions.SAVE_AS);
} else {
panel.runCommand(Actions.SAVE);
// TODO: can we find out whether the save was actually done or not?
}
panel.runCommand(Actions.SAVE);
// TODO: can we find out whether the save was actually done or not?
}
frame.output(Localization.lang("Save all finished."));

dialogService.notify(Localization.lang("Save all finished."));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/journals/journalList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12215,7 +12215,7 @@ Proceedings of the Koninklijke Nederlandse Akademie Van Wetenschappen. Series C:
Proceedings of the Latvian Academy of Sciences, Section B: Natural, Exact and Applied Sciences = Proc. Latv. Acad. Sci. Sect. B
Proceedings of the Mine Medical Officers Association = Proc. Mine Med. Off. Assoc.
Proceedings of the Mine Medical Officers Association of SA = Proc. Mine Med. Off. Assoc. SA
Proceedings of the National academy of Sciences of the United States of America = Proc. Natl. Acad. Sci. U.S.A.
Proceedings of the National Academy of Sciences of the United States of America = Proc. Natl. Acad. Sci. U.S.A.
Proceedings of the National Cancer Conference = Proc. Natl. Cancer Conf.
Proceedings of the National Science Council, Republic of China. Part B, Life Sciences = Proc. Natl. Sci. Counc. Repub. China B
Proceedings of the Nutrition Society = Proc. Nutr. Soc.
Expand Down
77 changes: 77 additions & 0 deletions src/test/java/org/jabref/gui/exporter/SaveAllActionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.jabref.gui.exporter;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Optional;

import org.jabref.gui.BasePanel;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.actions.Actions;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;

import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class SaveAllActionTest {

private BasePanel firstPanel = mock(BasePanel.class);
private BasePanel secondPanel = mock(BasePanel.class);
private JabRefFrame jabRefFrame = mock(JabRefFrame.class);
private DialogService dialogService = mock(DialogService.class);
private BibDatabaseContext bibDatabaseContext = mock(BibDatabaseContext.class);
private Optional<Path> databasePath = Optional.of(Paths.get("C:\\Users\\John_Doe\\Jabref"));
private SaveAllAction saveAllAction;

@Before
public void setUp() {
when(firstPanel.getBibDatabaseContext()).thenReturn(bibDatabaseContext);
when(secondPanel.getBibDatabaseContext()).thenReturn(bibDatabaseContext);
when(bibDatabaseContext.getDatabasePath()).thenReturn(databasePath);

when(jabRefFrame.getBasePanelList()).thenReturn(Arrays.asList(firstPanel, secondPanel));
when(jabRefFrame.getDialogService()).thenReturn(dialogService);

saveAllAction = new SaveAllAction(jabRefFrame);
}

@Test
public void executeShouldRunSaveCommandInEveryPanel() {
doNothing().when(dialogService).notify(anyString());

saveAllAction.execute();

verify(firstPanel, times(1)).runCommand(Actions.SAVE);
verify(secondPanel, times(1)).runCommand(Actions.SAVE);
}

@Test
public void executeShouldNotifyAboutSavingProcess() {
when(bibDatabaseContext.getDatabasePath()).thenReturn(databasePath);

saveAllAction.execute();

verify(dialogService, times(1)).notify(Localization.lang("Saving all libraries..."));
verify(dialogService, times(1)).notify(Localization.lang("Save all finished."));
}

@Test
public void executeShouldShowSaveAsWindowIfDatabaseNotSelected() {
when(bibDatabaseContext.getDatabasePath()).thenReturn(Optional.empty());
doNothing().when(dialogService).notify(anyString());

saveAllAction.execute();

verify(firstPanel, times(1)).runCommand(Actions.SAVE_AS);
verify(secondPanel, times(1)).runCommand(Actions.SAVE_AS);
}
}

0 comments on commit 8be8bdc

Please sign in to comment.