### Question:
StoreFiles { public void moveTo( File source, File target, LogFiles logFiles ) throws IOException { fs.mkdirs( logFiles.logFilesDirectory() ); for ( File candidate : fs.listFiles( source, fileFilter ) ) { File destination = logFiles.isLogFile( candidate) ? logFiles.logFilesDirectory() : target; fs.moveToDirectory( candidate, destination ); } Iterable<FileHandle> fileHandles = acceptedPageCachedFiles( source )::iterator; for ( FileHandle fh : fileHandles ) { fh.rename( new File( target, fh.getRelativeFile().getPath() ), StandardCopyOption.REPLACE_EXISTING ); } } 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 mustMoveFilesToTargetDirectory() throws Exception { File base = getBaseDir(); File src = new File( base, "src" ); File tgt = new File( base, "tgt" ); File a = new File( src, "a" ); createOnFileSystem( a ); createOnFileSystem( new File( tgt, ".fs-ignore" ) ); storeFiles.moveTo( src, tgt, logFiles ); assertFalse( fs.fileExists( a ) ); assertTrue( fs.fileExists( new File( tgt, "a" ) ) ); }
@Test public void movedFilesMustRetainTheirRelativePaths() throws Exception { File base = getBaseDir(); File src = new File( base, "src" ); File tgt = new File( base, "tgt" ); File dir = new File( src, "dir" ); File a = new File( dir, "a" ); createOnFileSystem( a ); createOnFileSystem( new File( tgt, ".fs-ignore" ) ); storeFiles.moveTo( src, tgt, logFiles ); assertFalse( fs.fileExists( a ) ); assertTrue( fs.fileExists( new File( new File( tgt, "dir" ), "a" ) ) ); }
@Test public void moveMustIgnoreFilesFilteredOut() throws Exception { File base = getBaseDir(); File src = new File( base, "src" ); File a = new File( src, "a" ); File ignore = new File( src, "ignore" ); File c = new File( ignore, "c" ); File tgt = new File( base, "tgt" ); createOnFileSystem( a ); createOnFileSystem( c ); createOnFileSystem( new File( tgt, ".fs-ignore" ) ); FilenameFilter filter = ( directory, name ) -> !name.startsWith( "ignore" ); storeFiles = new StoreFiles( fs, pageCache, filter ); storeFiles.moveTo( src, tgt, logFiles ); assertFalse( fs.fileExists( a ) ); assertTrue( fs.fileExists( c ) ); assertTrue( fs.fileExists( new File( tgt, "a" ) ) ); }