-
-
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.
JournalAbbreviation search feature (#7804)
- Loading branch information
Showing
7 changed files
with
169 additions
and
9 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
44 changes: 44 additions & 0 deletions
44
src/test/java/org/jabref/gui/preferences/journals/AbbreviationViewModelTest.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,44 @@ | ||
package org.jabref.gui.preferences.journals; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.jabref.logic.journals.Abbreviation; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class AbbreviationViewModelTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideContainsCaseIndependentContains") | ||
void containsCaseIndependentContains(String searchTerm, AbbreviationViewModel abbreviation) { | ||
assertTrue(abbreviation.containsCaseIndependent(searchTerm)); | ||
} | ||
|
||
private static Stream<Arguments> provideContainsCaseIndependentContains() { | ||
return Stream.of( | ||
Arguments.of("name", new AbbreviationViewModel(new Abbreviation("Long Name", "abbr", "unique"))), | ||
Arguments.of("bBr", new AbbreviationViewModel(new Abbreviation("Long Name", "abbr", "unique"))), | ||
Arguments.of("Uniq", new AbbreviationViewModel(new Abbreviation("Long Name", "abbr", "unique"))), | ||
Arguments.of("", new AbbreviationViewModel(new Abbreviation("Long Name", "abbr", "unique"))), | ||
Arguments.of("", new AbbreviationViewModel(new Abbreviation("", "", ""))) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideContainsCaseIndependentDoesNotContain") | ||
void containsCaseIndependentDoesNotContain(String searchTerm, AbbreviationViewModel abbreviation) { | ||
assertFalse(abbreviation.containsCaseIndependent(searchTerm)); | ||
} | ||
|
||
private static Stream<Arguments> provideContainsCaseIndependentDoesNotContain() { | ||
return Stream.of( | ||
Arguments.of("Something else", new AbbreviationViewModel(new Abbreviation("Long Name", "abbr", "unique"))), | ||
Arguments.of("Something", new AbbreviationViewModel(new Abbreviation("", "", ""))) | ||
); | ||
} | ||
} |
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,26 +1,51 @@ | ||
package org.jabref.gui.util; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import javafx.scene.paint.Color; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ColorUtilTest { | ||
|
||
private static final Color C1 = Color.color(0.2, 0.4, 1); | ||
private static final Color C2 = Color.rgb(255, 255, 255); | ||
private static final Color C3 = Color.color(0, 0, 0, 0); | ||
private static final Color C4 = Color.color(1, 1, 1, 1); | ||
private static final Color C5 = Color.color(0.6, 0.8, 0.5, 0.3); | ||
|
||
private ColorUtil colorUtil = new ColorUtil(); | ||
private final Color c1 = Color.color(0.2, 0.4, 1); | ||
private final Color c2 = Color.rgb(255, 255, 255); | ||
|
||
@Test | ||
public void toRGBCodeTest() { | ||
assertEquals("#3366FF", ColorUtil.toRGBCode(c1)); | ||
assertEquals("#FFFFFF", ColorUtil.toRGBCode(c2)); | ||
assertEquals("#3366FF", ColorUtil.toRGBCode(C1)); | ||
assertEquals("#FFFFFF", ColorUtil.toRGBCode(C2)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideToRGBACodeTest") | ||
public void toRGBACodeTest(Color color, String expected) { | ||
assertEquals(expected, ColorUtil.toRGBACode(color)); | ||
} | ||
|
||
private static Stream<Arguments> provideToRGBACodeTest() { | ||
return Stream.of( | ||
Arguments.of(C1, String.format("rgba(51,102,255,%f)", 1.0)), | ||
Arguments.of(C2, String.format("rgba(255,255,255,%f)", 1.0)), | ||
Arguments.of(C3, String.format("rgba(0,0,0,%f)", 0.0)), | ||
Arguments.of(C4, String.format("rgba(255,255,255,%f)", 1.0)), | ||
Arguments.of(C5, String.format("rgba(153,204,127,%f)", 0.3)) | ||
); | ||
} | ||
|
||
@Test | ||
public void toHexTest() { | ||
assertEquals("#000001", ColorUtil.toHex(c1)); | ||
assertEquals("#010101", ColorUtil.toHex(c2)); | ||
assertEquals("#000001", ColorUtil.toHex(C1)); | ||
assertEquals("#010101", ColorUtil.toHex(C2)); | ||
} | ||
} |