Search in sources :

Example 11 with UncheckedText

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

the class LoggingInputStream method mark.

@Override
public void mark(final int limit) {
    this.origin.mark(limit);
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("Marked position %d from %s.", limit, this.source)).asString());
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 12 with UncheckedText

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

the class LoggingInputStream method skip.

@Override
public long skip(final long num) throws IOException {
    final long skipped = this.origin.skip(num);
    this.logger.log(this.level.value(), new UncheckedText(new FormattedText("Skipped %d byte(s) from %s.", skipped, this.source)).asString());
    return skipped;
}
Also used : UncheckedText(org.cactoos.text.UncheckedText) FormattedText(org.cactoos.text.FormattedText)

Example 13 with UncheckedText

use of org.cactoos.text.UncheckedText 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)

Aggregations

UncheckedText (org.cactoos.text.UncheckedText)13 FormattedText (org.cactoos.text.FormattedText)12 Level (java.util.logging.Level)3 Instant (java.time.Instant)2 TextOf (org.cactoos.text.TextOf)1 IsIterableContainingInOrder (org.hamcrest.collection.IsIterableContainingInOrder)1 Test (org.junit.jupiter.api.Test)1 IsText (org.llorllale.cactoos.matchers.IsText)1