Search in sources :

Example 46 with IsText

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

the class TextOfDateTimeTest method zonedDateTimeFormattedAsIsoDateTime.

@Test
void zonedDateTimeFormattedAsIsoDateTime() {
    final ZonedDateTime date = ZonedDateTime.of(2017, 12, 13, 14, 15, 16, 17, ZoneId.of("Europe/Berlin"));
    new Assertion<>("Must format a ZonedDateTime with default/ISO format.", new TextOfDateTime(date), new IsText("2017-12-13T14:15:16.000000017+01:00")).affirm();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 47 with IsText

use of org.llorllale.cactoos.matchers.IsText 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 48 with IsText

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

the class SortedTest method mustSortTextIterableAsSetUsingCustomCOmparator.

@Test
@SuppressWarnings("unchecked")
void mustSortTextIterableAsSetUsingCustomCOmparator() {
    new Assertion<>("Must keep unique integer numbers sorted in descending order", new Sorted<Text>((first, second) -> {
        final String left = new UncheckedText(first).asString();
        final String right = new UncheckedText(second).asString();
        return left.compareTo(right);
    }, new TextOf("cd"), new TextOf("ab"), new TextOf("gh"), new TextOf("ef")), new IsIterableContainingInOrder<Text>(new ListOf<>(new IsText("ab"), new IsText("cd"), new IsText("ef"), new IsText("gh")))).affirm();
}
Also used : IsIterableContainingInOrder(org.hamcrest.collection.IsIterableContainingInOrder) UncheckedText(org.cactoos.text.UncheckedText) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) Test(org.junit.jupiter.api.Test)

Example 49 with IsText

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

the class AbbreviatedTest method abbreviatesTextThatChanges.

@Test
@SuppressWarnings("unchecked")
void abbreviatesTextThatChanges() {
    final AtomicInteger counter = new AtomicInteger(0);
    final Text txt = new TextOf(() -> {
        final String result;
        if (counter.getAndIncrement() == 0) {
            result = "The quick brown fox jumps";
        } else {
            result = "The lazy black dog";
        }
        return result;
    });
    new Assertion<>("Must abbreviate a text that changes", new Abbreviated(txt, 15), new AllOf<>(new IsText("The quick br..."), new IsText("The lazy bla..."))).affirm();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) AllOf(org.hamcrest.core.AllOf) Test(org.junit.jupiter.api.Test)

Example 50 with IsText

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

the class ComparableTextTest method equalsToItself.

@Test
public void equalsToItself() {
    final Text text = new TextOf("text");
    new Assertion<>("Does not equal to itself", text, new IsText(text)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.Test)

Aggregations

IsText (org.llorllale.cactoos.matchers.IsText)51 Test (org.junit.jupiter.api.Test)35 TextOf (org.cactoos.text.TextOf)22 Test (org.junit.Test)16 HasString (org.llorllale.cactoos.matchers.HasString)12 File (java.io.File)11 StringReader (java.io.StringReader)6 Text (org.cactoos.Text)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 LengthOf (org.cactoos.scalar.LengthOf)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 LocalDate (java.time.LocalDate)3 LocalDateTime (java.time.LocalDateTime)3 OffsetDateTime (java.time.OffsetDateTime)3 ZonedDateTime (java.time.ZonedDateTime)3 Calendar (java.util.Calendar)3 Path (java.nio.file.Path)2 BytesOf (org.cactoos.bytes.BytesOf)2 BufferedWriter (java.io.BufferedWriter)1