@Test public void base_folder1_files_convert_to_target_files() { File originBase = new File("./parent1/"); File targetBase = new File("./parent2/"); File sourceFile1 = new File(originBase,"test1.puml"); File sourcefile2 = new File(originBase,"test2.puml"); File sourceFile3 = new File(originBase,"sub1/test3.puml"); CopySupport support = new CopySupport(originBase, targetBase); List<File> result = support.createTargetFiles(Arrays.asList(sourceFile1,sourcefile2,sourceFile3)); File expectedTargetFile1= new File(targetBase,"test1.puml"); File expectedTargetFile2 = new File(targetBase,"test2.puml"); File expectedTargetFile3 = new File(targetBase,"sub1/test3.puml"); Iterator<File> it = result.iterator(); assertEquals(expectedTargetFile1.toString(),it.next().toString()); assertEquals(expectedTargetFile2.toString(),it.next().toString()); assertEquals(expectedTargetFile3.toString(),it.next().toString()); }
protected List<File> createTargetFiles(List<File> files){ List<File> result = new ArrayList<File>(); Path targetParentPath = newBaseFolder.toPath(); Path parentPath = oldBaseFolder.toPath(); for (File file: files) { Path path = file.toPath(); Path relativePath = parentPath.relativize(path); Path targetPath = targetParentPath.resolve(relativePath); result.add(targetPath.toFile()); } return result; }
CopySupport { protected List<File> createTargetFiles(List<File> files){ List<File> result = new ArrayList<File>(); Path targetParentPath = newBaseFolder.toPath(); Path parentPath = oldBaseFolder.toPath(); for (File file: files) { Path path = file.toPath(); Path relativePath = parentPath.relativize(path); Path targetPath = targetParentPath.resolve(relativePath); result.add(targetPath.toFile()); } return result; } }
CopySupport { protected List<File> createTargetFiles(List<File> files){ List<File> result = new ArrayList<File>(); Path targetParentPath = newBaseFolder.toPath(); Path parentPath = oldBaseFolder.toPath(); for (File file: files) { Path path = file.toPath(); Path relativePath = parentPath.relativize(path); Path targetPath = targetParentPath.resolve(relativePath); result.add(targetPath.toFile()); } return result; } CopySupport(File oldBaseFolder, File newBaseFolder); }
CopySupport { protected List<File> createTargetFiles(List<File> files){ List<File> result = new ArrayList<File>(); Path targetParentPath = newBaseFolder.toPath(); Path parentPath = oldBaseFolder.toPath(); for (File file: files) { Path path = file.toPath(); Path relativePath = parentPath.relativize(path); Path targetPath = targetParentPath.resolve(relativePath); result.add(targetPath.toFile()); } return result; } CopySupport(File oldBaseFolder, File newBaseFolder); void copyFilesToNewBase(List<File> sourceFiles); }
CopySupport { protected List<File> createTargetFiles(List<File> files){ List<File> result = new ArrayList<File>(); Path targetParentPath = newBaseFolder.toPath(); Path parentPath = oldBaseFolder.toPath(); for (File file: files) { Path path = file.toPath(); Path relativePath = parentPath.relativize(path); Path targetPath = targetParentPath.resolve(relativePath); result.add(targetPath.toFile()); } return result; } CopySupport(File oldBaseFolder, File newBaseFolder); void copyFilesToNewBase(List<File> sourceFiles);  }