Search in sources :

Example 1 with IsNot

use of org.hamcrest.core.IsNot in project cactoos by yegor256.

the class NoNullsTest method addsToEmptyCollection.

@Test
void addsToEmptyCollection() {
    final Collection<Integer> col = new NoNulls<>(new ListOf<>());
    col.add(1);
    new Assertion<>("Must not be empty after an item was added", col.isEmpty(), new IsNot<>(new IsTrue())).affirm();
}
Also used : IsNot(org.hamcrest.core.IsNot) IsTrue(org.llorllale.cactoos.matchers.IsTrue) Test(org.junit.jupiter.api.Test)

Example 2 with IsNot

use of org.hamcrest.core.IsNot in project cactoos by yegor256.

the class ComparableTextTest method equalsOfDifferentText.

@Test
public void equalsOfDifferentText() {
    final Text text = new ComparableText(new TextOf("my value"));
    new Assertion<>("Is equal to the completely different object", text, new IsNot<>(new IsEqual<>("The string is ignored"))).affirm();
    new Assertion<>("Is equal to the completely different text", text, new IsNot<>(new IsText("The text is ignored"))).affirm();
    new Assertion<>("Is equal to the different ComparableText", text, new IsNot<>(new IsEqual<>(new ComparableText(new TextOf("A different text"))))).affirm();
    new Assertion<>("The string is equal to the different ComparableText", text, new IsNot<>(new IsText(new ComparableText(new TextOf("A different value"))))).affirm();
}
Also used : IsNot(org.hamcrest.core.IsNot) IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.Test)

Example 3 with IsNot

use of org.hamcrest.core.IsNot in project cactoos by yegor256.

the class NoNullsTest method retainsAll.

@Test
void retainsAll() {
    final Collection<Integer> col = new NoNulls<>(new ListOf<>(1, 2, 3));
    new Assertion<>("NoNulls#retainAll(...) must return false for the same elements", col.retainAll(new ListOf<>(1, 2, 3)), new IsNot<>(new IsTrue())).affirm();
}
Also used : IsNot(org.hamcrest.core.IsNot) IsTrue(org.llorllale.cactoos.matchers.IsTrue) Test(org.junit.jupiter.api.Test)

Example 4 with IsNot

use of org.hamcrest.core.IsNot 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();
}
Also used : Path(java.nio.file.Path) ProcOf(org.cactoos.proc.ProcOf) IsNot(org.hamcrest.core.IsNot) IsTrue(org.llorllale.cactoos.matchers.IsTrue) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with IsNot

use of org.hamcrest.core.IsNot 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();
}
Also used : Path(java.nio.file.Path) IsNot(org.hamcrest.core.IsNot) IsTrue(org.llorllale.cactoos.matchers.IsTrue) LengthOf(org.cactoos.scalar.LengthOf) OutputStreamWriter(java.io.OutputStreamWriter) Test(org.junit.Test)

Aggregations

IsNot (org.hamcrest.core.IsNot)6 IsTrue (org.llorllale.cactoos.matchers.IsTrue)5 Test (org.junit.jupiter.api.Test)4 Path (java.nio.file.Path)2 Test (org.junit.Test)2 File (java.io.File)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Text (org.cactoos.Text)1 ProcOf (org.cactoos.proc.ProcOf)1 LengthOf (org.cactoos.scalar.LengthOf)1 IsText (org.llorllale.cactoos.matchers.IsText)1