CommandDirectories { public Path resolveWithTargetDirectoryAndCreateParentDirectories(Path pathInSourceDirectory) throws CommandException { Path path = resolveWithTargetDirectory(pathInSourceDirectory); try { Files.createDirectories(path.toAbsolutePath().getParent()); } catch (IOException ioe) { throw new CommandException("Can't create target directory: " + path, ioe); } return path; } CommandDirectories(String sourceDirectoryPathString);  CommandDirectories(String sourceDirectoryPathString, String targetDirectoryPathString); Path resolveWithTargetDirectory(Path pathInSourceDirectory); Path resolveWithTargetDirectoryAndCreateParentDirectories(Path pathInSourceDirectory); Path relativizeWithSourceDirectory(Path path); Path relativizeWithTargetDirectory(Path path); Path relativizeWithUserDirectory(Path path); List<Path> listFilesWithExtensionInSourceDirectory(String... extensions); Path getSourceDirectoryPath(); Path getTargetDirectoryPath();  }
@Test public void testResolveWithTargetDirectoryAndCreateParentDirectories() throws Exception { Path fileInSourceDirectory = Paths.get(getInputResourcesTestDir().toString(), "sub/file1"); CommandDirectories instance = new CommandDirectories(getInputResourcesTestDir().toString(), getTargetTestDir().toString()); Path expResult = getBaseDir().toPath().relativize(Paths.get(getTargetTestDir().toString(), "sub/file1")); Path result = instance.resolveWithTargetDirectoryAndCreateParentDirectories(fileInSourceDirectory); assertEquals(expResult, result); Files.write(result, new byte[0]); checkExpectedGeneratedResources(); }