Search in sources :

Example 1 with TextHasString

use of org.cactoos.matchers.TextHasString in project cactoos by yegor256.

the class WriterAsOutputStreamTest method writesLargeContentToFile.

@Test
public void writesLargeContentToFile() throws IOException {
    final Path temp = Files.createTempFile("cactoos-1", "txt-1");
    MatcherAssert.assertThat("Can't copy Input to Output and return Input", new TextOf(new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new OutputTo(new WriterAsOutputStream(new OutputStreamWriter(new FileOutputStream(temp.toFile()), StandardCharsets.UTF_8), StandardCharsets.UTF_8, // @checkstyle MagicNumber (1 line)
    345)))), new TextHasString(new MatcherOf<>(str -> {
        return new TextOf(temp).asString().equals(str);
    })));
}
Also used : Path(java.nio.file.Path) FileOutputStream(java.io.FileOutputStream) TextHasString(org.cactoos.matchers.TextHasString) TextOf(org.cactoos.text.TextOf) OutputStreamWriter(java.io.OutputStreamWriter) MatcherOf(org.cactoos.matchers.MatcherOf) Test(org.junit.Test)

Example 2 with TextHasString

use of org.cactoos.matchers.TextHasString in project cactoos by yegor256.

the class WriterAsOutputTest method writesLargeContentToFile.

@Test
public void writesLargeContentToFile() throws IOException {
    final Path temp = Files.createTempFile("cactoos-1", "txt-1");
    MatcherAssert.assertThat("Can't copy Input to Output and return Input", new TextOf(new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new WriterAsOutput(new OutputStreamWriter(new FileOutputStream(temp.toFile()), StandardCharsets.UTF_8)))), new TextHasString(new MatcherOf<>(str -> {
        return new TextOf(temp).asString().equals(str);
    })));
}
Also used : Path(java.nio.file.Path) FileOutputStream(java.io.FileOutputStream) TextHasString(org.cactoos.matchers.TextHasString) TextOf(org.cactoos.text.TextOf) OutputStreamWriter(java.io.OutputStreamWriter) MatcherOf(org.cactoos.matchers.MatcherOf) Test(org.junit.Test)

Example 3 with TextHasString

use of org.cactoos.matchers.TextHasString in project cactoos by yegor256.

the class AbbreviatedTextTest method abbreviatesTextWithSameLength.

@Test
public void abbreviatesTextWithSameLength() {
    final String msg = "elegant objects";
    MatcherAssert.assertThat("Can't abbreviate a text with same length", // @checkstyle MagicNumber (1 line)
    new AbbreviatedText(msg, 15), new TextHasString(msg));
}
Also used : TextHasString(org.cactoos.matchers.TextHasString) TextHasString(org.cactoos.matchers.TextHasString) Test(org.junit.Test)

Example 4 with TextHasString

use of org.cactoos.matchers.TextHasString in project cactoos by yegor256.

the class AbbreviatedTextTest method abbreviatesAnEmptyText.

@Test
public void abbreviatesAnEmptyText() {
    final String msg = "";
    MatcherAssert.assertThat("Can't abbreviate an msg text", // @checkstyle MagicNumber (1 line)
    new AbbreviatedText(msg, 8), new TextHasString(msg));
}
Also used : TextHasString(org.cactoos.matchers.TextHasString) TextHasString(org.cactoos.matchers.TextHasString) Test(org.junit.Test)

Example 5 with TextHasString

use of org.cactoos.matchers.TextHasString in project cactoos by yegor256.

the class AbbreviatedTextTest method abbreviatesTextTwoCharsBigger.

@Test
public void abbreviatesTextTwoCharsBigger() {
    final String msg = "hi everybody!";
    MatcherAssert.assertThat("Can't abbreviate a text two chars bigger", // @checkstyle MagicNumber (1 line)
    new AbbreviatedText(msg, 15), new TextHasString(msg));
}
Also used : TextHasString(org.cactoos.matchers.TextHasString) TextHasString(org.cactoos.matchers.TextHasString) Test(org.junit.Test)

Aggregations

TextHasString (org.cactoos.matchers.TextHasString)10 Test (org.junit.Test)10 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Path (java.nio.file.Path)2 MatcherOf (org.cactoos.matchers.MatcherOf)2 TextOf (org.cactoos.text.TextOf)2