-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
237 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.jabref.logic.util; | ||
|
||
import org.jabref.logic.util.io.FileNameCleaner; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class FileNameCleanerTest { | ||
|
||
@Test | ||
void cleanFileName() { | ||
assertEquals("legalFilename.txt", FileNameCleaner.cleanFileName("legalFilename.txt")); | ||
assertEquals("illegalFilename______.txt", FileNameCleaner.cleanFileName("illegalFilename/?*<>|.txt")); | ||
assertEquals("illegalFileName_.txt", FileNameCleaner.cleanFileName("illegalFileName{.txt")); | ||
} | ||
|
||
@Test | ||
void cleanDirectoryName() { | ||
assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); | ||
assertEquals("subdir/legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir/legalFilename.txt")); | ||
assertEquals("illegalFilename/_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename/?*<>|.txt")); | ||
} | ||
|
||
@Test | ||
void cleanDirectoryNameForWindows() { | ||
assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); | ||
assertEquals("subdir\\legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir\\legalFilename.txt")); | ||
assertEquals("illegalFilename\\_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename\\?*<>|.txt")); | ||
} | ||
|
||
@Test | ||
void cleanCurlyBracesAsWell() { | ||
assertEquals("The Evolution of Sentiment_ Analysis_A Review of Research Topics, Venues, and Top Cited Papers.PDF", FileNameCleaner.cleanFileName("The Evolution of Sentiment} Analysis}A Review of Research Topics, Venues, and Top Cited Papers.PDF")); | ||
} | ||
} |
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,43 @@ | ||
package org.jabref.logic.util; | ||
|
||
import org.jabref.logic.util.io.FileNameCleaner; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class FileNameCleanerTest { | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"legalFilename.txt, legalFilename.txt", | ||
"illegalFilename______.txt, illegalFilename/?*<>|.txt", | ||
"illegalFileName_.txt, illegalFileName{.txt", | ||
"_The Evolution of Sentiment_ Analysis_.PDF, ?The Evolution of Sentiment} Analysis}.PDF", | ||
"'The Evolution of Sentiment_ Analysis_A Review of Research Topics, Venues, and Top Cited Papers.PDF', 'The Evolution of Sentiment} Analysis}A Review of Research Topics, Venues, and Top Cited Papers.PDF'" | ||
}) | ||
void cleanFileName(String expected, String input) { | ||
assertEquals(expected, FileNameCleaner.cleanFileName(input)); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"legalFilename.txt, legalFilename.txt", | ||
"subdir/legalFilename.txt, subdir/legalFilename.txt", | ||
"illegalFilename/_____.txt, illegalFilename/?*<>|.txt" | ||
}) | ||
void cleanDirectoryName(String expected, String input) { | ||
assertEquals(expected, FileNameCleaner.cleanDirectoryName(input)); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"legalFilename.txt, legalFilename.txt", | ||
"subdir\\legalFilename.txt, subdir\\legalFilename.txt", | ||
"illegalFilename\\_____.txt, illegalFilename\\?*<>|.txt" | ||
}) | ||
void cleanDirectoryNameForWindows(String expected, String input) { | ||
assertEquals(expected, FileNameCleaner.cleanDirectoryName(input)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/mappings/jabRef-FileNameCleanerTest.txt
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,14 @@ | ||
package cleanFileName() : void -> package cleanFileName(expected String, input String) : void | ||
line range:13-13==line range:21-21 | ||
line range:15-15==line range:21-21 | ||
line range:14-14==line range:21-21 | ||
package cleanCurlyBracesAsWell() : void -> package cleanFileName(expected String, input String) : void | ||
line range:34-34==line range:21-21 | ||
package cleanDirectoryName() : void -> package cleanDirectoryName(expected String, input String) : void | ||
line range:20-20==line range:31-31 | ||
line range:21-21==line range:31-31 | ||
line range:22-22==line range:31-31 | ||
package cleanDirectoryNameForWindows() : void -> package cleanDirectoryNameForWindows(expected String, input String) : void | ||
line range:27-27==line range:41-41 | ||
line range:28-28==line range:41-41 | ||
line range:29-29==line range:41-41 |