public static void run(Path source, Path target) throws IOException {

        final List<Path> existingPaths = collectExistingPaths(target);
        existingPaths.remove(target); // exclude the target, we don't want to remove it in following step
        deletePaths(existingPaths);
        copyFiles(source, target);
    }
@Test
    void run() throws IOException {
        FullDirSync.run(source, target);

        List<Path> afterSyncState = new ArrayList<>();

        Files.walkFileTree(target, new SimpleFileVisitor<>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                if(!target.equals(dir)) {
                    afterSyncState.add(dir);
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                afterSyncState.add(file);
                return super.visitFile(file, attrs);
            }
        });

        Assertions.assertThat(afterSyncState)
                .extracting(target::relativize)
                .extracting(Path::toString)
                .hasSize(4)
                .contains("a.txt", "b.txt", "subdir", "subdir/c.txt");

        Assertions.assertThat(afterSyncState)
                .filteredOn(Files::isDirectory)
                .allSatisfy(p -> {
                    final Set<PosixFilePermission> permission = Files.getPosixFilePermissions(p);
                    Assertions.assertThat(permission).containsExactlyInAnyOrderElementsOf(FullDirSync.DIRECTORY_PERMISSIONS);
                });

        Assertions.assertThat(afterSyncState)
                .filteredOn(Files::isRegularFile)
                .allSatisfy(p -> {
                    final Set<PosixFilePermission> permission = Files.getPosixFilePermissions(p);
                    Assertions.assertThat(permission).containsExactlyInAnyOrderElementsOf(FullDirSync.FILE_PERMISSIONS);
                });



    }