-
-
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.
- Loading branch information
Showing
7 changed files
with
33 additions
and
51 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
19 changes: 2 additions & 17 deletions
19
src/test/java/org/jabref/gui/importer/NewEntryActionTest.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 |
---|---|---|
@@ -1,48 +1,33 @@ | ||
package org.jabref.gui.importer; | ||
|
||
import javafx.collections.FXCollections; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.LibraryTab; | ||
import org.jabref.gui.LibraryTabContainer; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.gui.util.OptionalObjectProperty; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.types.EntryType; | ||
import org.jabref.model.entry.types.StandardEntryType; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
class NewEntryActionTest { | ||
|
||
private NewEntryAction newEntryAction; | ||
private final LibraryTab libraryTab = mock(LibraryTab.class); | ||
private final LibraryTabContainer tabContainer = mock(LibraryTabContainer.class); | ||
private final DialogService dialogService = spy(DialogService.class); | ||
private final GuiPreferences preferences = mock(GuiPreferences.class); | ||
private final StateManager stateManager = mock(StateManager.class); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
when(stateManager.activeDatabaseProperty()).thenReturn(OptionalObjectProperty.empty()); | ||
newEntryAction = new NewEntryAction(() -> libraryTab, dialogService, preferences, stateManager); | ||
} | ||
|
||
@Test | ||
void executeOnSuccessWithFixedType() { | ||
EntryType type = StandardEntryType.Article; | ||
newEntryAction = new NewEntryAction(() -> libraryTab, type, dialogService, preferences, stateManager); | ||
when(tabContainer.getLibraryTabs()).thenReturn(FXCollections.observableArrayList(libraryTab)); | ||
NewEntryAction newEntryAction = new NewEntryAction(type, dialogService, preferences, stateManager); | ||
|
||
newEntryAction.execute(); | ||
newEntryAction.execute(libraryTab); | ||
verify(libraryTab, times(1)).insertEntry(new BibEntry(type)); | ||
} | ||
} |