Search in sources :

Example 11 with IsText

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

the class TextOfDateTimeTest method offsetDateTimeFormattedWithFormatString.

@Test
void offsetDateTimeFormattedWithFormatString() {
    final OffsetDateTime date = OffsetDateTime.of(2017, 12, 13, 14, 15, 16, 17, ZoneOffset.ofHours(1));
    new Assertion<>("Must format a OffsetDateTime with format.", new TextOfDateTime("yyyy-MM-dd HH:mm:ss", date), new IsText("2017-12-13 14:15:16")).affirm();
}
Also used : OffsetDateTime(java.time.OffsetDateTime) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 12 with IsText

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

the class TextOfDateTimeTest method zonedDateTimeFormattedWithFormatString.

@Test
void zonedDateTimeFormattedWithFormatString() {
    final ZonedDateTime date = ZonedDateTime.of(2017, 12, 13, 14, 15, 16, 17, ZoneId.of("Europe/Berlin"));
    new Assertion<>("Must format a ZonedDateTime with format.", new TextOfDateTime("yyyy-MM-dd HH:mm:ss", date), new IsText("2017-12-13 14:15:16")).affirm();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 13 with IsText

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

the class ComparableTextTest method equalsOfDifferentText.

@Test
public void equalsOfDifferentText() {
    final Text text = new ComparableText(new TextOf("my value"));
    new Assertion<>("Is equal to the completely different object", text, new IsNot<>(new IsEqual<>("The string is ignored"))).affirm();
    new Assertion<>("Is equal to the completely different text", text, new IsNot<>(new IsText("The text is ignored"))).affirm();
    new Assertion<>("Is equal to the different ComparableText", text, new IsNot<>(new IsEqual<>(new ComparableText(new TextOf("A different text"))))).affirm();
    new Assertion<>("The string is equal to the different ComparableText", text, new IsNot<>(new IsText(new ComparableText(new TextOf("A different value"))))).affirm();
}
Also used : IsNot(org.hamcrest.core.IsNot) IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.Test)

Example 14 with IsText

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

the class ReaderOfTest method readsFile.

@Test
public void readsFile() throws Exception {
    final String message = "file on äÄ üÜ öÖ ß жш";
    final File input = this.folder.newFile();
    Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("Must read from file", new TextOf(new ReaderOf(input)), new IsText(message)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Example 15 with IsText

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

the class ReaderOfTest method readsUri.

@Test
public void readsUri() throws Exception {
    final String message = "URI on äÄ üÜ öÖ ß жш";
    final File input = this.folder.newFile();
    Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("Must read from uri", new TextOf(new ReaderOf(input.toURI())), new IsText(message)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) File(java.io.File) 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