diff --git a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java index 2ce86d731c4..b2e45d10c4e 100644 --- a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java +++ b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java @@ -1051,6 +1051,7 @@ public void mousePressed(MouseEvent e) { if (other.isPresent()) { // This will be true if the duplicate is in the existing // database. + //TODO: this could be where duplicate resolving bug starts DuplicateResolverDialog diag = new DuplicateResolverDialog(getFrame(), other.get(), first, DuplicateResolverDialog.DuplicateResolverType.INSPECTION); diff --git a/src/test/java/org/jabref/gui/DuplicateResolverDialogTest.java b/src/test/java/org/jabref/gui/DuplicateResolverDialogTest.java new file mode 100644 index 00000000000..71269acdfb0 --- /dev/null +++ b/src/test/java/org/jabref/gui/DuplicateResolverDialogTest.java @@ -0,0 +1,78 @@ +package org.jabref.gui; + +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import org.jabref.gui.mergeentries.MergeEntries; +import org.jabref.model.database.BibDatabaseMode; +import org.jabref.model.entry.BibEntry; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; +//trying to find how this is linked to BibTexKey Duplicate Check throws NPE Bug#4614 +class DuplicateResolverDialogTest { + + @Test + void givenNewDuplicateResolverDialogAndEmptyParameters_whenInitializing_thenNoError() { + Stage stage = new Stage(); + JabRefFrame frame = new JabRefFrame(stage); + BibEntry one = new BibEntry(); + BibEntry two = new BibEntry(); + DuplicateResolverDialog.DuplicateResolverType type = DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK; + + DuplicateResolverDialog sut = new DuplicateResolverDialog(frame, one, two, type); + } + + @Test + void givenUninitializedStage_whenInitializing_thenNoError() { + Stage sut; + + } + + @Test + void givenInitializedStage_whenInitializing_thenNoError() { + Stage sut = new Stage(StageStyle.DECORATED); + + } + + @Test + void givenNewJabRefFrame_whenInitializing_thenNoError() { + Stage stage = new Stage(); + JabRefFrame sut = new JabRefFrame(stage); + + } + + @Test + void givenNewBibEntry_whenInitializing_thenNoError() { + BibEntry sut = new BibEntry(); + + } + + @Test + void givenNewDuplicateResolverTypeIMPORT_CHECK_whenInitializing_thenEqualsIMPORT_CHECK() { + DuplicateResolverDialog.DuplicateResolverType sut = DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK; + assertEquals(DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK,sut); + } + + @Test + void givenNewDuplicateResolverResultKEEP_LEFT_whenInitializing_thenEqualsIMPORT_CHECK() { + DuplicateResolverDialog.DuplicateResolverResult sut = DuplicateResolverDialog.DuplicateResolverResult.KEEP_LEFT; + assertEquals(DuplicateResolverDialog.DuplicateResolverResult.KEEP_LEFT,sut); + } + + @Test + public void givenDuplicateResolverDialog_whenGetMergedEntry_thenMergedBibEntryMeReturned(){ + Stage stage = new Stage(); + JabRefFrame frame = new JabRefFrame(stage); + BibEntry one = new BibEntry(); + BibEntry two = new BibEntry(); + DuplicateResolverDialog.DuplicateResolverType type = DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK; + + DuplicateResolverDialog testDialog = new DuplicateResolverDialog(frame, one, two, type); + + BibEntry sut = testDialog.getMergedEntry(); + BibDatabaseMode mode = BibDatabaseMode.BIBTEX; + + MergeEntries ans = new MergeEntries(one, two, mode); + assertEquals(ans, sut); + } +}