Search in sources :

Example 36 with IsText

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

the class StickyTest method cachesResult.

@Test
void cachesResult() {
    final Text sticky = new Sticky(new Randomized());
    new Assertion<>("must be the same", sticky, new IsText(sticky)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) Text(org.cactoos.Text) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 37 with IsText

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

the class TextOfDateTimeTest method readsLocalDateFormattedWithFormatString.

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

Example 38 with IsText

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

the class TextOfDateTimeTest method readsLocalDateFormattedAsIsoDateTime.

@Test
void readsLocalDateFormattedAsIsoDateTime() throws IOException {
    final LocalDate date = LocalDate.of(2017, 12, 13);
    new Assertion<>("Must format a LocalDate with default/ISO format.", new TextOfDateTime(date), new IsText(MessageFormat.format("2017-12-13T00:00:00{0}", date.atTime(LocalTime.MIN).atZone(ZoneId.systemDefault()).getOffset().toString()))).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test)

Example 39 with IsText

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

the class TextOfDateTimeTest method localDateTimeFormattedAsIsoDateTime.

@Test
void localDateTimeFormattedAsIsoDateTime() {
    final LocalDateTime date = LocalDateTime.of(2017, 12, 13, 14, 15, 16, 17);
    new Assertion<>("Must format a LocalDateTime with default/ISO format.", new TextOfDateTime(date), new IsText(MessageFormat.format("2017-12-13T14:15:16.000000017{0}", date.atZone(ZoneId.systemDefault()).getOffset().toString()))).affirm();
}
Also used : LocalDateTime(java.time.LocalDateTime) IsText(org.llorllale.cactoos.matchers.IsText) Test(org.junit.jupiter.api.Test)

Example 40 with IsText

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

the class TextOfDateTimeTest method dateFormattedUsingIsoFormatter.

@Test
void dateFormattedUsingIsoFormatter() {
    final Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
    calendar.set(2017, Calendar.DECEMBER, 13, 14, 15, 16);
    calendar.set(Calendar.MILLISECOND, 17);
    final ZoneOffset offset = calendar.getTimeZone().toZoneId().getRules().getOffset(calendar.toInstant());
    new Assertion<>("Must format a java.util.Date with ISO format.", new TextOfDateTime(calendar.getTime()), new IsText("2017-12-13T14:15:16.017" + offset)).affirm();
}
Also used : Calendar(java.util.Calendar) IsText(org.llorllale.cactoos.matchers.IsText) ZoneOffset(java.time.ZoneOffset) 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