Skip to content

Commit a23d3c8

Browse files
committed
fix: address Checkstyle issues
1 parent 2a6604e commit a23d3c8

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private Optional<Abbreviation> findAbbreviationFuzzyMatched(String input) {
226226
}
227227

228228
/**
229-
* Finds the best matching abbreviation by fuzzy matching from a collection of abbreviations
229+
* Finds the best matching abbreviation by fuzzy matching from a collection of abbreviations.
230230
*
231231
* @param abbreviations Collection of abbreviations to search
232232
* @param input The input string to match against

src/test/java/org/jabref/gui/journals/UndoableUnabbreviatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.jabref.gui.journals;
22

3-
import java.util.List;
3+
import java.util.Set;
44

55
import javax.swing.undo.CompoundEdit;
66

@@ -37,11 +37,11 @@ class UndoableUnabbreviatorTest {
3737
@BeforeEach
3838
void setUp() {
3939
repository = new JournalAbbreviationRepository();
40-
repository.addCustomAbbreviations(List.of(BUILT_IN_1, BUILT_IN_2),
40+
repository.addCustomAbbreviations(Set.of(BUILT_IN_1, BUILT_IN_2),
4141
JournalAbbreviationRepository.BUILTIN_LIST_ID,
4242
true);
4343

44-
repository.addCustomAbbreviations(List.of(CUSTOM_1, CUSTOM_2),
44+
repository.addCustomAbbreviations(Set.of(CUSTOM_1, CUSTOM_2),
4545
CUSTOM_SOURCE,
4646
true);
4747

src/test/java/org/jabref/gui/preferences/journals/JournalAbbreviationsViewModelTabTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Arrays;
88
import java.util.List;
99
import java.util.Optional;
10+
import java.util.stream.Collectors;
1011
import java.util.stream.Stream;
1112

1213
import javafx.beans.property.SimpleBooleanProperty;

src/test/java/org/jabref/logic/journals/AbbreviationsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.jabref.logic.journals;
22

3-
import java.util.List;
43
import java.util.Optional;
4+
import java.util.Set;
55

66
import org.junit.jupiter.api.BeforeEach;
77
import org.junit.jupiter.api.Test;
@@ -22,7 +22,7 @@ class AbbreviationsTest {
2222
void setUp() {
2323
repository = new JournalAbbreviationRepository();
2424

25-
repository.addCustomAbbreviations(List.of(TEST_JOURNAL, DOTTED_JOURNAL),
25+
repository.addCustomAbbreviations(Set.of(TEST_JOURNAL, DOTTED_JOURNAL),
2626
JournalAbbreviationRepository.BUILTIN_LIST_ID,
2727
true);
2828
}

src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class JournalAbbreviationRepositoryTest {
5252
private JournalAbbreviationRepository createTestRepository() {
5353
JournalAbbreviationRepository testRepo = new JournalAbbreviationRepository();
5454

55-
testRepo.addCustomAbbreviations(List.of(
55+
testRepo.addCustomAbbreviations(Set.of(
5656
AMERICAN_JOURNAL,
5757
ACS_MATERIALS,
5858
ANTIOXIDANTS,
@@ -409,7 +409,7 @@ void dotlessForPhysRevB() {
409409
@ParameterizedTest
410410
@MethodSource("provideAbbreviationTestCases")
411411
void fuzzyMatch(List<Abbreviation> abbreviationList, String input, String expectedAbbreviation, String expectedDotless, String expectedShortest, String ambiguousInput) {
412-
repository.addCustomAbbreviations(abbreviationList);
412+
repository.addCustomAbbreviations(Set.copyOf(abbreviationList));
413413

414414
assertEquals(expectedAbbreviation, repository.getDefaultAbbreviation(input).orElse("WRONG"));
415415

@@ -423,7 +423,7 @@ void fuzzyMatch(List<Abbreviation> abbreviationList, String input, String expect
423423
static Stream<Arguments> provideAbbreviationTestCases() {
424424
return Stream.of(
425425
Arguments.of(
426-
List.of(
426+
Set.of(
427427
new Abbreviation("Journal of Physics A", "J. Phys. A", "JPA"),
428428
new Abbreviation("Journal of Physics B", "J. Phys. B", "JPB"),
429429
new Abbreviation("Journal of Physics C", "J. Phys. C", "JPC")
@@ -435,7 +435,7 @@ static Stream<Arguments> provideAbbreviationTestCases() {
435435
"Journal of Physics"
436436
),
437437
Arguments.of(
438-
List.of(
438+
Set.of(
439439
new Abbreviation("中国物理学报", "物理学报", "ZWP"),
440440
new Abbreviation("中国物理学理", "物理学报报", "ZWP"),
441441
new Abbreviation("中国科学: 物理学", "中科物理", "ZKP")
@@ -447,7 +447,7 @@ static Stream<Arguments> provideAbbreviationTestCases() {
447447
"中国物理学"
448448
),
449449
Arguments.of(
450-
List.of(
450+
Set.of(
451451
new Abbreviation("Zeitschrift für Chem", "Z. Phys. Chem.", "ZPC"),
452452
new Abbreviation("Zeitschrift für Chys", "Z. Angew. Chem.", "ZAC")
453453
),
@@ -464,7 +464,7 @@ static Stream<Arguments> provideAbbreviationTestCases() {
464464
void addCustomAbbreviationsWithEnabledState() {
465465
String sourceKey = "test-source";
466466

467-
repository.addCustomAbbreviations(List.of(
467+
repository.addCustomAbbreviations(Set.of(
468468
new Abbreviation("Journal One", "J. One"),
469469
new Abbreviation("Journal Two", "J. Two")
470470
), sourceKey, true);
@@ -479,7 +479,7 @@ void addCustomAbbreviationsWithEnabledState() {
479479
void disablingSourcePreventsAccessToAbbreviations() {
480480
String sourceKey = "test-source";
481481

482-
repository.addCustomAbbreviations(List.of(
482+
repository.addCustomAbbreviations(Set.of(
483483
new Abbreviation("Unique Journal", "U. J.")
484484
), sourceKey, true);
485485

@@ -497,7 +497,7 @@ void disablingSourcePreventsAccessToAbbreviations() {
497497
void reenablingSourceRestoresAccessToAbbreviations() {
498498
String sourceKey = "test-source";
499499

500-
repository.addCustomAbbreviations(List.of(
500+
repository.addCustomAbbreviations(Set.of(
501501
new Abbreviation("Disabled Journal", "D. J.")
502502
), sourceKey, true);
503503

@@ -545,11 +545,11 @@ void multipleSourcesCanBeToggled() {
545545
String sourceKey1 = "source-1-special";
546546
String sourceKey2 = "source-2-special";
547547

548-
testRepo.addCustomAbbreviations(List.of(
548+
testRepo.addCustomAbbreviations(Set.of(
549549
new Abbreviation("Unique Journal Source One XYZ", "UniqueJS1")
550550
), sourceKey1, true);
551551

552-
testRepo.addCustomAbbreviations(List.of(
552+
testRepo.addCustomAbbreviations(Set.of(
553553
new Abbreviation("Unique Journal Source Two ABC", "UniqueJS2")
554554
), sourceKey2, true);
555555

@@ -624,15 +624,15 @@ void getAllAbbreviationsWithSourcesReturnsCorrectSources() {
624624

625625
testRepo.getCustomAbbreviations().clear();
626626

627-
testRepo.addCustomAbbreviations(List.of(
627+
testRepo.addCustomAbbreviations(Set.of(
628628
AMERICAN_JOURNAL,
629629
ACS_MATERIALS,
630630
ANTIOXIDANTS,
631631
PHYSICAL_REVIEW
632632
), JournalAbbreviationRepository.BUILTIN_LIST_ID, true);
633633

634634
String customSource = "test-custom";
635-
testRepo.addCustomAbbreviations(List.of(
635+
testRepo.addCustomAbbreviations(Set.of(
636636
new Abbreviation("Custom Journal", "Cust. J.")
637637
), customSource, true);
638638

@@ -657,7 +657,7 @@ void getAllAbbreviationsWithSourcesReturnsCorrectSources() {
657657
assertTrue(customAbbr.isPresent(), "Should find custom abbreviation with source");
658658
assertEquals("Custom Journal", customAbbr.get().getAbbreviation().getName());
659659

660-
for (Abbreviation abbr : List.of(AMERICAN_JOURNAL, ACS_MATERIALS, ANTIOXIDANTS, PHYSICAL_REVIEW)) {
660+
for (Abbreviation abbr : Set.of(AMERICAN_JOURNAL, ACS_MATERIALS, ANTIOXIDANTS, PHYSICAL_REVIEW)) {
661661
boolean found = allWithSources.stream()
662662
.anyMatch(aws -> JournalAbbreviationRepository.BUILTIN_LIST_ID.equals(aws.getSource()) &&
663663
abbr.getName().equals(aws.getAbbreviation().getName()));

0 commit comments

Comments
 (0)