### Question:
StoreFiles { public void delete( File storeDir, LogFiles logFiles ) throws IOException { File[] files = fs.listFiles( storeDir, fileFilter ); if ( files != null ) { for ( File file : files ) { fs.deleteRecursively( file ); } } File[] txLogs = fs.listFiles( logFiles.logFilesDirectory() ); if ( txLogs != null ) { for ( File txLog : txLogs ) { fs.deleteFile( txLog ); } } Iterable<FileHandle> iterator = acceptedPageCachedFiles( storeDir )::iterator; for ( FileHandle fh : iterator ) { fh.delete(); } } StoreFiles( FileSystemAbstraction fs, PageCache pageCache );  StoreFiles( FileSystemAbstraction fs, PageCache pageCache, FilenameFilter fileFilter ); void delete( File storeDir, LogFiles logFiles ); void moveTo( File source, File target, LogFiles logFiles ); boolean isEmpty( File storeDir, Collection<File> filesToLookFor ); StoreId readStoreId( DatabaseLayout databaseLayout );  }### Answer:
@Test public void deleteMustRecursivelyRemoveFilesInGivenDirectory() throws Exception { File dir = getBaseDir(); File a = new File( dir, "a" ); File b = new File( dir, "b" ); createOnFileSystem( a ); assertTrue( fs.fileExists( a ) ); assertFalse( fs.fileExists( b ) ); storeFiles.delete( dir, logFiles ); assertFalse( fs.fileExists( a ) ); }
@Test public void deleteMustNotDeleteIgnoredFiles() throws Exception { File dir = getBaseDir(); File a = new File( dir, "a" ); File c = new File( dir, "c" ); createOnFileSystem( a ); createOnFileSystem( c ); FilenameFilter filter = ( directory, name ) -> !name.equals( "c" ) && !name.equals( "d" ); storeFiles = new StoreFiles( fs, pageCache, filter ); storeFiles.delete( dir, logFiles ); assertFalse( fs.fileExists( a ) ); assertTrue( fs.fileExists( c ) ); }
@Test public void deleteMustNotDeleteFilesInIgnoredDirectories() throws Exception { File dir = getBaseDir(); File ignore = new File( dir, "ignore" ); File a = new File( dir, "a" ); File c = new File( ignore, "c" ); createOnFileSystem( a ); createOnFileSystem( c ); FilenameFilter filter = ( directory, name ) -> !name.startsWith( "ignore" ); storeFiles = new StoreFiles( fs, pageCache, filter ); storeFiles.delete( dir, logFiles ); assertFalse( fs.fileExists( a ) ); assertTrue( fs.fileExists( c ) ); }
@Test public void deleteMustSilentlyIgnoreMissingDirectories() throws Exception { File dir = getBaseDir(); File sub = new File( dir, "sub" ); storeFiles.delete( sub, logFiles ); }