66import  java .io .File ;
77import  java .io .IOException ;
88import  java .nio .file .Files ;
9+ import  java .nio .file .Path ;
910
1011import  static  org .junit .Assert .assertFalse ;
1112import  static  org .junit .Assert .assertTrue ;
1213
1314public  class  FilePathHelperTest  {
1415
15-     private  File  dir ;
16+     private  Path  dir ;
1617
1718    @ Before 
1819    public  void  setUp () throws  IOException  {
19-         dir  = Files .createTempDirectory ("dir1" ). toFile () ;
20+         dir  = Files .createTempDirectory ("dir1" );
2021    }
2122
2223    @ Test 
@@ -31,24 +32,24 @@ public void testIsValidDirectoryPathWithNullString() {
3132
3233    @ Test 
3334    public  void  testIsValidDirectoryPathWithValidPath () {
34-         assertTrue (FilePathUtils .isValidDirectoryPath (dir .getAbsolutePath ()));
35+         assertTrue (FilePathUtils .isValidDirectoryPath (dir .toAbsolutePath (). toString ()));
3536    }
3637
3738    @ Test 
3839    public  void  testIsValidDirectoryPathWithDeepValidDirectory () throws  IOException  {
39-         final  File  subDir  = Files .createDirectory (dir .toPath (). resolve ("subdir" )).toFile ();
40+         final  File  subDir  = Files .createDirectory (dir .resolve ("subdir" )).toFile ();
4041        assertTrue (FilePathUtils .isValidDirectoryPath (subDir .getAbsolutePath ()));
4142    }
4243
4344    @ Test 
4445    public  void  testIsValidDirectoryPathWithNotExistDirectory () {
45-         assertFalse (FilePathUtils .isValidDirectoryPath (dir .toPath (). resolve ("not-exists-subdir" ).
46-                  toFile ().getAbsolutePath ()));
46+         assertFalse (FilePathUtils .isValidDirectoryPath (dir .resolve ("not-exists-subdir" ).
47+             toFile ().getAbsolutePath ()));
4748    }
4849
4950    @ Test 
5051    public  void  testIsValidDirectoryPathWithFile () throws  IOException  {
51-         final  File  tempFile  = Files .createFile (dir .toPath (). resolve ("simple_file" )).toFile ();
52+         final  File  tempFile  = Files .createFile (dir .resolve ("simple_file" )).toFile ();
5253        assertFalse (FilePathUtils .isValidDirectoryPath (tempFile .getAbsolutePath ()));
5354    }
5455
0 commit comments