DocumentFileUtils { public synchronized void createFolder(Path folderPath) { if (!folderPath.toFile().exists()) { try { Files.createDirectory(folderPath); } catch (IOException e) { throw new DocumentFileUtilsException("Exception creating folder: " + folderPath, e); } } else if (!folderPath.toFile().isDirectory()) { throw new DocumentFileUtilsException("Wanted to create folder but found a file: " + folderPath); } } private  DocumentFileUtils(DocumentTools documentTools); void createFile(Element element, Path path); void createFile(Element element, Path path, boolean addNamespace); synchronized void createFolder(Path folderPath); synchronized void createFolders(Path folderPath); static final DocumentFileUtils INSTANCE; static final String BUNDLE_EXTENSION; static final String DELETE_BUNDLE_EXTENSION; static final String INSTALL_BUNDLE_EXTENSION; static final String PREFIX_ENVIRONMENT; static final String PREFIX_FULL; }
@Test void createFolder() { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test"); DocumentFileUtils.INSTANCE.createFolder(path); assertTrue(path.toFile().exists()); assertTrue(path.toFile().isDirectory()); }
@Test void createFolderWithInvalidPath() { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test", "test1"); assertThrows(DocumentFileUtilsException.class, () -> DocumentFileUtils.INSTANCE.createFolder(path)); }
@Test void createFolderWithFileSameName() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test.f"); Files.touch(path.toFile()); assertThrows(DocumentFileUtilsException.class, () -> DocumentFileUtils.INSTANCE.createFolder(path)); }