Skip to content

Commit e55ed6a

Browse files
committed
fixed that suggestedFileNames were assumed Optional in test, and runaway format case
1 parent df8c706 commit e55ed6a

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

jablib/src/test/java/org/jabref/logic/externalfiles/LinkedFileHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ void getSuggestedFileName(String expectedFileName, String link, String extension
8181
final LinkedFileHandler linkedFileHandler = new LinkedFileHandler(linkedFile, entry, databaseContext, filePreferences);
8282

8383
if (extension.isEmpty()) {
84-
assertEquals(expectedFileName, linkedFileHandler.getSuggestedFileName(extension).orElse("file" + "." + extension));
84+
assertEquals(expectedFileName, linkedFileHandler.getSuggestedFileName(extension));
8585
} else {
86-
assertEquals(expectedFileName, linkedFileHandler.getSuggestedFileName().orElse("file"));
86+
assertEquals(expectedFileName, linkedFileHandler.getSuggestedFileName());
8787
}
8888
}
8989

jablib/src/test/java/org/jabref/logic/util/io/FileUtilTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,25 @@ void getFileNameWithMultipleDotsString() {
229229
}
230230

231231
@ParameterizedTest
232+
// formatter:off
232233
@CsvSource(textBlock = """
233-
test.file, www.example.com/test.file
234-
test.file, http://www.example.com/test.file
235-
test.file, https://www.example.com/test.file
236-
test.file, www.example.com/path/to/test.file
237-
test.file, http://www.example.com/path/to/test.file
238-
test.file, https://www.example.com/path/to/test.file
239-
test.file, https://www.example.com/not\\a\\windows\\path/test.file
240-
test.file, https://www.example.com////test.file
241-
blank, https://www.example.com/path/to/blank
242-
blank, https://www.example.com/not\\a\\windows\\path/blank
243-
not\\a\\windows.file, https://www.example.com/path/to/not\\a\\windows.file
244-
test.file, https://www.example.com/path/to/file.pdf?field=value
245-
test.file, https://www.example.com/path/to/file.pdf?a=1&b=2
246-
test.file, https://www.example.com/path/to/file.pdf?search=for+a+file
247-
blank, https://www.example.com/path/to/blank?search=for+a+file
234+
test.file, www.example.com/test.file
235+
test.file, http://www.example.com/test.file
236+
test.file, https://www.example.com/test.file
237+
test.file, www.example.com/path/to/test.file
238+
test.file, http://www.example.com/path/to/test.file
239+
test.file, https://www.example.com/path/to/test.file
240+
test.file, https://www.example.com/not\\a\\windows\\path/test.file
241+
test.file, https://www.example.com////test.file
242+
blank, https://www.example.com/path/to/blank
243+
blank, https://www.example.com/not\\a\\windows\\path/blank
244+
not\\a\\windows.file, https://www.example.com/path/to/not\\a\\windows.file
245+
test.file, https://www.example.com/path/to/file.pdf?field=value
246+
test.file, https://www.example.com/path/to/file.pdf?a=1&b=2
247+
test.file, https://www.example.com/path/to/file.pdf?search=for+a+file
248+
blank, https://www.example.com/path/to/blank?search=for+a+file
248249
""")
250+
// formatter:on
249251
void getFileNameFromUrlsCorrectly(String file, String url) {
250252
assertEquals(file, FileUtil.getFileNameFromUrl(url).orElse("file.pdf"), "from '" + url + "'");
251253
}

0 commit comments

Comments
 (0)