DocumentFileUtils { public void createFile(Element element, Path path) { createFile(element, path, false); } 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 createFile() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test.xml"); DocumentFileUtils.INSTANCE.createFile(sampleElement(), path); assertTrue(path.toFile().exists()); assertNotNull(readFileToString(path.toFile(), Charset.defaultCharset())); }
@Test void createFileNonexistingPath() { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test", "test.xml"); assertThrows(DocumentFileUtilsException.class, () -> DocumentFileUtils.INSTANCE.createFile(sampleElement(), path)); }
@Test void createFileWithNamespace() throws IOException { Path path = Paths.get(rootProjectDir.getRoot().toPath().toString(), "test.xml"); DocumentFileUtils.INSTANCE.createFile(sampleElement(), path, true); assertTrue(path.toFile().exists()); String content = readFileToString(path.toFile(), Charset.defaultCharset()); assertNotNull(content); assertTrue(content.contains("xmlns:l7")); assertTrue(content.contains("http: }