Search in sources :

Example 1 with Randomized

use of org.cactoos.text.Randomized in project cactoos by yegor256.

the class AppendToTest method failsIfFileDoesNotExist.

/**
 * Ensures that AppendTo is failing on a negative predicate result.
 */
@Test
public void failsIfFileDoesNotExist() throws Exception {
    final File source = new File(new Randomized('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h').asString());
    new Assertion<>("Can't throw exception with proper message", () -> new AppendTo(source).stream(), new Throws<>(source.getPath(), NoSuchFileException.class)).affirm();
}
Also used : Randomized(org.cactoos.text.Randomized) Throws(org.llorllale.cactoos.matchers.Throws) File(java.io.File) Test(org.junit.Test)

Example 2 with Randomized

use of org.cactoos.text.Randomized in project cactoos by yegor256.

the class ImmutableTest method decoratesToString.

@Test
public void decoratesToString() throws Exception {
    final String string = new Randomized().asString();
    final Iterator<Object> iterator = new Iterator<Object>() {

        public Object next() {
            return new Object();
        }

        public boolean hasNext() {
            return false;
        }

        public String toString() {
            return string;
        }
    };
    final Iterator<Object> immutable = new Immutable<>(iterator);
    new Assertion<>("must delegate toString to decorated iterator", new TextOf(immutable.toString()), new IsText(iterator.toString())).affirm();
}
Also used : Randomized(org.cactoos.text.Randomized) Iterator(java.util.Iterator) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test)

Aggregations

Randomized (org.cactoos.text.Randomized)2 Test (org.junit.Test)2 File (java.io.File)1 Iterator (java.util.Iterator)1 TextOf (org.cactoos.text.TextOf)1 IsText (org.llorllale.cactoos.matchers.IsText)1 Throws (org.llorllale.cactoos.matchers.Throws)1