@@ -20,11 +20,13 @@ public List<FileEntity> getJavaTestFiles(String directoryPath, boolean recursive
2020 Files .walk (startDir , 1 )
2121 .filter (Files ::isRegularFile )
2222 .forEach (filePath -> {
23- String fileNameWithoutExtension = filePath .getFileName ().toString ().substring (0 ,filePath .getFileName ().toString ().lastIndexOf ("." ));
24- //test files should have 'test' as either a prefix or suffix
25- if (filePath .toString ().toLowerCase ().endsWith (".java" ) &&
26- (fileNameWithoutExtension .toLowerCase ().startsWith ("test" )) || fileNameWithoutExtension .toLowerCase ().endsWith ("test" )) {
27- files .add (new FileEntity (filePath ));
23+ if (filePath .getFileName ().toString ().lastIndexOf ("." )!=-1 ) {
24+ String fileNameWithoutExtension = filePath .getFileName ().toString ().substring (0 , filePath .getFileName ().toString ().lastIndexOf ("." ));
25+ //test files should have 'test' as either a prefix or suffix
26+ if (filePath .toString ().toLowerCase ().endsWith (".java" ) &&
27+ (fileNameWithoutExtension .toLowerCase ().startsWith ("test" ) || fileNameWithoutExtension .toLowerCase ().endsWith ("test" ))) {
28+ files .add (new FileEntity (filePath ));
29+ }
2830 }
2931 });
3032 }
@@ -68,11 +70,13 @@ public class FindJavaTestFilesVisitor extends SimpleFileVisitor<Path> {
6870 public FileVisitResult visitFile (Path file ,
6971 BasicFileAttributes attrs )
7072 throws IOException {
71- String fileNameWithoutExtension = file .getFileName ().toString ().substring (0 ,file .getFileName ().toString ().lastIndexOf ("." ));
72- //test files should have 'test' as either a prefix or suffix
73- if (file .toString ().toLowerCase ().endsWith (".java" ) &&
74- (fileNameWithoutExtension .toLowerCase ().startsWith ("test" )) || fileNameWithoutExtension .toLowerCase ().endsWith ("test" )) {
75- files .add (new FileEntity (file ));
73+ if (file .getFileName ().toString ().lastIndexOf ("." ) !=-1 ) {
74+ String fileNameWithoutExtension = file .getFileName ().toString ().substring (0 , file .getFileName ().toString ().lastIndexOf ("." ));
75+ //test files should have 'test' as either a prefix or suffix
76+ if (file .toString ().toLowerCase ().endsWith (".java" ) &&
77+ (fileNameWithoutExtension .toLowerCase ().startsWith ("test" ) || fileNameWithoutExtension .toLowerCase ().endsWith ("test" ))) {
78+ files .add (new FileEntity (file ));
79+ }
7680 }
7781 return FileVisitResult .CONTINUE ;
7882 }
0 commit comments