use of org.cactoos.proc.ProcOf in project cactoos by yegor256.
the class TempFolderTest method deletesNonEmptyDirectory.
@Test
void deletesNonEmptyDirectory() throws Exception {
final TempFolder temp = new TempFolder();
final Path root = temp.value();
new ForEach<>(new ProcOf<String>(name -> {
final Path dir = Files.createDirectories(new File(root.toFile(), name).toPath());
new ForEach<>(new ProcOf<String>(filename -> {
new TempFile(() -> dir, filename, "").value();
})).exec(new IterableOf<>("file1.txt", "file2.txt", "file3.txt"));
})).exec(new IterableOf<>("a", "b", "c", "d", "e"));
temp.close();
new Assertion<>("Can't delete not empty folder while closing", temp.value().toFile().exists(), new IsNot<>(new IsTrue())).affirm();
}
use of org.cactoos.proc.ProcOf in project cactoos by yegor256.
the class TempFolderTest method createDirectoryWithDirectoriesAndFiles.
@Test
void createDirectoryWithDirectoriesAndFiles() throws Exception {
final TempFolder temp = new TempFolder();
final Path root = temp.value();
new ForEach<>(new ProcOf<String>(name -> {
final Path dir = Files.createDirectories(new File(root.toFile(), name).toPath());
new ForEach<>(new ProcOf<String>(filename -> {
new TempFile(() -> dir, filename, "").value();
})).exec(new IterableOf<>("1.txt", "2.txt", "3.txt"));
})).exec(new IterableOf<>("1", "2", "3", "4", "5"));
new Assertion<>("Directory contains files and sub directories", temp.value().toFile().exists(), new IsTrue()).affirm();
temp.close();
}