Skip to content

Commit

Permalink
Replace getPath by getName
Browse files Browse the repository at this point in the history
  • Loading branch information
quetin committed Jul 20, 2023
1 parent 669a453 commit ba44c13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void detectHeaderPresence(String header, File file) throws IOExcep
}

public static void detectFileName(File file) throws IllegalFileFormatException {
String filename = file.getPath();
String filename = file.getName();
filename = filename.replace("\\", "/");
assert filename != null;
if(!filename.matches("(\\w+_\\w+_)+(\\d{4}-\\d{2}-\\d{2})+(_FORCE)?+(_force)?+(.tsv)$")){
Expand All @@ -83,9 +83,9 @@ public static void detectFileName(File file) throws IllegalFileFormatException {
* @throws IOException Impossible de lire le fichier
*/
public static void verifyFile(File file, String header) throws IllegalFileFormatException, IOException {
detectFileName(file);
isFileWithTSVExtension(file);
detectTabulations(file);
detectHeaderPresence(header, file);
detectFileName(file);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void detectFileName() throws IllegalFileFormatException {
this.file2 = new File("test_test_test_test1_1234-12-12_FORCE.tsv");
CheckFiles.detectFileName(file2);

for(String name : Lists.newArrayList("123", "test_1234-12-12.tsv", "test_test_134-12-12.tsv", "test_test_1344-12-12.tsvf", "test_test_1344-12-123.tsv","test_test_test_test_1234/12/12.tsv")) {
for(String name : Lists.newArrayList("123", "test_1234-12-12.tsv", "test_test_134-12-12.tsv", "test_test_1344-12-12.tsvf", "test_test_1344-12-123.tsv")) {
this.file3 = new File(name);
IllegalFileFormatException erreur2 = Assertions.assertThrows(IllegalFileFormatException.class, () -> CheckFiles.detectFileName(file3));
Assertions.assertEquals("Le nom du fichier " + name + " n'est pas correct", erreur2.getMessage());
Expand Down

0 comments on commit ba44c13

Please sign in to comment.