Search in sources :

Example 6 with IsText

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

the class TextOfTest method readsMultilineInputStreamWithCarriageReturn.

@Test
void readsMultilineInputStreamWithCarriageReturn() throws Exception {
    final String content = "line1-\rline2";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    new Assertion<>("Can't read multiline inputStream with carriage return", new TextOf(stream), new IsText(content)).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 7 with IsText

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

the class TextOfTest method readsFromInputStream.

@Test
void readsFromInputStream() throws Exception {
    final String content = "line1";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    new Assertion<>("Can't read inputStream", new TextOf(stream), new IsText(new String(content.getBytes(), StandardCharsets.UTF_8))).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 8 with IsText

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

the class TextOfDateTimeTest method localDateTimeFormattedWithFormatStringWithLocale.

@Test
void localDateTimeFormattedWithFormatStringWithLocale() {
    final LocalDateTime date = LocalDateTime.of(2017, 12, 13, 14, 15, 16, 17);
    new Assertion<>("Must format a LocalDateTime with format using locale.", new TextOfDateTime("yyyy MMM dd. HH.mm.ss", date, Locale.FRENCH), new IsText("2017 déc. 13. 14.15.16")).affirm();
}
Also used : LocalDateTime(java.time.LocalDateTime) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 9 with IsText

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

the class TextOfDateTimeTest method localDateTimeFormattedWithFormatString.

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

Example 10 with IsText

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

the class TextOfDateTimeTest method readsLocalDateFormattedWithFormatStringWithLocale.

@Test
void readsLocalDateFormattedWithFormatStringWithLocale() {
    final LocalDate date = LocalDate.of(2017, 12, 13);
    new Assertion<>("Must format a LocalDate with format using locale.", new TextOfDateTime("yyyy MMM dd. HH.mm.ss", date, Locale.FRENCH), new IsText("2017 déc. 13. 00.00.00")).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.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