-
-
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.
Fix 2701 too may files found (#2732)
* Splitting up several variables for debugging. * Checking if the 'database' value is not 'null' before invokig a method -- this fixes incorrect match of multiple files caused by a (masked) "null pointer exception". * Restoring the previous (more compact) code style. * Adding a unit test for the new fix. * Removing unused member 'private String patternString'. * Adding another test to MakeLabelWithoutDatabaseTest.java, to cover the second 'if' branch in the 2701 fix. * Removing parameter annotation comments from the tests in MakeLabelWithoutDatabaseTest.java, since IntelliJ handles them automagically. * Removing unused commented-out class member.
- Loading branch information
1 parent
8c41684
commit e7fc94c
Showing
2 changed files
with
53 additions
and
3 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
41 changes: 41 additions & 0 deletions
41
src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithoutDatabaseTest.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.jabref.logic.bibtexkeypattern; | ||
|
||
import org.jabref.model.entry.BibEntry; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class MakeLabelWithoutDatabaseTest { | ||
|
||
private BibEntry entry; | ||
|
||
@Before | ||
public void setUp() { | ||
entry = new BibEntry(); | ||
entry.setField("author", "John Doe"); | ||
entry.setField("year", "2016"); | ||
entry.setField("title", "An awesome paper on JabRef"); | ||
} | ||
|
||
@Test | ||
public void makeLabelForFileSearch() { | ||
String label = | ||
BibtexKeyPatternUtil.makeLabel(entry, "auth", ',', null); | ||
assertEquals("Doe", label); | ||
} | ||
|
||
@Test | ||
public void makeEditorLabelForFileSearch() { | ||
BibEntry localEntry = new BibEntry(); | ||
localEntry.setField("editor", "John Doe"); | ||
localEntry.setField("year", "2016"); | ||
localEntry.setField("title", "An awesome paper on JabRef"); | ||
|
||
String label = | ||
BibtexKeyPatternUtil.makeLabel(localEntry, "auth", ',', null); | ||
assertEquals("Doe", label); | ||
} | ||
|
||
} |