@Test public void shouldNotOperateOnDirectories() throws IOException { Path dir = Paths.get( "/some/path" ); onFile( operation, wrapped ).preVisitDirectory( dir, null ); verify( operation, never() ).accept( dir ); }
private void visitPath( Path transactionalLogsPath, Predicate<Path> exclude, ArchiveOutputStream stream ) throws IOException { Files.walkFileTree( transactionalLogsPath, onlyMatching( not( exclude ), throwExceptions( onDirectory( dir -> dumpDirectory( transactionalLogsPath, stream, dir ), onFile( file -> dumpFile( transactionalLogsPath, stream, file ), justContinue() ) ) ) ) ); }
@Test public void shouldOperateOnFiles() throws IOException { Path file = Paths.get( "/some/path" ); onFile( operation, wrapped ).visitFile( file, null ); verify( operation ).accept( file ); } }
@Parameterized.Parameters( name = "{0}" ) public static List<Object[]> formats() { return asList( new Object[]{"decorator", (Function<FileVisitor<Path>, FileVisitor<Path>>) FileVisitors.Decorator::new, false }, new Object[]{"onFile", (Function<FileVisitor<Path>, FileVisitor<Path>>) wrapped -> FileVisitors.onFile( noop(), wrapped ), false }, new Object[]{"onDirectory", (Function<FileVisitor<Path>, FileVisitor<Path>>) wrapped -> FileVisitors.onDirectory( noop(), wrapped ), false }, new Object[]{"throwExceptions", (Function<FileVisitor<Path>, FileVisitor<Path>>) FileVisitors::throwExceptions, true }, new Object[]{"onlyMatching", (Function<FileVisitor<Path>, FileVisitor<Path>>) wrapped -> FileVisitors.onlyMatching( Predicates.alwaysTrue(), wrapped ), false } ); }
private void visitPath( Path transactionalLogsPath, Predicate<Path> exclude, ArchiveOutputStream stream ) throws IOException { Files.walkFileTree( transactionalLogsPath, onlyMatching( not( exclude ), throwExceptions( onDirectory( dir -> dumpDirectory( transactionalLogsPath, stream, dir ), onFile( file -> dumpFile( transactionalLogsPath, stream, file ), justContinue() ) ) ) ) ); }