Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goml jb duplicate resolver dialog bug bib tex key duplicate checkthrows npe #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
78 changes: 78 additions & 0 deletions src/test/java/org/jabref/gui/DuplicateResolverDialogTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}