Skip to content

Commit

Permalink
Apply RemoveTestPrefix (JabRef#10823)
Browse files Browse the repository at this point in the history
* Result of recipe RemoveTestPrefix

* Fix @MethodSource references

* Fix compile issues

* Fix method name

* Add another assertion
  • Loading branch information
koppor authored Jan 29, 2024
1 parent 0b8748d commit 936ab5f
Show file tree
Hide file tree
Showing 221 changed files with 1,249 additions and 1,246 deletions.
1 change: 1 addition & 0 deletions rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@ recipeList:
- org.openrewrite.staticanalysis.WhileInsteadOfFor
# - org.openrewrite.staticanalysis.WriteOctalValuesAsDecimal

- org.openrewrite.java.testing.cleanup.RemoveTestPrefix
- org.openrewrite.java.testing.junit5.CleanupAssertions
# - org.openrewrite.java.testing.junit5.JUnit5BestPractices
2 changes: 1 addition & 1 deletion src/test/java/org/jabref/IconsPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class IconsPropertiesTest {

@Test
public void testExistenceOfIconImagesReferencedFromIconsProperties() throws IOException {
public void existenceOfIconImagesReferencedFromIconsProperties() throws IOException {
String folder = "src/main/resources/images/external";
String iconsProperties = "Icons.properties";
String iconsPropertiesPath = "src/main/resources/images/" + iconsProperties;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jabref/cli/ArgumentProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void setup() {
}

@Test
void testAuxImport(@TempDir Path tempDir) throws Exception {
void auxImport(@TempDir Path tempDir) throws Exception {
String auxFile = Path.of(AuxCommandLineTest.class.getResource("paper.aux").toURI()).toAbsolutePath().toString();
String originBib = Path.of(AuxCommandLineTest.class.getResource("origin.bib").toURI()).toAbsolutePath().toString();

Expand All @@ -75,7 +75,7 @@ void testAuxImport(@TempDir Path tempDir) throws Exception {
}

@Test
void testExportMatches(@TempDir Path tempDir) throws Exception {
void exportMatches(@TempDir Path tempDir) throws Exception {
Path originBib = Path.of(Objects.requireNonNull(ArgumentProcessorTest.class.getResource("origin.bib")).toURI());
String originBibFile = originBib.toAbsolutePath().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class AppendPersonNamesStrategyTest {

@Test
void testWithoutParam() {
void withoutParam() {
AppendPersonNamesStrategy strategy = new AppendPersonNamesStrategy();
assertEquals(" and ", strategy.getDelimiter());
}
Expand All @@ -19,7 +19,7 @@ void testWithoutParam() {
"TRUE, ' '",
"FALSE, ' and '",
})
void testWithParam(boolean separationBySpace, String expectedResult) {
void withParam(boolean separationBySpace, String expectedResult) {
AppendPersonNamesStrategy strategy = new AppendPersonNamesStrategy(separationBySpace);
assertEquals(expectedResult, strategy.getDelimiter());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void setUp() {
"FALSE, TRUE, BOTH, 'Reagle, Jr., J. M.'",
"FALSE, FALSE, BOTH, 'Reagle'"
})
void testToStringWithoutAutoCompletePreferences(boolean autoCompFF, boolean autoCompLF, AutoCompleteFirstNameMode autoCompleteFirstNameMode, String expectedResult) {
void toStringWithoutAutoCompletePreferences(boolean autoCompFF, boolean autoCompLF, AutoCompleteFirstNameMode autoCompleteFirstNameMode, String expectedResult) {
PersonNameStringConverter converter = new PersonNameStringConverter(autoCompFF, autoCompLF, autoCompleteFirstNameMode);
String formattedStr = converter.toString(author);
assertEquals(expectedResult, formattedStr);
Expand All @@ -58,7 +58,7 @@ void testToStringWithoutAutoCompletePreferences(boolean autoCompFF, boolean auto
"TRUE, ONLY_ABBREVIATED, BOTH, 'Reagle, Jr., J. M.'",
"TRUE, BOTH, BOTH, 'Reagle, Jr., J. M.'"
})
void testToStringWithAutoCompletePreferences(boolean shouldAutoComplete,
void toStringWithAutoCompletePreferences(boolean shouldAutoComplete,
AutoCompleteFirstNameMode firstNameMode,
AutoCompletePreferences.NameFormat nameFormat,
String expectedResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static Stream<Arguments> getTestPairs() {

@ParameterizedTest
@MethodSource("getTestPairs")
public void testAppropriateCompleterReturned(Class<SuggestionProvider<BibEntry>> expected, Field field) {
public void appropriateCompleterReturned(Class<SuggestionProvider<BibEntry>> expected, Field field) {
assertEquals(expected, suggestionProviders.getForField(field).getClass());
}

Expand Down
20 changes: 10 additions & 10 deletions src/test/java/org/jabref/gui/edit/CopyMoreActionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setUp() {
}

@Test
public void testExecuteOnFail() {
public void executeOnFail() {
when(stateManager.getActiveDatabase()).thenReturn(Optional.empty());
when(stateManager.getSelectedEntries()).thenReturn(FXCollections.emptyObservableList());
copyMoreAction = new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository);
Expand All @@ -78,7 +78,7 @@ public void testExecuteOnFail() {
}

@Test
public void testExecuteCopyTitleWithNoTitle() {
public void executeCopyTitleWithNoTitle() {
BibEntry entryWithNoTitle = (BibEntry) entry.clone();
entryWithNoTitle.clearField(StandardField.TITLE);
ObservableList<BibEntry> entriesWithNoTitles = FXCollections.observableArrayList(entryWithNoTitle);
Expand All @@ -94,7 +94,7 @@ public void testExecuteCopyTitleWithNoTitle() {
}

@Test
public void testExecuteCopyTitleOnPartialSuccess() {
public void executeCopyTitleOnPartialSuccess() {
BibEntry entryWithNoTitle = (BibEntry) entry.clone();
entryWithNoTitle.clearField(StandardField.TITLE);
ObservableList<BibEntry> mixedEntries = FXCollections.observableArrayList(entryWithNoTitle, entry);
Expand All @@ -112,7 +112,7 @@ public void testExecuteCopyTitleOnPartialSuccess() {
}

@Test
public void testExecuteCopyTitleOnSuccess() {
public void executeCopyTitleOnSuccess() {
ObservableList<BibEntry> entriesWithTitles = FXCollections.observableArrayList(entry);
BibDatabaseContext databaseContext = new BibDatabaseContext(new BibDatabase(entriesWithTitles));

Expand All @@ -128,7 +128,7 @@ public void testExecuteCopyTitleOnSuccess() {
}

@Test
public void testExecuteCopyKeyWithNoKey() {
public void executeCopyKeyWithNoKey() {
BibEntry entryWithNoKey = (BibEntry) entry.clone();
entryWithNoKey.clearCiteKey();
ObservableList<BibEntry> entriesWithNoKeys = FXCollections.observableArrayList(entryWithNoKey);
Expand All @@ -144,7 +144,7 @@ public void testExecuteCopyKeyWithNoKey() {
}

@Test
public void testExecuteCopyKeyOnPartialSuccess() {
public void executeCopyKeyOnPartialSuccess() {
BibEntry entryWithNoKey = (BibEntry) entry.clone();
entryWithNoKey.clearCiteKey();
ObservableList<BibEntry> mixedEntries = FXCollections.observableArrayList(entryWithNoKey, entry);
Expand All @@ -162,7 +162,7 @@ public void testExecuteCopyKeyOnPartialSuccess() {
}

@Test
public void testExecuteCopyKeyOnSuccess() {
public void executeCopyKeyOnSuccess() {
ObservableList<BibEntry> entriesWithKeys = FXCollections.observableArrayList(entry);
BibDatabaseContext databaseContext = new BibDatabaseContext(new BibDatabase(entriesWithKeys));

Expand All @@ -178,7 +178,7 @@ public void testExecuteCopyKeyOnSuccess() {
}

@Test
public void testExecuteCopyDoiWithNoDoi() {
public void executeCopyDoiWithNoDoi() {
BibEntry entryWithNoDoi = (BibEntry) entry.clone();
entryWithNoDoi.clearField(StandardField.DOI);
ObservableList<BibEntry> entriesWithNoDois = FXCollections.observableArrayList(entryWithNoDoi);
Expand All @@ -194,7 +194,7 @@ public void testExecuteCopyDoiWithNoDoi() {
}

@Test
public void testExecuteCopyDoiOnPartialSuccess() {
public void executeCopyDoiOnPartialSuccess() {
BibEntry entryWithNoDoi = (BibEntry) entry.clone();
entryWithNoDoi.clearField(StandardField.DOI);
ObservableList<BibEntry> mixedEntries = FXCollections.observableArrayList(entryWithNoDoi, entry);
Expand All @@ -212,7 +212,7 @@ public void testExecuteCopyDoiOnPartialSuccess() {
}

@Test
public void testExecuteCopyDoiOnSuccess() {
public void executeCopyDoiOnSuccess() {
ObservableList<BibEntry> entriesWithDois = FXCollections.observableArrayList(entry);
BibDatabaseContext databaseContext = new BibDatabaseContext(new BibDatabase(entriesWithDois));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void setUp() {
"and, '', author, TRUE, FALSE, 2", // replace two "and"s with empty string in the same AUTHOR field
"' ', ',', date, TRUE, FALSE, 1" // replace space with comma in DATE field
})
void testReplace(String findString, String replaceString, String fieldString, boolean selectOnly, boolean allFieldReplace, int expectedResult) {
void replace(String findString, String replaceString, String fieldString, boolean selectOnly, boolean allFieldReplace, int expectedResult) {
viewModel.findStringProperty().bind(new SimpleStringProperty(findString));
viewModel.replaceStringProperty().bind(new SimpleStringProperty(replaceString));
viewModel.fieldStringProperty().bind(new SimpleStringProperty(fieldString));
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jabref/gui/entryeditor/CommentsTabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void commentFieldShownIfContainsText(boolean shouldShowUserCommentsFields) {
}

@Test
void testDetermineFieldsToShowWorksForMultipleUsers() {
void determineFieldsToShowWorksForMultipleUsers() {
final UserSpecificCommentField ownerComment = new UserSpecificCommentField(ownerName);
final UserSpecificCommentField otherUsersComment = new UserSpecificCommentField("other-user-id");

Expand All @@ -159,7 +159,7 @@ void testDetermineFieldsToShowWorksForMultipleUsers() {
}

@Test
public void testDifferentiateCaseInUserName() {
public void differentiateCaseInUserName() {
UserSpecificCommentField field1 = new UserSpecificCommentField("USER");
UserSpecificCommentField field2 = new UserSpecificCommentField("user");
assertNotEquals(field1, field2, "Two UserSpecificCommentField instances with usernames that differ only by case should be considered different");
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/jabref/gui/entryeditor/SciteTabTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ void setUp() {
}

@Test
public void testName() {
public void name() {
Assertions.assertEquals(SciteTab.NAME, "Citation information");
}

@Test
public void testShouldShow() {
public void shouldShow() {
var tab = new SciteTab(preferencesService, taskExecutor, dialogService);
boolean shouldShow = tab.shouldShow(null);
Assertions.assertTrue(shouldShow);
}

@Test
public void testBindNullEntry() {
public void bindNullEntry() {
var tab = new SciteTab(preferencesService, taskExecutor, dialogService);
tab.bindToEntry(null);
}

@Test
public void testBindEntry() {
public void bindEntry() {
var tab = new SciteTab(preferencesService, taskExecutor, dialogService);
var entry = new BibEntry()
.withField(StandardField.DOI, SAMPLE_DOI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void setUp() {
}

@Test
public void testSciteTallyDTO() {
public void sciteTallyDTO() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", 1);
jsonObject.put("supporting", 2);
Expand All @@ -56,7 +56,7 @@ public void testSciteTallyDTO() {
}

@Test
void testFetchTallies() throws FetcherException {
void fetchTallies() throws FetcherException {
var viewModel = new SciteTabViewModel(preferencesService, taskExecutor);
DOI doi = new DOI(SciteTabTest.SAMPLE_DOI);
var actual = DOI.parse(viewModel.fetchTallies(doi).doi());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void setUp() {
}

@Test
void testExistingEntryCitesOtherPaperWithCitationKeys() {
void existingEntryCitesOtherPaperWithCitationKeys() {
var citationItems = List.of(new CitationRelationItem(firstEntryToImport, false),
new CitationRelationItem(secondEntryToImport, false));

Expand All @@ -109,7 +109,7 @@ void testExistingEntryCitesOtherPaperWithCitationKeys() {
}

@Test
void testImportedEntriesWithExistingCitationKeysCiteExistingEntry() {
void importedEntriesWithExistingCitationKeysCiteExistingEntry() {
var citationItems = List.of(new CitationRelationItem(firstEntryToImport, false),
new CitationRelationItem(secondEntryToImport, false));

Expand All @@ -119,7 +119,7 @@ void testImportedEntriesWithExistingCitationKeysCiteExistingEntry() {
}

@Test
void testExistingEntryCitesOtherPaperWithCitationKeysAndExistingCiteField() {
void existingEntryCitesOtherPaperWithCitationKeysAndExistingCiteField() {
existingEntry.setField(StandardField.CITES, "Asdf1222");
var citationItems = List.of(new CitationRelationItem(firstEntryToImport, false),
new CitationRelationItem(secondEntryToImport, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public void setUp() {
}

@Test
public void testExecuteIfNoSelectedEntries() {
public void executeIfNoSelectedEntries() {
when(stateManager.getSelectedEntries()).thenReturn(FXCollections.emptyObservableList());

exportToClipboardAction.execute();
verify(dialogService, times(1)).notify(Localization.lang("This operation requires one or more entries to be selected."));
}

@Test
public void testExecuteOnSuccess() {
public void executeOnSuccess() {
Exporter selectedExporter = new Exporter("html", "HTML", StandardFileType.HTML) {
@Override
public void export(BibDatabaseContext databaseContext, Path file, List<BibEntry> entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void setUp(@TempDir Path folder) throws Exception {
}

@Test
public void testFindAssociatedNotLinkedFilesSuccess() throws Exception {
public void findAssociatedNotLinkedFilesSuccess() throws Exception {
when(databaseContext.getFileDirectories(any())).thenReturn(Collections.singletonList(path.getParent()));
List<LinkedFile> expected = Collections.singletonList(new LinkedFile("", Path.of("CiteKey.pdf"), "PDF"));
AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(databaseContext, filePreferences, autoLinkPrefs);
Expand All @@ -56,7 +56,7 @@ public void testFindAssociatedNotLinkedFilesSuccess() throws Exception {
}

@Test
public void testFindAssociatedNotLinkedFilesForEmptySearchDir() throws Exception {
public void findAssociatedNotLinkedFilesForEmptySearchDir() throws Exception {
when(filePreferences.shouldStoreFilesRelativeToBibFile()).thenReturn(false);
AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(databaseContext, filePreferences, autoLinkPrefs);
List<LinkedFile> actual = util.findAssociatedNotLinkedFiles(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void sortByDateDescendingPositiveTest() {
}

@Test
public void testSortByDateDescendingNegativeTest() {
public void sortByDateDescendingNegativeTest() {
List<String> sortedPaths = fileFilterUtils
.sortByDateDescending(files)
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void validateExistingRelativePath() throws Exception {
}

@Test
void testHierarchicalContextFromGroup() throws Exception {
void hierarchicalContextFromGroup() throws Exception {
GroupHierarchyType groupHierarchyType = GroupHierarchyType.INCLUDING;
when(group.getHierarchicalContext()).thenReturn(groupHierarchyType);
viewModel = new GroupDialogViewModel(dialogService, bibDatabaseContext, preferencesService, group, null, new DummyFileUpdateMonitor());
Expand All @@ -94,7 +94,7 @@ void testHierarchicalContextFromGroup() throws Exception {
}

@Test
void testDefaultHierarchicalContext() throws Exception {
void defaultHierarchicalContext() throws Exception {
GroupHierarchyType defaultHierarchicalContext = GroupHierarchyType.REFINING;
when(preferencesService.getGroupsPreferences().getDefaultHierarchicalContext()).thenReturn(defaultHierarchicalContext);
viewModel = new GroupDialogViewModel(dialogService, bibDatabaseContext, preferencesService, null, null, new DummyFileUpdateMonitor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void setUp() {
}

@Test
public void testExecuteOnSuccessWithFixedType() {
public void executeOnSuccessWithFixedType() {
EntryType type = StandardEntryType.Article;
newEntryAction = new NewEntryAction(() -> libraryTab, type, dialogService, preferencesService, stateManager);
when(tabContainer.getLibraryTabs()).thenReturn(List.of(libraryTab));
Expand Down
Loading

0 comments on commit 936ab5f

Please sign in to comment.