use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class TempFolderTest method createsDirectory.
@Test
void createsDirectory() throws Exception {
try (TempFolder folder = new TempFolder()) {
final File dir = folder.value().toFile();
new Assertion<>("must create new directory", dir.exists() && dir.isDirectory(), new IsTrue()).affirm();
}
}
use of org.llorllale.cactoos.matchers.IsTrue 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.llorllale.cactoos.matchers.IsTrue 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();
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class WriterAsOutputStreamTest method writesToFileAndRemovesIt.
@Test
public void writesToFileAndRemovesIt() throws Exception {
final Path temp = this.folder.newFile().toPath();
final String content = "Hello, товарищ! How are you?";
try (OutputStreamWriter writer = new OutputStreamWriter(Files.newOutputStream(temp.toAbsolutePath()), StandardCharsets.UTF_8)) {
new LengthOf(new TeeInput(new InputOf(content), new OutputTo(new WriterAsOutputStream(writer, StandardCharsets.UTF_8, // @checkstyle MagicNumber (1 line)
345)))).value();
}
Files.delete(temp);
new Assertion<>("file must not exist anymore", Files.exists(temp), new IsNot<>(new IsTrue())).affirm();
}
use of org.llorllale.cactoos.matchers.IsTrue in project cactoos by yegor256.
the class IteratorOfTest method nonEmptyIteratorDoesNotHaveNext.
@Test
void nonEmptyIteratorDoesNotHaveNext() {
final Iterator<Integer> iterator = new IteratorOf<>(1, 2, 3);
while (iterator.hasNext()) {
iterator.next();
}
new Assertion<>("Must create non empty iterator", iterator.hasNext(), new IsNot<>(new IsTrue())).affirm();
}
Aggregations