From 7f104c5d18be1d2959d15570c0e031123754df92 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Fri, 21 May 2021 21:30:42 +0200 Subject: [PATCH] rename chronoLocalDateTimeAssertion functions to new schema in api-fluent --- .../en_GB/chronoLocalDateExpectations.kt | 10 +- .../en_GB/chronoLocalDateTimeExpectations.kt | 176 ++++++++++++++++++ .../ChronoLocalDateTimeExpectationsSpec.kt | 20 +- .../ChronoLocalDateTimeExpectationsSpec.kt | 96 +++++----- ...noZonedDateTimeAsStringExpectationsSpec.kt | 130 ++++++------- 5 files changed, 304 insertions(+), 128 deletions(-) create mode 100644 apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateExpectations.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateExpectations.kt index 0bd2f67cd..3dcdf6404 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateExpectations.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateExpectations.kt @@ -25,7 +25,7 @@ fun Expect.toBeBefore(expected: ChronoLocalDate): Expec * is before the [expected] [java.time.LocalDate] given as [String]. * * @return an [Expect] for the subject of `this` expectation. - * @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd** + * @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd** * * @since 0.17.0 */ @@ -49,7 +49,7 @@ fun Expect.toBeBeforeOrTheSamePointInTimeAs(expected: C * is before or equal the [expected] [java.time.LocalDate] given as [String]. * * @return an [Expect] for the subject of `this` expectation. - * @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd** + * @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd** * * @since 0.17.0 */ @@ -73,7 +73,7 @@ fun Expect.toBeTheSamePointInTimeAs(expected: ChronoLoc * is equal to the [expected] [java.time.LocalDate] given as [String]. * * @return an [Expect] for the subject of `this` expectation. - * @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd** + * @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd** * * @since 0.17.0 */ @@ -96,7 +96,7 @@ fun Expect.toBeAfterOrTheSamePointInTimeAs(expected: Ch * is after or equal the [expected] [java.time.LocalDate] given as [String]. * * @return an [Expect] for the subject of `this` expectation. - * @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd** + * @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd** * * @since 0.17.0 */ @@ -120,7 +120,7 @@ fun Expect.toBeAfter(expected: ChronoLocalDate): Expect * is after the [expected] [java.time.LocalDate] given as [String]. * * @return an [Expect] for the subject of `this` expectation. - * @throws [IllegalArgumentException] in case [expected] is not in the form of **yyyy-mm-dd** + * @throws [java.time.DateTimeException] in case [expected] is not in the form of **yyyy-mm-dd** * * @since 0.17.0 */ diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt new file mode 100644 index 000000000..e04ffdae1 --- /dev/null +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/chronoLocalDateTimeExpectations.kt @@ -0,0 +1,176 @@ +@file:Suppress( + // TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed + "JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE" +) + +package ch.tutteli.atrium.api.fluent.en_GB + +import ch.tutteli.atrium.creating.Expect +import ch.tutteli.atrium.logic.* +import java.time.LocalDateTime +import java.time.chrono.ChronoLocalDate +import java.time.chrono.ChronoLocalDateTime + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [ChronoLocalDateTime]. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun > Expect.toBeBefore( + expected: ChronoLocalDateTime<*> +): Expect = _logicAppend { isBefore(expected) } + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format. + * The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. + * The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a + * date without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest: + * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds) + * yyyy-mm-ddThh:mm:ss + * yyyy-mm-ddThh:mm + * yyyy-mm-dd + * + * @return an [Expect] for the subject of `this` expectation. + * @throws [java.time.DateTimeException] in case an unsupported format is given. + * + * @since 0.17.0 + */ +fun > Expect.toBeBefore( + expected: String +): Expect = _logicAppend { isBefore(expected) } + + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before or equal the [expected] [ChronoLocalDateTime]. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun > Expect.toBeBeforeOrTheSamePointInTimeAs( + expected: ChronoLocalDateTime<*> +): Expect = _logicAppend { isBeforeOrEqual(expected) } + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format. + * The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. + * The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a + * date without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest: + * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds) + * yyyy-mm-ddThh:mm:ss + * yyyy-mm-ddThh:mm + * yyyy-mm-dd + * + * @return an [Expect] for the subject of `this` expectation. + * @throws [java.time.DateTimeException] in case an unsupported format is given. + * + * @since 0.17.0 + */ +fun > Expect.toBeBeforeOrTheSamePointInTimeAs( + expected: String +): Expect = _logicAppend { isBeforeOrEqual(expected) } + + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is equal to the [expected] [ChronoLocalDateTime]. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun > Expect.toBeTheSamePointInTimeAs( + expected: ChronoLocalDateTime<*> +): Expect = _logicAppend { isEqual(expected) } + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format. + * The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. + * The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date + * without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest: + * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds) + * yyyy-mm-ddThh:mm:ss + * yyyy-mm-ddThh:mm + * yyyy-mm-dd + * + * @return an [Expect] for the subject of `this` expectation. + * @throws [java.time.DateTimeException] in case an unsupported format is given. + * + * @since 0.17.0 + */ +fun > Expect.toBeTheSamePointInTimeAs( + expected: String +): Expect = _logicAppend { isEqual(expected) } + + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is after or equal the [expected] [ChronoLocalDateTime]. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun > Expect.toBeAfterOrTheSamePointInTimeAs( + expected: ChronoLocalDateTime<*> +): Expect = _logicAppend { isAfterOrEqual(expected) } + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format. + * The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. + * The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date + * without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest: + * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds) + * yyyy-mm-ddThh:mm:ss + * yyyy-mm-ddThh:mm + * yyyy-mm-dd + * + * @return an [Expect] for the subject of `this` expectation. + * @throws [java.time.DateTimeException] in case an unsupported format is given. + * + * @since 0.17.0 + */ +fun > Expect.toBeAfterOrTheSamePointInTimeAs( + expected: String +): Expect = _logicAppend { isAfterOrEqual(expected) } + + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is after the [expected] [ChronoLocalDateTime]. + * + * @return an [Expect] for the subject of `this` expectation. + * + * @since 0.17.0 + */ +fun > Expect.toBeAfter( + expected: ChronoLocalDateTime<*> +): Expect = _logicAppend { isAfter(expected) } + +/** + * Expects that the subject of `this` expectation (a [ChronoLocalDateTime]) + * is before the [expected] [LocalDateTime] given as [String] in (modified) ISO 8601 format. + * The string will be converted to a LocalDateTime according to ISO 8601 but with a slight deviation. + * The alternative notation (e.g. 20200401120001 instead of 2020-04-01T12:00:01) is not supported and we accept a date + * without time in which case 00:00:00 is used. Following the supported formats from the longest to the shortest: + * yyyy-mm-ddThh:mm:ss.sss (up to 9 digits for nanoseconds) + * yyyy-mm-ddThh:mm:ss + * yyyy-mm-ddThh:mm + * yyyy-mm-dd + * + * @return an [Expect] for the subject of `this` expectation. + * @throws [java.time.DateTimeException] in case an unsupported format is given. + * + * @since 0.17.0 + */ +fun > Expect.toBeAfter( + expected: String +): Expect = _logicAppend { isAfter(expected) } diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeExpectationsSpec.kt index 418ffd982..c3e7cec5a 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/ChronoLocalDateTimeExpectationsSpec.kt @@ -14,20 +14,20 @@ class ChronoLocalDateTimeExpectationsSpec : Spek({ include(ChronoLocalDateTimeAsStringSpec) }) { object ChronoLocalDateTimeSpec : ch.tutteli.atrium.specs.integration.ChronoLocalDateTimeExpectationsSpec( - fun1, ChronoLocalDateTime<*>>(Expect>::isBefore), - fun1, ChronoLocalDateTime<*>>(Expect>::isBeforeOrEqual), - fun1, ChronoLocalDateTime<*>>(Expect>::isAfter), - fun1, ChronoLocalDateTime<*>>(Expect>::isAfterOrEqual), - fun1, ChronoLocalDateTime<*>>(Expect>::isEqual) + fun1, ChronoLocalDateTime<*>>(Expect>::toBeBefore), + fun1, ChronoLocalDateTime<*>>(Expect>::toBeBeforeOrTheSamePointInTimeAs), + fun1, ChronoLocalDateTime<*>>(Expect>::toBeAfter), + fun1, ChronoLocalDateTime<*>>(Expect>::toBeAfterOrTheSamePointInTimeAs), + fun1, ChronoLocalDateTime<*>>(Expect>::toBeTheSamePointInTimeAs) ) object ChronoLocalDateTimeAsStringSpec : ch.tutteli.atrium.specs.integration.ChronoLocalDateTimeAsStringExpectationsSpec( - fun1, String>(Expect>::isBefore), - fun1, String>(Expect>::isBeforeOrEqual), - fun1, String>(Expect>::isAfter), - fun1, String>(Expect>::isAfterOrEqual), - fun1, String>(Expect>::isEqual) + fun1, String>(Expect>::toBeBefore), + fun1, String>(Expect>::toBeBeforeOrTheSamePointInTimeAs), + fun1, String>(Expect>::toBeAfter), + fun1, String>(Expect>::toBeAfterOrTheSamePointInTimeAs), + fun1, String>(Expect>::toBeTheSamePointInTimeAs) ) @Suppress("unused", "UNUSED_VALUE") diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoLocalDateTimeExpectationsSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoLocalDateTimeExpectationsSpec.kt index c9bf6a80e..0ec3d6ed3 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoLocalDateTimeExpectationsSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoLocalDateTimeExpectationsSpec.kt @@ -13,11 +13,11 @@ import java.time.chrono.ChronoLocalDateTime import java.time.chrono.JapaneseDate abstract class ChronoLocalDateTimeExpectationsSpec( - isBefore: Fun1, ChronoLocalDateTime<*>>, - isBeforeOrEqual: Fun1, ChronoLocalDateTime<*>>, - isAfter: Fun1, ChronoLocalDateTime<*>>, - isAfterOrEqual: Fun1, ChronoLocalDateTime<*>>, - isEqual: Fun1, ChronoLocalDateTime<*>>, + toBeBefore: Fun1, ChronoLocalDateTime<*>>, + toBeBeforeOrTheSamePointInTimeAs: Fun1, ChronoLocalDateTime<*>>, + toBeAfter: Fun1, ChronoLocalDateTime<*>>, + toBeAfterOrTheSamePointInTimeAs: Fun1, ChronoLocalDateTime<*>>, + toBeTheSamePointInTimeAs: Fun1, ChronoLocalDateTime<*>>, describePrefix: String = "[Atrium] " ) : Spek({ @@ -27,18 +27,18 @@ abstract class ChronoLocalDateTimeExpectationsSpec( include(object : SubjectLessSpec>( describePrefix, - isBefore.forSubjectLess(eleven), - isBeforeOrEqual.forSubjectLess(eleven), - isAfter.forSubjectLess(eleven), - isAfterOrEqual.forSubjectLess(eleven), - isEqual.forSubjectLess(eleven) + toBeBefore.forSubjectLess(eleven), + toBeBeforeOrTheSamePointInTimeAs.forSubjectLess(eleven), + toBeAfter.forSubjectLess(eleven), + toBeAfterOrTheSamePointInTimeAs.forSubjectLess(eleven), + toBeTheSamePointInTimeAs.forSubjectLess(eleven) ) {}) - val isBeforeDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE.getDefault() - val isBeforeOrEqualDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE_OR_EQUAL.getDefault() - val isAfterDescr = DescriptionDateTimeLikeAssertion.IS_AFTER.getDefault() - val isAfterOrEqualDescr = DescriptionDateTimeLikeAssertion.IS_AFTER_OR_EQUAL.getDefault() - val isEqualDescr = DescriptionDateTimeLikeAssertion.IS_EQUAL_TO.getDefault() + val toBeBeforeDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE.getDefault() + val toBeBeforeOrTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_BEFORE_OR_EQUAL.getDefault() + val toBeAfterDescr = DescriptionDateTimeLikeAssertion.IS_AFTER.getDefault() + val toBeAfterOrTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_AFTER_OR_EQUAL.getDefault() + val toBeTheSamePointInTimeAsDescr = DescriptionDateTimeLikeAssertion.IS_EQUAL_TO.getDefault() listOf>( eleven, @@ -47,88 +47,88 @@ abstract class ChronoLocalDateTimeExpectationsSpec( val fluent = expect(subject) describe("$describePrefix subject is $subject") { - describe("${isBefore.name} ...") { - val isBeforeFun = isBefore.lambda + describe("${toBeBefore.name} ...") { + val toBeBeforeFun = toBeBefore.lambda it("$ten throws an AssertionError") { expect { - fluent.isBeforeFun(ten) - }.toThrow { messageToContain("$isBeforeDescr: $ten") } + fluent.toBeBeforeFun(ten) + }.toThrow { messageToContain("$toBeBeforeDescr: $ten") } } it("$eleven throws an AssertionError") { expect { - fluent.isBeforeFun(eleven) - }.toThrow { messageToContain("$isBeforeDescr: $eleven") } + fluent.toBeBeforeFun(eleven) + }.toThrow { messageToContain("$toBeBeforeDescr: $eleven") } } it("$twelve does not throw") { - fluent.isBeforeFun(twelve) + fluent.toBeBeforeFun(twelve) } } - describe("${isBeforeOrEqual.name} ...") { - val isBeforeOrEqualFun = isBeforeOrEqual.lambda + describe("${toBeBeforeOrTheSamePointInTimeAs.name} ...") { + val toBeBeforeOrTheSamePointInTimeAsFun = toBeBeforeOrTheSamePointInTimeAs.lambda it("$ten throws an AssertionError") { expect { - fluent.isBeforeOrEqualFun(ten) - }.toThrow { messageToContain("$isBeforeOrEqualDescr: $ten") } + fluent.toBeBeforeOrTheSamePointInTimeAsFun(ten) + }.toThrow { messageToContain("$toBeBeforeOrTheSamePointInTimeAsDescr: $ten") } } it("$eleven does not throw") { - fluent.isBeforeOrEqualFun(eleven) + fluent.toBeBeforeOrTheSamePointInTimeAsFun(eleven) } it("$twelve does not throw") { - fluent.isBeforeOrEqualFun(twelve) + fluent.toBeBeforeOrTheSamePointInTimeAsFun(twelve) } } - describe("${isAfter.name} ...") { - val isAfterFun = isAfter.lambda + describe("${toBeAfter.name} ...") { + val toBeAfterFun = toBeAfter.lambda it("$ten does not throw") { - fluent.isAfterFun(ten) + fluent.toBeAfterFun(ten) } it("$eleven throws an AssertionError") { expect { - fluent.isAfterFun(eleven) - }.toThrow { messageToContain("$isAfterDescr: $eleven") } + fluent.toBeAfterFun(eleven) + }.toThrow { messageToContain("$toBeAfterDescr: $eleven") } } it("$twelve throws an AssertionError") { expect { - fluent.isAfterFun(twelve) - }.toThrow { messageToContain("$isAfterDescr: $twelve") } + fluent.toBeAfterFun(twelve) + }.toThrow { messageToContain("$toBeAfterDescr: $twelve") } } } - describe("${isAfterOrEqual.name} ...") { - val isAfterOrEqualFun = isAfterOrEqual.lambda + describe("${toBeAfterOrTheSamePointInTimeAs.name} ...") { + val toBeAfterOrTheSamePointInTimeAsFun = toBeAfterOrTheSamePointInTimeAs.lambda it("$ten does not throw") { - fluent.isAfterOrEqualFun(ten) + fluent.toBeAfterOrTheSamePointInTimeAsFun(ten) } it("$eleven does not throw") { - fluent.isAfterOrEqualFun(eleven) + fluent.toBeAfterOrTheSamePointInTimeAsFun(eleven) } it("$twelve throws an AssertionError") { expect { - fluent.isAfterOrEqualFun(twelve) - }.toThrow { messageToContain("$isAfterOrEqualDescr: $twelve") } + fluent.toBeAfterOrTheSamePointInTimeAsFun(twelve) + }.toThrow { messageToContain("$toBeAfterOrTheSamePointInTimeAsDescr: $twelve") } } } - describe("${isEqual.name} ...") { - val isEqualFun = isEqual.lambda + describe("${toBeTheSamePointInTimeAs.name} ...") { + val toBeTheSamePointInTimeAsFun = toBeTheSamePointInTimeAs.lambda it("$ten throws an AssertionError") { expect { - fluent.isEqualFun(ten) - }.toThrow { messageToContain("$isEqualDescr: $ten") } + fluent.toBeTheSamePointInTimeAsFun(ten) + }.toThrow { messageToContain("$toBeTheSamePointInTimeAsDescr: $ten") } } it("$eleven does not throw") { - fluent.isEqualFun(eleven) + fluent.toBeTheSamePointInTimeAsFun(eleven) } it("$twelve throws an AssertionError") { expect { - fluent.isEqualFun(twelve) - }.toThrow { messageToContain("$isEqualDescr: $twelve") } + fluent.toBeTheSamePointInTimeAsFun(twelve) + }.toThrow { messageToContain("$toBeTheSamePointInTimeAsDescr: $twelve") } } } } diff --git a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoZonedDateTimeAsStringExpectationsSpec.kt b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoZonedDateTimeAsStringExpectationsSpec.kt index a310864c6..279e8d179 100644 --- a/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoZonedDateTimeAsStringExpectationsSpec.kt +++ b/misc/specs/atrium-specs-jvm/src/main/kotlin/ch/tutteli/atrium/specs/integration/ChronoZonedDateTimeAsStringExpectationsSpec.kt @@ -17,58 +17,58 @@ import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException abstract class ChronoZonedDateTimeAsStringExpectationsSpec( - isBefore: Fun1, String>, - isBeforeOrEqual: Fun1, String>, - isAfter: Fun1, String>, - isAfterOrEqual: Fun1, String>, - isEqual: Fun1, String>, + toBeBefore: Fun1, String>, + toBeBeforeOrTheSamePointInTimeAs: Fun1, String>, + toBeAfter: Fun1, String>, + toBeAfterOrTheSamePointInTimeAs: Fun1, String>, + toBeTheSamePointInTimeAs: Fun1, String>, describePrefix: String = "[Atrium] " ) : Spek({ - fun isBefore( + fun toBeBefore( expect: Expect>, expected: ChronoZonedDateTime<*> ): Expect> = - expect.(isBefore.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) + expect.(toBeBefore.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) - fun isBeforeOrEqual( + fun toBeBeforeOrTheSamePointInTimeAs( expect: Expect>, expected: ChronoZonedDateTime<*> ): Expect> = - expect.(isBeforeOrEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) + expect.(toBeBeforeOrTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) - fun isAfter( + fun toBeAfter( expect: Expect>, expected: ChronoZonedDateTime<*> ): Expect> = - expect.(isAfter.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) + expect.(toBeAfter.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) - fun isAfterOrEqual( + fun toBeAfterOrTheSamePointInTimeAs( expect: Expect>, expected: ChronoZonedDateTime<*> ): Expect> = - expect.(isAfterOrEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) + expect.(toBeAfterOrTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) - fun isEqual( + fun toBeTheSamePointInTimeAs( expect: Expect>, expected: ChronoZonedDateTime<*> ): Expect> = - expect.(isEqual.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) + expect.(toBeTheSamePointInTimeAs.lambda)(expected.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)) include(object : ChronoZonedDateTimeExpectationsSpec( - fun1(::isBefore), - fun1(::isBeforeOrEqual), - fun1(::isAfter), - fun1(::isAfterOrEqual), - fun1(::isEqual), + fun1(::toBeBefore), + fun1(::toBeBeforeOrTheSamePointInTimeAs), + fun1(::toBeAfter), + fun1(::toBeAfterOrTheSamePointInTimeAs), + fun1(::toBeTheSamePointInTimeAs), describePrefix ) {}) - val isBeforeFun = isBefore.lambda - val isBeforeOrEqualFun = isBeforeOrEqual.lambda - val isAfterFun = isAfter.lambda - val isAfterOrEqualFun = isAfterOrEqual.lambda - val isEqualFun = isEqual.lambda + val toBeBeforeFun = toBeBefore.lambda + val toBeBeforeOrTheSamePointInTimeAsFun = toBeBeforeOrTheSamePointInTimeAs.lambda + val toBeAfterFun = toBeAfter.lambda + val toBeAfterOrTheSamePointInTimeAsFun = toBeAfterOrTheSamePointInTimeAs.lambda + val toBeTheSamePointInTimeAsFun = toBeTheSamePointInTimeAs.lambda val subject = ZonedDateTime.now() as ChronoZonedDateTime<*> val now = expect(subject) @@ -94,29 +94,29 @@ abstract class ChronoZonedDateTimeAsStringExpectationsSpec( "2020-01-02T03:04Z-05:6" ).forEach { value -> context(value) { - it("${isBefore.name} throws a DateTimeParseException") { + it("${toBeBefore.name} throws a DateTimeParseException") { expect { - now.isBeforeFun(value) + now.toBeBeforeFun(value) }.toThrow { messageToContain("could not be parsed") } } - it("${isBeforeOrEqual.name} throws a DateTimeParseException") { + it("${toBeBeforeOrTheSamePointInTimeAs.name} throws a DateTimeParseException") { expect { - now.isBeforeOrEqualFun(value) + now.toBeBeforeOrTheSamePointInTimeAsFun(value) }.toThrow { messageToContain("could not be parsed") } } - it("${isAfter.name} throws a DateTimeParseException") { + it("${toBeAfter.name} throws a DateTimeParseException") { expect { - now.isAfterFun(value) + now.toBeAfterFun(value) }.toThrow { messageToContain("could not be parsed") } } - it("isAfterOrEqual throws a DateTimeParseException") { + it("toBeAfterOrTheSamePointInTimeAs throws a DateTimeParseException") { expect { - now.isAfterOrEqualFun(value) + now.toBeAfterOrTheSamePointInTimeAsFun(value) }.toThrow { messageToContain("could not be parsed") } } - it("${isEqual.name} throws a DateTimeParseException") { + it("${toBeTheSamePointInTimeAs.name} throws a DateTimeParseException") { expect { - now.isEqualFun(value) + now.toBeTheSamePointInTimeAsFun(value) }.toThrow { messageToContain("could not be parsed") } } } @@ -147,71 +147,71 @@ abstract class ChronoZonedDateTimeAsStringExpectationsSpec( context("passing $zonedDateTimeAsString") { - it("$before ${isBefore.name} $zonedDateTimeReferenceValue does not throw") { - expect(before).isBeforeFun(zonedDateTimeAsString) + it("$before ${toBeBefore.name} $zonedDateTimeReferenceValue does not throw") { + expect(before).toBeBeforeFun(zonedDateTimeAsString) } - it("$chronoZonedDateTime ${isBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$chronoZonedDateTime ${toBeBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(chronoZonedDateTime).isBeforeFun(zonedDateTimeAsString) + expect(chronoZonedDateTime).toBeBeforeFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_BEFORE.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$after ${isBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$after ${toBeBefore.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(after).isBeforeFun(zonedDateTimeAsString) + expect(after).toBeBeforeFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_BEFORE.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$before ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue does not throw") { - expect(before).isBeforeOrEqualFun(zonedDateTimeAsString) + it("$before ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") { + expect(before).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString) } - it("$chronoZonedDateTime ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue does not throw") { - expect(chronoZonedDateTime).isBeforeOrEqualFun(zonedDateTimeAsString) + it("$chronoZonedDateTime ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") { + expect(chronoZonedDateTime).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString) } - it("$after ${isBeforeOrEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$after ${toBeBeforeOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(after).isBeforeOrEqualFun(zonedDateTimeAsString) + expect(after).toBeBeforeOrTheSamePointInTimeAsFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_BEFORE_OR_EQUAL.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$before ${isAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$before ${toBeAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(before).isAfterFun(zonedDateTimeAsString) + expect(before).toBeAfterFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_AFTER.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$chronoZonedDateTime ${isAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$chronoZonedDateTime ${toBeAfter.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(chronoZonedDateTime).isAfterFun(zonedDateTimeAsString) + expect(chronoZonedDateTime).toBeAfterFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_AFTER.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$after ${isAfter.name} $zonedDateTimeAsString does not throw") { - expect(after).isAfterFun(zonedDateTimeAsString) + it("$after ${toBeAfter.name} $zonedDateTimeAsString does not throw") { + expect(after).toBeAfterFun(zonedDateTimeAsString) } - it("$before ${isAfterOrEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$before ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(before).isAfterOrEqualFun(zonedDateTimeAsString) + expect(before).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_AFTER_OR_EQUAL.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$chronoZonedDateTime ${isAfterOrEqual.name} $zonedDateTimeReferenceValue does not throw") { - expect(chronoZonedDateTime).isAfterOrEqualFun(zonedDateTimeAsString) + it("$chronoZonedDateTime ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") { + expect(chronoZonedDateTime).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString) } - it("$after ${isAfterOrEqual.name} $zonedDateTimeReferenceValue does not throw") { - expect(after).isAfterOrEqualFun(zonedDateTimeAsString) + it("$after ${toBeAfterOrTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") { + expect(after).toBeAfterOrTheSamePointInTimeAsFun(zonedDateTimeAsString) } - it("$before ${isEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$before ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(before).isEqualFun(zonedDateTimeAsString) + expect(before).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_EQUAL_TO.getDefault()}: $zonedDateTimeReferenceValue") } } - it("$chronoZonedDateTime ${isEqual.name} $zonedDateTimeReferenceValue does not throw") { - expect(chronoZonedDateTime).isEqualFun(zonedDateTimeAsString) + it("$chronoZonedDateTime ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue does not throw") { + expect(chronoZonedDateTime).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString) } - it("$after ${isEqual.name} $zonedDateTimeReferenceValue throws an AssertionError") { + it("$after ${toBeTheSamePointInTimeAs.name} $zonedDateTimeReferenceValue throws an AssertionError") { expect { - expect(after).isEqualFun(zonedDateTimeAsString) + expect(after).toBeTheSamePointInTimeAsFun(zonedDateTimeAsString) }.toThrow { messageToContain("${IS_EQUAL_TO.getDefault()}: $zonedDateTimeReferenceValue") } } }