PathNamingServiceImpl implements PathNamingService { public Path buildTargetPath(Path originalPath, String targetFileName) { final org.uberfire.java.nio.file.Path _originalPath = Paths.convert(originalPath); String extension = ""; if (!Files.isDirectory(_originalPath)) { extension = getExtension(originalPath.getFileName()); } return Paths.convert(_originalPath.resolveSibling(targetFileName + extension)); }  Path buildTargetPath(Path originalPath,
                                String targetFileName); Path buildTargetPath(Path originalPath,
                                Path targetParentDirectory,
                                String targetFileName); String getExtension(final String fileName); Iterable<ResourceTypeDefinition> getResourceTypeDefinitions();  }
@Test public void buildTargetPathForFolderInAnotherDirectoryTest() { Path originalPath = createFolder("parent/folder"); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-folder"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName, targetPath.toURI()); }
@Test public void buildTargetPathForFileInAnotherDirectoryTest() { String extension = ".txt"; Path originalPath = createFile("parent/file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }
@Test public void buildTargetPathForResourceTypeFileInAnotherDirectoryTest() { String extension = ".resource.xml.txt"; Path originalPath = createFile("parent/resource-file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-resource-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }