Search in sources :

Example 6 with HasValue

use of org.llorllale.cactoos.matchers.HasValue in project cactoos by yegor256.

the class FlattenedTest method flattens.

@Test
void flattens() {
    final Text txt = new TextOf("txt");
    final Scalar<Text> sclr = new Constant<>(txt);
    new Assertion<>("must flatten", new Flattened<>(new ScalarOf<>(() -> sclr)), new HasValue<>(new IsText(txt))).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) HasValue(org.llorllale.cactoos.matchers.HasValue) Test(org.junit.jupiter.api.Test)

Example 7 with HasValue

use of org.llorllale.cactoos.matchers.HasValue in project cactoos by yegor256.

the class FirstOfTest method returnsMatchingValue.

@Test
void returnsMatchingValue() {
    final int value = 1;
    new Assertion<>("Must return the only matching element", new FirstOf<>(i -> i >= value, new IterableOfInts(0, value), () -> -1), new HasValue<>(value)).affirm();
}
Also used : IterableOfInts(org.cactoos.iterable.IterableOfInts) HasValue(org.llorllale.cactoos.matchers.HasValue) Test(org.junit.jupiter.api.Test)

Example 8 with HasValue

use of org.llorllale.cactoos.matchers.HasValue in project cactoos by yegor256.

the class BinaryTest method conditionFalse.

@Test
public void conditionFalse() {
    final int expected = 0;
    final AtomicInteger counter = new AtomicInteger(0);
    final Binary binary = new Binary(new False(), counter::incrementAndGet);
    new Assertion<>("Binary has to return false", binary, new HasValue<>(false)).affirm();
    new Assertion<>("Binary must not to invoke increment method", counter.get(), new IsEqual<>(expected)).affirm();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HasValue(org.llorllale.cactoos.matchers.HasValue) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.Test)

Aggregations

HasValue (org.llorllale.cactoos.matchers.HasValue)8 Test (org.junit.jupiter.api.Test)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 IterableOfInts (org.cactoos.iterable.IterableOfInts)2 TextOf (org.cactoos.text.TextOf)2 IsEqual (org.hamcrest.core.IsEqual)2 Test (org.junit.Test)2 Text (org.cactoos.Text)1 LengthOf (org.cactoos.scalar.LengthOf)1 IsText (org.llorllale.cactoos.matchers.IsText)1