How to use Instant.shouldBeBetween method of io.kotest.matchers.date.instant class

Best Kotest code snippet using io.kotest.matchers.date.instant.Instant.shouldBeBetween

DateMatchersTest.kt

Source:DateMatchersTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.date2import io.kotest.assertions.shouldFail3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.StringSpec5import io.kotest.matchers.date.after6import io.kotest.matchers.date.atSameZone7import io.kotest.matchers.date.before8import io.kotest.matchers.date.haveSameDay9import io.kotest.matchers.date.haveSameHours10import io.kotest.matchers.date.haveSameInstantAs11import io.kotest.matchers.date.haveSameMinutes12import io.kotest.matchers.date.haveSameMonth13import io.kotest.matchers.date.haveSameNanos14import io.kotest.matchers.date.haveSameSeconds15import io.kotest.matchers.date.haveSameYear16import io.kotest.matchers.date.shouldBeAfter17import io.kotest.matchers.date.shouldBeBefore18import io.kotest.matchers.date.shouldBeBetween19import io.kotest.matchers.date.shouldBeToday20import io.kotest.matchers.date.shouldBeWithin21import io.kotest.matchers.date.shouldHaveDayOfMonth22import io.kotest.matchers.date.shouldHaveDayOfWeek23import io.kotest.matchers.date.shouldHaveDayOfYear24import io.kotest.matchers.date.shouldHaveHour25import io.kotest.matchers.date.shouldHaveMinute26import io.kotest.matchers.date.shouldHaveMonth27import io.kotest.matchers.date.shouldHaveNano28import io.kotest.matchers.date.shouldHaveSameDayAs29import io.kotest.matchers.date.shouldHaveSameHoursAs30import io.kotest.matchers.date.shouldHaveSameInstantAs31import io.kotest.matchers.date.shouldHaveSameMinutesAs32import io.kotest.matchers.date.shouldHaveSameMonthAs33import io.kotest.matchers.date.shouldHaveSameNanosAs34import io.kotest.matchers.date.shouldHaveSameSecondsAs35import io.kotest.matchers.date.shouldHaveSameYearAs36import io.kotest.matchers.date.shouldHaveSecond37import io.kotest.matchers.date.shouldNotBeAfter38import io.kotest.matchers.date.shouldNotBeBefore39import io.kotest.matchers.date.shouldNotBeBetween40import io.kotest.matchers.date.shouldNotBeToday41import io.kotest.matchers.date.shouldNotBeWithin42import io.kotest.matchers.date.shouldNotHaveSameDayAs43import io.kotest.matchers.date.shouldNotHaveSameHoursAs44import io.kotest.matchers.date.shouldNotHaveSameInstantAs45import io.kotest.matchers.date.shouldNotHaveSameMinutesAs46import io.kotest.matchers.date.shouldNotHaveSameMonthAs47import io.kotest.matchers.date.shouldNotHaveSameNanosAs48import io.kotest.matchers.date.shouldNotHaveSameSecondsAs49import io.kotest.matchers.date.shouldNotHaveSameYearAs50import io.kotest.matchers.date.within51import io.kotest.matchers.shouldBe52import io.kotest.matchers.should53import io.kotest.matchers.shouldNot54import io.kotest.matchers.shouldNotBe55import java.time.DayOfWeek.SATURDAY56import java.time.Duration57import java.time.LocalDate58import java.time.LocalDateTime59import java.time.LocalTime60import java.time.Month61import java.time.OffsetDateTime62import java.time.Period63import java.time.ZoneId64import java.time.ZoneOffset65import java.time.ZonedDateTime66class DateMatchersTest : StringSpec() {67 init {68 "LocalTime should have same nanos ignoring other fields" {69 LocalTime.of(1, 2, 3, 4) should haveSameNanos(LocalTime.of(5, 6, 7, 4))70 LocalTime.of(1, 2, 3, 4) shouldNot haveSameNanos(LocalTime.of(1, 2, 3, 8))71 LocalTime.of(1, 2, 3, 4).shouldHaveSameNanosAs(LocalTime.of(5, 6, 7, 4))72 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameNanosAs(LocalTime.of(1, 2, 3, 8))73 }74 "LocalTime should have same seconds ignoring other fields" {75 LocalTime.of(1, 2, 3, 4) should haveSameSeconds(LocalTime.of(5, 6, 3, 4))76 LocalTime.of(1, 2, 3, 4) shouldNot haveSameSeconds(LocalTime.of(1, 2, 5, 4))77 LocalTime.of(1, 2, 3, 4).shouldHaveSameSecondsAs(LocalTime.of(5, 6, 3, 4))78 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameSecondsAs(LocalTime.of(1, 2, 5, 4))79 }80 "LocalTime should have same minutes ignoring other fields" {81 LocalTime.of(1, 2, 3, 4) should haveSameMinutes(LocalTime.of(5, 2, 7, 8))82 LocalTime.of(1, 2, 3, 4) shouldNot haveSameMinutes(LocalTime.of(1, 5, 3, 4))83 LocalTime.of(1, 2, 3, 4).shouldHaveSameMinutesAs(LocalTime.of(5, 2, 7, 8))84 LocalTime.of(1, 2, 3, 4).shouldNotHaveSameMinutesAs(LocalTime.of(1, 5, 3, 4))85 }86 "LocalTime should have same hours ignoring other fields" {87 LocalTime.of(12, 1, 2, 7777) should haveSameHours(LocalTime.of(12, 59, 58, 9999))88 LocalTime.of(3, 59, 58, 9999) shouldNot haveSameHours(LocalTime.of(12, 59, 58, 9999))89 LocalTime.of(12, 1, 2, 7777).shouldHaveSameHoursAs(LocalTime.of(12, 59, 58, 9999))90 LocalTime.of(3, 59, 58, 9999).shouldNotHaveSameHoursAs(LocalTime.of(12, 59, 58, 9999))91 }92 "LocalDate should have same year ignoring other fields" {93 LocalDate.of(2014, 1, 2) should haveSameYear(LocalDate.of(2014, 5, 6))94 LocalDate.of(2014, 1, 2) shouldNot haveSameYear(LocalDate.of(2018, 5, 6))95 LocalDate.of(2014, 1, 2).shouldHaveSameYearAs(LocalDate.of(2014, 5, 6))96 LocalDate.of(2014, 1, 2).shouldNotHaveSameYearAs(LocalDate.of(2018, 5, 6))97 }98 "LocalDateTime should have same year ignoring other fields" {99 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1))100 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1))101 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1))102 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1))103 }104 "ZonedDateTime should have same year ignoring other fields" {105 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))106 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))107 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))108 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atZone(ZoneId.of("Z")))109 }110 "OffsetDateTime should have same year ignoring other fields" {111 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameYear(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))112 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameYear(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))113 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameYearAs(LocalDateTime.of(2014, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))114 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameYearAs(LocalDateTime.of(2018, 5, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))115 }116 "LocalDate should have same month ignoring other fields" {117 LocalDate.of(2014, 1, 2) should haveSameMonth(LocalDate.of(2016, 1, 6))118 LocalDate.of(2014, 1, 2) shouldNot haveSameMonth(LocalDate.of(2018, 4, 6))119 LocalDate.of(2014, 1, 2).shouldHaveSameMonthAs(LocalDate.of(2016, 1, 6))120 LocalDate.of(2014, 1, 2).shouldNotHaveSameMonthAs(LocalDate.of(2018, 4, 6))121 }122 "LocalDateTime should have same month ignoring other fields" {123 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1))124 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1))125 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1))126 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1))127 }128 "ZonedDateTime should have same month ignoring other fields" {129 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atZone(ZoneId.of("Z")))130 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))131 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atZone(ZoneId.of("Z")))132 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))133 }134 "OffsetDateTime should have same month ignoring other fields" {135 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameMonth(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))136 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameMonth(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))137 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameMonthAs(LocalDateTime.of(2014, 1, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))138 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameMonthAs(LocalDateTime.of(2018, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))139 }140 "LocalDate should have same day ignoring other fields" {141 LocalDate.of(2014, 1, 2) should haveSameDay(LocalDate.of(2014, 1, 2))142 LocalDate.of(2014, 1, 2) shouldNot haveSameDay(LocalDate.of(2014, 4, 6))143 LocalDate.of(2014, 1, 2).shouldHaveSameDayAs(LocalDate.of(2014, 1, 2))144 LocalDate.of(2014, 1, 2).shouldNotHaveSameDayAs(LocalDate.of(2014, 4, 6))145 }146 "LocalDateTime should have same day ignoring other fields" {147 LocalDateTime.of(2014, 1, 2, 4, 3, 2) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1))148 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1))149 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1))150 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1))151 }152 "ZonedDateTime should have same day ignoring other fields" {153 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")))154 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))155 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")))156 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atZone(ZoneId.of("Z")))157 }158 "OffsetDateTime should have same day ignoring other fields" {159 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) should haveSameDay(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))160 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNot haveSameDay(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))161 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldHaveSameDayAs(LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))162 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotHaveSameDayAs(LocalDateTime.of(2014, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))163 }164 "LocalTime shouldBe before" {165 LocalTime.of(1, 2, 3, 1000) shouldBe before(LocalTime.of(1, 10, 3, 1000))166 LocalTime.of(1, 2, 3, 1000) shouldNotBe before(LocalTime.of(1, 1, 3, 1000))167 LocalTime.of(1, 2, 3, 1000).shouldBeBefore(LocalTime.of(5, 2, 3, 1000))168 LocalTime.of(1, 2, 3, 1000).shouldNotBeBefore(LocalTime.of(0, 2, 3, 1000))169 }170 "LocalDate shouldBe before" {171 LocalDate.of(2014, 1, 2) shouldBe before(LocalDate.of(2014, 1, 3))172 LocalDate.of(2014, 1, 2) shouldNotBe before(LocalDate.of(2014, 1, 1))173 LocalDate.of(2014, 1, 2).shouldBeBefore(LocalDate.of(2014, 1, 3))174 LocalDate.of(2014, 1, 2).shouldNotBeBefore(LocalDate.of(2014, 1, 1))175 }176 "LocalDateTime shouldBe before" {177 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe before(LocalDateTime.of(2014, 2, 2, 3, 2, 1))178 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe before(LocalDateTime.of(2014, 1, 1, 3, 2, 1))179 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeBefore(LocalDateTime.of(2014, 2, 2, 3, 2, 1))180 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeBefore(LocalDateTime.of(2014, 1, 1, 3, 2, 1))181 }182 "ZonedDateTime shouldBe before" {183 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe before(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))184 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe before(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))185 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeBefore(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))186 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeBefore(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))187 }188 "ZonedDateTime shouldBe equal" {189 ZonedDateTime.of(2019, 12, 10, 10, 0, 0, 0, ZoneOffset.UTC) shouldBe190 ZonedDateTime.of(2019, 12, 10, 4, 0, 0, 0, ZoneId.of("America/Chicago")).atSameZone()191 shouldThrow<AssertionError> {192 ZonedDateTime.of(2019, 12, 10, 10, 0, 0, 0, ZoneOffset.UTC) shouldBe193 ZonedDateTime.of(2019, 12, 10, 4, 1, 0, 0, ZoneId.of("America/Chicago")).atSameZone()194 }.message shouldBe "expected:<2019-12-10T10:01Z> but was:<2019-12-10T10:00Z>"195 }196 "OffsetDateTime shouldBe before" {197 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe before(LocalDateTime.of(2016, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))198 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe before(LocalDateTime.of(2012, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))199 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeBefore(LocalDateTime.of(2016, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC))200 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeBefore(LocalDateTime.of(2012, 2, 6, 3, 2, 1).atOffset(ZoneOffset.UTC))201 }202 "LocalTime shouldBe after" {203 LocalTime.of(1, 2, 3, 9999) shouldBe after(LocalTime.of(1, 2, 3, 1111))204 LocalTime.of(1, 2, 3, 1000) shouldNotBe after(LocalTime.of(1, 2, 10, 1000))205 LocalTime.of(1, 2, 3, 9999).shouldBeAfter(LocalTime.of(1, 2, 3, 1111))206 LocalTime.of(1, 2, 3, 1000).shouldNotBeAfter(LocalTime.of(1, 2, 10, 1000))207 }208 "LocalDate shouldBe after" {209 LocalDate.of(2014, 1, 2) shouldBe after(LocalDate.of(2013, 1, 3))210 LocalDate.of(2014, 1, 2) shouldNotBe after(LocalDate.of(2014, 1, 3))211 LocalDate.of(2014, 1, 2).shouldBeAfter(LocalDate.of(2013, 1, 3))212 LocalDate.of(2014, 1, 2).shouldNotBeAfter(LocalDate.of(2014, 1, 3))213 }214 "LocalDateTime shouldBe after" {215 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1))216 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe after(LocalDateTime.of(2014, 1, 3, 3, 2, 1))217 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1))218 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeAfter(LocalDateTime.of(2014, 1, 3, 3, 2, 1))219 }220 "ZonedDateTime shouldBe after" {221 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))222 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe after(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))223 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atZone(ZoneId.of("Z")))224 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeAfter(LocalDateTime.of(2014, 1, 3, 3, 2, 1).atZone(ZoneId.of("Z")))225 }226 "OffsetDateTime shouldBe after" {227 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe after(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))228 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe after(LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))229 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeAfter(LocalDateTime.of(2014, 1, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))230 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeAfter(LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))231 }232 "LocalDate shouldBe within(period, date)" {233 LocalDate.of(2014, 1, 2) shouldBe within(Period.ofDays(3), LocalDate.of(2014, 1, 1))234 LocalDate.of(2014, 1, 2) shouldBe within(Period.ofDays(3), LocalDate.of(2014, 1, 5))235 LocalDate.of(2014, 1, 2) shouldNotBe within(Period.ofDays(3), LocalDate.of(2014, 1, 6))236 LocalDate.of(2014, 1, 2).shouldBeWithin(Period.ofDays(3), LocalDate.of(2014, 1, 5))237 LocalDate.of(2014, 1, 2).shouldNotBeWithin(Period.ofDays(3), LocalDate.of(2014, 1, 6))238 }239 "LocalDateTime shouldBe within(period, date)" {240 LocalDateTime.of(2014, 1, 2, 4, 3, 2) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2))241 LocalDateTime.of(2014, 1, 2, 3, 2, 1) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2))242 LocalDateTime.of(2014, 1, 2, 4, 3, 2).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2))243 LocalDateTime.of(2014, 1, 2, 3, 2, 1).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2))244 }245 "ZonedDateTime shouldBe within(period, date)" {246 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))247 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))248 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))249 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))250 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))251 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))252 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))253 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))254 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))255 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))256 }257 "ZonedDateTime shouldBe within(duration, date)" {258 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))259 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))260 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))261 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))262 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))263 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atZone(ZoneId.of("Z")))264 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 4, 3, 2).atZone(ZoneId.of("Z")))265 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atZone(ZoneId.of("Z")).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 2, 9, 3, 2).atZone(ZoneId.of("Z")))266 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 3, 2, 2).atZone(ZoneId.of("Z")))267 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atZone(ZoneId.of("Z")).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 1, 3, 2, 0).atZone(ZoneId.of("Z")))268 }269 "OffsetDateTime shouldBe within(period, date)" {270 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe within(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))271 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe within(Period.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))272 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))273 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeWithin(Period.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))274 }275 "OffsetDateTime shouldBe within(duration, date)" {276 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC) shouldBe within(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))277 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC) shouldNotBe within(Duration.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))278 LocalDateTime.of(2014, 1, 2, 4, 3, 2).atOffset(ZoneOffset.UTC).shouldBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 1, 3, 4, 3, 2).atOffset(ZoneOffset.UTC))279 LocalDateTime.of(2014, 1, 2, 3, 2, 1).atOffset(ZoneOffset.UTC).shouldNotBeWithin(Duration.ofDays(1), LocalDateTime.of(2014, 2, 1, 3, 2, 1).atOffset(ZoneOffset.UTC))280 }281 "LocalTime shouldBe between" {282 LocalTime.of(14, 20, 50, 1000).shouldBeBetween(LocalTime.of(14, 20, 49), LocalTime.of(14, 20, 51))283 LocalTime.of(14, 20, 50, 1000).shouldNotBeBetween(LocalTime.of(14, 20, 51), LocalTime.of(14, 20, 52))284 }285 "LocalDate shouldBe between" {286 LocalDate.of(2019, 2, 16).shouldBeBetween(LocalDate.of(2019, 2, 15), LocalDate.of(2019, 2, 17))287 LocalDate.of(2019, 2, 16).shouldNotBeBetween(LocalDate.of(2019, 2, 17), LocalDate.of(2019, 2, 18))288 }289 "LocalDateTime shouldBe between" {290 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldBeBetween(LocalDateTime.of(2019, 2, 15, 12, 0, 0), LocalDateTime.of(2019, 2, 17, 12, 0, 0))291 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldBeBetween(LocalDateTime.of(2019, 2, 16, 10, 0, 0), LocalDateTime.of(2019, 2, 16, 14, 0, 0))292 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldNotBeBetween(LocalDateTime.of(2019, 2, 17, 12, 0, 0), LocalDateTime.of(2019, 2, 18, 12, 0, 0))293 LocalDateTime.of(2019, 2, 16, 12, 0, 0).shouldNotBeBetween(LocalDateTime.of(2019, 2, 16, 18, 0, 0), LocalDateTime.of(2019, 2, 16, 20, 0, 0))294 }295 "ZonedDateTime shouldBe between" {296 ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")).shouldBeBetween(ZonedDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")), ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")))297 ZonedDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")).shouldNotBeBetween(ZonedDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")), ZonedDateTime.of(2019, 2, 18, 12, 0, 0, 0, ZoneId.of("America/Sao_Paulo")))298 }299 "OffsetDateTime shouldBe between" {300 OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3)).shouldBeBetween(OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3)), OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3)))301 OffsetDateTime.of(2019, 2, 15, 12, 0, 0, 0, ZoneOffset.ofHours(-3)).shouldNotBeBetween(OffsetDateTime.of(2019, 2, 16, 12, 0, 0, 0, ZoneOffset.ofHours(-3)), OffsetDateTime.of(2019, 2, 17, 12, 0, 0, 0, ZoneOffset.ofHours(-3)))302 }303 "LocalDate.shouldBeToday() should match today" {304 LocalDate.now().shouldBeToday()305 }306 "LocalDateTime.shouldBeToday() should match today" {307 LocalDateTime.now().shouldBeToday()308 }309 "LocalDate.shouldBeToday() should not match the past" {310 shouldFail {311 LocalDate.of(2002, Month.APRIL, 1).shouldBeToday()312 }313 }314 "LocalDateTime.shouldBeToday() should not match the past" {315 shouldFail {316 LocalDateTime.of(2002, Month.APRIL, 1, 5, 2).shouldBeToday()317 }318 shouldFail {319 LocalDateTime.now().minusDays(1).shouldBeToday()320 }321 }322 "LocalDateTime.shouldNotBeToday()" {323 LocalDateTime.of(2002, Month.APRIL, 1, 5, 2).shouldNotBeToday()324 shouldFail {325 LocalDateTime.now().shouldNotBeToday()326 }327 }328 "LocalDate.shouldNotBeToday()" {329 LocalDate.of(2002, Month.APRIL, 2).shouldNotBeToday()330 shouldFail {331 LocalDateTime.now().shouldNotBeToday()332 }333 }334 "LocalDateTime should have day of month (day)" {335 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfMonth 16336 }337 "LocalDateTime should have day of week" {338 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfWeek SATURDAY339 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfWeek 6340 }341 "LocalDateTime should have day of year" {342 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveDayOfYear 47343 }344 "LocalDateTime should have month" {345 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveMonth 2346 LocalDateTime.of(2019, 2, 16, 12, 0, 0, 0) shouldHaveMonth Month.FEBRUARY347 }348 "LocalDateTime should have hour" {349 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 0) shouldHaveHour 12350 }351 "LocalDateTime should have minute" {352 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 0) shouldHaveMinute 10353 }354 "LocalDateTime should have second" {355 LocalDateTime.of(2019, 2, 16, 12, 10, 13, 0) shouldHaveSecond 13356 }357 "LocalDateTime should have nano" {358 LocalDateTime.of(2019, 2, 16, 12, 10, 0, 14) shouldHaveNano 14359 }360 "ZonedDateTime should be have same instant of the given ZonedDateTime irrespective of their timezone" {361 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) should haveSameInstantAs(ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-3)))362 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldHaveSameInstantAs ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-3))363 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldNot haveSameInstantAs(ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-2)))364 ZonedDateTime.of(2019, 2, 16, 11, 0, 0, 0, ZoneOffset.ofHours(-1)) shouldNotHaveSameInstantAs ZonedDateTime.of(2019, 2, 16, 9, 0, 0, 0, ZoneOffset.ofHours(-2))365 }366 }367}...

Full Screen

Full Screen

TidspunktTest.kt

Source:TidspunktTest.kt Github

copy

Full Screen

1package no.nav.su.se.bakover.common2import io.kotest.matchers.comparables.shouldBeGreaterThan3import io.kotest.matchers.comparables.shouldBeLessThan4import io.kotest.matchers.comparables.shouldNotBeLessThan5import io.kotest.matchers.ints.shouldBeBetween6import io.kotest.matchers.shouldBe7import io.kotest.matchers.shouldNotBe8import io.kotest.matchers.types.shouldNotBeSameInstanceAs9import org.junit.jupiter.api.Test10import java.time.Clock11import java.time.Instant12import java.time.LocalDate13import java.time.Month14import java.time.ZoneOffset15import java.time.temporal.ChronoUnit16internal class TidspunktTest {17 private val instant = Instant.parse("1970-01-01T01:01:01.123456789Z")18 @Test19 fun `truncate instant to same format as repo, precision in micros`() {20 val tidspunkt = instant.toTidspunkt()21 ChronoUnit.MICROS.between(instant, tidspunkt) shouldBe 022 instant.toString().length.shouldNotBeLessThan(tidspunkt.toString().length)23 tidspunkt.nano % 1000 shouldBe 024 val addedMicrosInstant = instant.plus(251, ChronoUnit.MICROS)25 val addedMicrosTidspunkt = addedMicrosInstant.toTidspunkt()26 ChronoUnit.MICROS.between(addedMicrosInstant, addedMicrosTidspunkt) shouldBe 027 addedMicrosInstant.toString().length.shouldNotBeLessThan(addedMicrosTidspunkt.toString().length)28 addedMicrosTidspunkt.nano % 1000 shouldBe 029 val addedNanosInstant = instant.plusNanos(378)30 val addedNanosTidspunkt = addedNanosInstant.toTidspunkt()31 (addedNanosInstant.nano - addedNanosTidspunkt.nano).shouldBeBetween(1, 1000)32 addedNanosInstant shouldNotBe addedNanosTidspunkt.instant33 addedNanosTidspunkt shouldBe addedNanosInstant34 ChronoUnit.MICROS.between(addedNanosInstant, addedNanosTidspunkt) shouldBe 035 addedNanosInstant.toString().length.shouldNotBeLessThan(addedNanosTidspunkt.toString().length)36 addedNanosTidspunkt.nano % 1000 shouldBe 037 }38 @Test39 fun `should equal instant truncated to same precision`() {40 val instant = instant.plusNanos(515)41 val tidspunkt = instant.toTidspunkt()42 instant shouldNotBe tidspunkt.instant43 instant.truncatedTo(Tidspunkt.unit) shouldBe tidspunkt.instant44 tidspunkt shouldBe instant45 tidspunkt shouldBe instant.truncatedTo(Tidspunkt.unit)46 val othertidspunkt = instant.toTidspunkt()47 tidspunkt shouldBe othertidspunkt48 tidspunkt shouldBe tidspunkt49 }50 @Test51 fun comparison() {52 val startOfDayInstant = 1.januar(2020).atStartOfDay().toInstant(ZoneOffset.UTC)53 val endOfDayInstant = 1.januar(2020).plusDays(1).atStartOfDay().minusNanos(1).toInstant(ZoneOffset.UTC)54 val startOfDaytidspunkt = startOfDayInstant.toTidspunkt()55 val endOfDaytidspunkt = endOfDayInstant.toTidspunkt()56 startOfDayInstant shouldBeLessThan endOfDayInstant57 startOfDaytidspunkt.instant shouldBeLessThan endOfDaytidspunkt.instant58 startOfDayInstant shouldBeLessThan endOfDaytidspunkt.instant59 endOfDayInstant shouldBeGreaterThan startOfDaytidspunkt.instant60 }61 @Test62 fun `new instances for companions`() {63 val firstEpoch = Tidspunkt.EPOCH64 val secondEpoch = Tidspunkt.EPOCH65 firstEpoch shouldNotBeSameInstanceAs secondEpoch66 val firstMin = Tidspunkt.MIN67 val secondMin = Tidspunkt.MIN68 firstMin shouldNotBeSameInstanceAs secondMin69 }70 @Test71 fun `should serialize as instant`() {72 val start = 1.oktober(2020).endOfDay()73 val serialized = objectMapper.writeValueAsString(start)74 serialized shouldBe "\"2020-10-01T21:59:59.999999Z\"" // Denne serialiseres til json-streng istedenfor objekt75 val deserialized = objectMapper.readValue(serialized, Tidspunkt::class.java)76 deserialized shouldBe start77 val objSerialized = objectMapper.writeValueAsString(NestedSerialization(start))78 objSerialized shouldBe """{"tidspunkt":"2020-10-01T21:59:59.999999Z","other":"other values"}"""79 val objDeserialized = objectMapper.readValue(objSerialized, NestedSerialization::class.java)80 objDeserialized shouldBe NestedSerialization(start, "other values")81 }82 @Test83 fun now() {84 val fixedUTC = Clock.fixed(1.januar(2020).endOfDay(ZoneOffset.UTC).instant, ZoneOffset.UTC)85 val nowUTC = Tidspunkt.now(fixedUTC)86 nowUTC.toString() shouldBe "2020-01-01T23:59:59.999999Z"87 val fixedOslo = Clock.fixed(1.januar(2020).endOfDay(zoneIdOslo).instant, zoneIdOslo)88 val nowOslo = Tidspunkt.now(fixedOslo)89 nowOslo.toString() shouldBe "2020-01-01T22:59:59.999999Z"90 }91 @Test92 fun `konverterer tidspunkt til localDate`() {93 1.januar(2020).startOfDay(ZoneOffset.UTC).toLocalDate(ZoneOffset.UTC) shouldBe LocalDate.of(94 2020,95 Month.JANUARY,96 197 )98 1.januar(2020).endOfDay(ZoneOffset.UTC).toLocalDate(ZoneOffset.UTC) shouldBe LocalDate.of(99 2020,100 Month.JANUARY,101 1102 )103 1.januar(2020).startOfDay(zoneIdOslo).toLocalDate(zoneIdOslo) shouldBe LocalDate.of(2020, Month.JANUARY, 1)104 1.januar(2020).endOfDay(zoneIdOslo).toLocalDate(zoneIdOslo) shouldBe LocalDate.of(2020, Month.JANUARY, 1)105 }106 @Test107 fun `plusser på tid`() {108 Tidspunkt(instant).plus(1, ChronoUnit.DAYS).toString() shouldBe "1970-01-02T01:01:01.123456Z"109 }110 data class NestedSerialization(111 val tidspunkt: Tidspunkt,112 val other: String = "other values"113 )114}...

Full Screen

Full Screen

timestampTest.kt

Source:timestampTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.date2import io.kotest.core.spec.style.FreeSpec3import io.kotest.matchers.date.shouldBeAfter4import io.kotest.matchers.date.shouldBeBefore5import io.kotest.matchers.date.shouldBeBetween6import io.kotest.matchers.date.shouldNotBeAfter7import io.kotest.matchers.date.shouldNotBeBefore8import io.kotest.matchers.date.shouldNotBeBetween9import io.kotest.matchers.shouldBe10import io.kotest.matchers.shouldNotBe11import java.sql.Timestamp12import java.time.Instant13class TimeStampTest : FreeSpec() {14 init {15 "two timestamp of same instance should be same" {16 val nowInstance = Instant.now()17 Timestamp.from(nowInstance) shouldBe Timestamp.from(nowInstance)18 }19 "two timestamp of different instance should be not be same" {20 val nowInstance = Instant.now()21 val anotherInstance = nowInstance.plusMillis(1000L)22 Timestamp.from(nowInstance) shouldNotBe Timestamp.from(anotherInstance)23 }24 "timestamp of current instance should be after the timestamp of past instance" {25 val nowInstance = Instant.now()26 val instanceBeforeFiveSecond = nowInstance.minusMillis(5000L)27 Timestamp.from(nowInstance) shouldBeAfter Timestamp.from(instanceBeforeFiveSecond)28 }29 "timestamp of current instance should not be after the timestamp of future instance" {30 val nowInstance = Instant.now()31 val instanceAfterFiveSecond = nowInstance.plusMillis(5000L)32 Timestamp.from(nowInstance) shouldNotBeAfter Timestamp.from(instanceAfterFiveSecond)33 }34 "timestamp of current instance should not be after the another timestamp of same instance" {35 val nowInstance = Instant.now()36 Timestamp.from(nowInstance) shouldNotBeAfter Timestamp.from(nowInstance)37 }38 "timestamp of current instance should be before the timestamp of future instance" {39 val nowInstance = Instant.now()40 val instanceAfterFiveSecond = nowInstance.plusMillis(5000L)41 Timestamp.from(nowInstance) shouldBeBefore Timestamp.from(instanceAfterFiveSecond)42 }43 "timestamp of current instance should not be before the timestamp of past instance" {44 val nowInstance = Instant.now()45 val instanceBeforeFiveSecond = nowInstance.minusMillis(5000L)46 Timestamp.from(nowInstance) shouldNotBeBefore Timestamp.from(instanceBeforeFiveSecond)47 }48 "timestamp of current instance should not be before the another timestamp of same instance" {49 val nowInstance = Instant.now()50 Timestamp.from(nowInstance) shouldNotBeBefore Timestamp.from(nowInstance)51 }52 "current timestamp should be between timestamp of past and future" {53 val nowInstant = Instant.now()54 val currentTimestamp = Timestamp.from(nowInstant)55 val pastTimestamp = Timestamp.from(nowInstant.minusMillis(5000))56 val futureTimestamp = Timestamp.from(nowInstant.plusMillis(5000))57 currentTimestamp.shouldBeBetween(pastTimestamp, futureTimestamp)58 }59 "past timestamp should not be between timestamp of current instant and future" {60 val nowInstant = Instant.now()61 val currentTimestamp = Timestamp.from(nowInstant)62 val pastTimestamp = Timestamp.from(nowInstant.minusMillis(5000))63 val futureTimestamp = Timestamp.from(nowInstant.plusMillis(5000))64 pastTimestamp.shouldNotBeBetween(currentTimestamp, futureTimestamp)65 }66 "future timestamp should not be between timestamp of current instant and future" {67 val nowInstant = Instant.now()68 val currentTimestamp = Timestamp.from(nowInstant)69 val pastTimestamp = Timestamp.from(nowInstant.minusMillis(5000))70 val futureTimestamp = Timestamp.from(nowInstant.plusMillis(5000))71 futureTimestamp.shouldNotBeBetween(pastTimestamp, currentTimestamp)72 }73 }74}...

Full Screen

Full Screen

HistoryBTest.kt

Source:HistoryBTest.kt Github

copy

Full Screen

1package com.painkillergis.fall_color_history.snapshot2import com.painkillergis.fall_color_history.util.BFunSpec3import com.painkillergis.fall_color_history.util.toJsonObject4import io.kotest.matchers.date.shouldBeBetween5import io.kotest.matchers.shouldBe6import io.ktor.client.call.*7import io.ktor.client.request.*8import io.ktor.client.statement.*9import io.ktor.http.*10import kotlinx.serialization.json.JsonObject11import java.time.Instant12import java.time.format.DateTimeFormatter13class HistoryBTest : BFunSpec({ httpClient ->14 afterEach {15 httpClient.delete<Unit>("/snapshots")16 }17 test("no history") {18 httpClient.get<HttpResponse>("/snapshots").apply {19 status shouldBe HttpStatusCode.OK20 receive<JsonObject>() shouldBe mapOf("history" to emptyList<Unit>())21 }22 }23 test("history after updates") {24 httpClient.put<Unit>("/snapshots/latest") {25 contentType(ContentType.Application.Json)26 body = LocationsContainer(mapOf("the" to "first update"))27 }28 httpClient.put<Unit>("/snapshots/latest") {29 contentType(ContentType.Application.Json)30 body = LocationsContainer(mapOf("the" to "second update"))31 }32 httpClient.get<HttpResponse>("/snapshots").apply {33 status shouldBe HttpStatusCode.OK34 receive<HistoryContainer>().shouldBeHistory(35 SnapshotContainerMatcher(LocationsContainer(mapOf("the" to "first update"))),36 SnapshotContainerMatcher(LocationsContainer(mapOf("the" to "second update"))),37 )38 }39 }40 test("discard duplicate updates") {41 httpClient.put<Unit>("/snapshots/latest") {42 contentType(ContentType.Application.Json)43 body = LocationsContainer(mapOf("the" to "same update"))44 }45 httpClient.put<Unit>("/snapshots/latest") {46 contentType(ContentType.Application.Json)47 body = LocationsContainer(mapOf("the" to "same update"))48 }49 httpClient.get<HistoryContainer>("/snapshots").shouldBeHistory(50 SnapshotContainerMatcher(LocationsContainer(mapOf("the" to "same update"))),51 )52 }53 test("photo field does not impact distinctness of a snapshot") {54 val withPhoto = LocationsContainer(mapOf("the" to "same update", "photo" to "123456"))55 val withoutPhoto = LocationsContainer(mapOf("the" to "same update"))56 httpClient.put<Unit>("/snapshots/latest") {57 contentType(ContentType.Application.Json)58 body = withPhoto59 }60 httpClient.put<Unit>("/snapshots/latest") {61 contentType(ContentType.Application.Json)62 body = withoutPhoto63 }64 httpClient.get<HistoryContainer>("/snapshots").shouldBeHistory(65 SnapshotContainerMatcher(withPhoto),66 )67 httpClient.delete<Unit>("/snapshots")68 httpClient.put<Unit>("/snapshots/latest") {69 contentType(ContentType.Application.Json)70 body = withoutPhoto71 }72 httpClient.put<Unit>("/snapshots/latest") {73 contentType(ContentType.Application.Json)74 body = withPhoto75 }76 httpClient.get<HistoryContainer>("/snapshots").shouldBeHistory(77 SnapshotContainerMatcher(withoutPhoto),78 )79 }80})81fun HistoryContainer.shouldBeHistory(vararg matcher: SnapshotContainerMatcher) {82 history.size shouldBe matcher.size83 history.zip(matcher).forEachIndexed { index, (actual, matcher) ->84 try {85 actual.content shouldBe matcher.content86 Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(actual.timestamp))87 .shouldBeBetween(88 matcher.timestamp.minusMillis(matcher.timestampToleranceMs),89 matcher.timestamp.plusMillis(matcher.timestampToleranceMs),90 )91 } catch (exception: AssertionError) {92 throw AssertionError("Snapshot containers did not match at index $index", exception)93 }94 }95}96data class SnapshotContainerMatcher(97 val content: LocationsContainer,98 val timestamp: Instant = Instant.now(),99 val timestampToleranceMs: Long = 1000,100)...

Full Screen

Full Screen

instantMatcherTest.kt

Source:instantMatcherTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.date2import io.kotest.core.spec.style.FreeSpec3import io.kotest.matchers.date.shouldBeAfter4import io.kotest.matchers.date.shouldBeBefore5import io.kotest.matchers.date.shouldBeBetween6import io.kotest.matchers.date.shouldNotBeAfter7import io.kotest.matchers.date.shouldNotBeBefore8import io.kotest.matchers.date.shouldNotBeBetween9import io.kotest.matchers.shouldBe10import io.kotest.matchers.shouldNotBe11import java.time.Instant12class InstantMatcherTest : FreeSpec() {13 init {14 "same instance of instant should be same" {15 val currentInstant = Instant.now()16 currentInstant shouldBe currentInstant17 }18 "different instance of instant having same time should be same" {19 Instant.ofEpochMilli(10000) shouldBe Instant.ofEpochMilli(10000)20 }21 "instance of different time should be different" {22 val currentInstant = Instant.now()23 val pastInstant = currentInstant.minusMillis(40000)24 currentInstant shouldNotBe pastInstant25 }26 "past instant should be before current instant" {27 val currentInstant = Instant.now()28 val pastInstant = currentInstant.minusMillis(1000)29 pastInstant shouldBeBefore currentInstant30 }31 "current instant should not be before past instant" {32 val currentInstant = Instant.now()33 val pastInstant = currentInstant.minusMillis(1000)34 currentInstant shouldNotBeBefore pastInstant35 }36 "future instant should be after current instant" {37 val currentInstant = Instant.now()38 val futureInstant = currentInstant.plusMillis(1000)39 futureInstant shouldBeAfter currentInstant40 }41 "current instant should not be after past instant" {42 val currentInstant = Instant.now()43 val futureInstant = currentInstant.plusMillis(1000)44 currentInstant shouldNotBeAfter futureInstant45 }46 "instant of same time should not be before another instant of same time" {47 Instant.ofEpochMilli(30000) shouldNotBeBefore Instant.ofEpochMilli(30000)48 }49 "instant of same time should not be after another instant of same time" {50 Instant.ofEpochMilli(30000) shouldNotBeAfter Instant.ofEpochMilli(30000)51 }52 "current instant should be between past instant and future instant" {53 val currentInstant = Instant.now()54 val pastInstant = currentInstant.minusMillis(30000)55 val futureInstant = currentInstant.plusMillis(30000)56 currentInstant.shouldBeBetween(pastInstant, futureInstant)57 }58 "past instant should not be between current instant and future instant" {59 val currentInstant = Instant.now()60 val pastInstant = currentInstant.minusMillis(30000)61 val futureInstant = currentInstant.plusMillis(30000)62 pastInstant.shouldNotBeBetween(currentInstant, futureInstant)63 }64 "future instant should not be between past instant and current instant" {65 val currentInstant = Instant.now()66 val pastInstant = currentInstant.minusMillis(30000)67 val futureInstant = currentInstant.plusMillis(30000)68 futureInstant.shouldNotBeBetween(pastInstant, currentInstant)69 }70 }71}...

Full Screen

Full Screen

instant.kt

Source:instant.kt Github

copy

Full Screen

1package io.kotest.matchers.date2import io.kotest.matchers.Matcher3import io.kotest.matchers.MatcherResult4import io.kotest.matchers.shouldBe5import io.kotest.matchers.shouldNot6import io.kotest.matchers.shouldNotBe7import java.time.Instant8fun before(anotherInstant: Instant) = object : Matcher<Instant> {9 override fun test(value: Instant): MatcherResult {10 return MatcherResult(11 value.isBefore(anotherInstant),12 { "Expected $value to be before $anotherInstant, but it's not." },13 { "$anotherInstant is not expected to be before $value." }14 )15 }16}17fun after(anotherInstant: Instant) = object : Matcher<Instant> {18 override fun test(value: Instant): MatcherResult {19 return MatcherResult(20 value.isAfter(anotherInstant),21 { "Expected $value to be after $anotherInstant, but it's not." },22 { "$anotherInstant is not expected to be after $value." }23 )24 }25}26fun between(fromInstant: Instant, toInstant: Instant) = object : Matcher<Instant> {27 override fun test(value: Instant): MatcherResult {28 return MatcherResult(29 value.isAfter(fromInstant) && value.isBefore(toInstant),30 { "$value should be after $fromInstant and before $toInstant" },31 { "$value should not be be after $fromInstant and before $toInstant" }32 )33 }34}35/**36 * Assert that [Instant] is before [anotherInstant].37 * @see [shouldNotBeBefore]38 * */39infix fun Instant.shouldBeBefore(anotherInstant: Instant) = this shouldBe before(anotherInstant)40/**41 * Assert that [Instant] is not before [anotherInstant].42 * @see [shouldBeBefore]43 * */44infix fun Instant.shouldNotBeBefore(anotherInstant: Instant) = this shouldNotBe before(anotherInstant)45/**46 * Assert that [Instant] is after [anotherInstant].47 * @see [shouldNotBeAfter]48 * */49infix fun Instant.shouldBeAfter(anotherInstant: Instant) = this shouldBe after(anotherInstant)50/**51 * Assert that [Instant] is not after [anotherInstant].52 * @see [shouldNotBeAfter]53 * */54infix fun Instant.shouldNotBeAfter(anotherInstant: Instant) = this shouldNot after(anotherInstant)55/**56 * Assert that [Instant] is between [fromInstant] and [toInstant].57 * @see [shouldNotBeBetween]58 * */59fun Instant.shouldBeBetween(fromInstant: Instant, toInstant: Instant) = this shouldBe between(fromInstant, toInstant)60/**61 * Assert that [Instant] is between [fromInstant] and [toInstant].62 * @see [shouldBeBetween]63 * */64fun Instant.shouldNotBeBetween(fromInstant: Instant, toInstant: Instant) = this shouldNotBe between(fromInstant, toInstant)...

Full Screen

Full Screen

LatestBTest.kt

Source:LatestBTest.kt Github

copy

Full Screen

1package com.painkillergis.fall_color_history.snapshot2import com.painkillergis.fall_color_history.util.BFunSpec3import com.painkillergis.fall_color_history.util.toJsonObject4import io.kotest.matchers.date.shouldBeBetween5import io.kotest.matchers.shouldBe6import io.ktor.client.call.*7import io.ktor.client.request.*8import io.ktor.client.statement.*9import io.ktor.http.*10import kotlinx.serialization.json.JsonObject11import kotlinx.serialization.json.JsonPrimitive12import java.time.Instant13import java.time.format.DateTimeFormatter14class LatestBTest : BFunSpec({ httpClient ->15 afterEach {16 httpClient.delete<Unit>("/snapshots")17 }18 test("no latest") {19 httpClient.get<HttpResponse>("/snapshots/latest").apply {20 status shouldBe HttpStatusCode.OK21 receive<JsonObject>() shouldBe mapOf(22 "timestamp" to "",23 "content" to emptyMap<String, Unit>(),24 ).toJsonObject()25 }26 }27 test("replace latest") {28 val latest = mapOf("locations" to emptyList<Unit>())29 httpClient.put<HttpResponse>("/snapshots/latest") {30 contentType(ContentType.Application.Json)31 body = latest32 }.apply {33 status shouldBe HttpStatusCode.NoContent34 }35 httpClient.get<HttpResponse>("/snapshots/latest").apply {36 status shouldBe HttpStatusCode.OK37 receive<JsonObject>().apply {38 (get("timestamp") as JsonPrimitive)39 .content40 .let { Instant.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(it)) }41 .shouldBeBetween(42 Instant.now().minusSeconds(5),43 Instant.now().plusSeconds(5),44 )45 get("content") shouldBe latest46 }47 }48 }49})...

Full Screen

Full Screen

CreateTrialUserImplTest.kt

Source:CreateTrialUserImplTest.kt Github

copy

Full Screen

1package com.falcon.falcon.core.usecase.trial2import com.falcon.falcon.core.entity.User3import com.falcon.falcon.core.enumeration.UserType4import com.falcon.falcon.core.usecase.user.CreateUserUseCase5import io.kotest.matchers.date.shouldBeBetween6import io.kotest.matchers.shouldBe7import io.kotest.matchers.string.shouldBeUUID8import io.kotest.matchers.types.shouldBeTypeOf9import io.mockk.clearAllMocks10import io.mockk.every11import io.mockk.mockk12import org.junit.jupiter.api.BeforeEach13import org.junit.jupiter.api.Test14import org.junit.jupiter.api.TestInstance15import java.time.Instant16import java.time.temporal.ChronoUnit17@TestInstance(TestInstance.Lifecycle.PER_CLASS)18internal class CreateTrialUserImplTest {19 private val createUserUseCase: CreateUserUseCase = mockk()20 private val trialDuration = 1L21 private val underTest: CreateTrialUserImpl = CreateTrialUserImpl(createUserUseCase, trialDuration)22 @BeforeEach23 fun init() {24 clearAllMocks()25 }26 @Test27 fun `Should generate random user`() {28 // Given29 every { createUserUseCase.execute(any()) } returnsArgument 030 // When31 val result = underTest.execute()32 // Then33 result.shouldBeTypeOf<User>()34 result.username.shouldBeUUID()35 result.password.shouldBeUUID()36 result.type.shouldBe(UserType.TRIAL)37 result.expirationDate?.shouldBeBetween(38 Instant.now().plus(50, ChronoUnit.MINUTES),39 Instant.now().plus(70, ChronoUnit.MINUTES),40 )41 }42}...

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))2Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))3Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))4Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))5Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))6Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))7Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))8Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))9Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))10Instant.now().shouldBeBetween(Instant.now().minus(1, ChronoUnit.SECONDS), Instant.now().plus(1, ChronoUnit.SECONDS))

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1val instant = Instant.now()2instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))3val instant = Instant.now()4instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))5val instant = Instant.now()6instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))7val instant = Instant.now()8instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))9val instant = Instant.now()10instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))11val instant = Instant.now()12instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))13val instant = Instant.now()14instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))15val instant = Instant.now()16instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))17val instant = Instant.now()18instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))19val instant = Instant.now()20instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))21val instant = Instant.now()22instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.date.instant.shouldBeBetween2import java.time.Instant3val instant = Instant.now()4instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))5import io.kotest.matchers.date.instant.shouldBeBetween6import java.time.Instant7val instant = Instant.now()8instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))9import io.kotest.matchers.date.instant.shouldBeBetween10import java.time.Instant11val instant = Instant.now()12instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))13import io.kotest.matchers.date.instant.shouldBeBetween14import java.time.Instant15val instant = Instant.now()16instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))17import io.kotest.matchers.date.instant.shouldBeBetween18import java.time.Instant19val instant = Instant.now()20instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))21import io.kotest.matchers.date.instant.shouldBeBetween22import java.time.Instant23val instant = Instant.now()24instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))25import io.kotest.matchers.date.instant.shouldBeBetween26import java.time.Instant27val instant = Instant.now()28instant.shouldBeBetween(Instant.now().minusSeconds(10), Instant.now().plusSeconds(10))29import io.kotest.matchers.date.instant.shouldBeBetween30import java.time.Instant31val instant = Instant.now()32instant.shouldBeBetween(Instant.now().minusSeconds(

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1val today = Instant.now() val tomorrow = Instant.now().plus(1, ChronoUnit.DAYS) val yesterday = Instant.now().minus(1, ChronoUnit.DAYS) today.shouldBeBetween(yesterday, tomorrow) today.shouldBeBetween(yesterday, today) today.shouldBeBetween(today, tomorrow) today.shouldBeBetween(today, today)2val today = Instant.now() val tomorrow = Instant.now().plus(1, ChronoUnit.DAYS) val yesterday = Instant.now().minus(1, ChronoUnit.DAYS) today.shouldNotBeBetween(tomorrow, tomorrow.plus(1, ChronoUnit.DAYS)) today.shouldNotBeBetween(yesterday.minus(1, ChronoUnit.DAYS), yesterday)3val today = LocalDate.now() val tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS) val yesterday = LocalDate.now().minus(1, ChronoUnit.DAYS) today.shouldBeBetween(yesterday, tomorrow) today.shouldBeBetween(yesterday, today) today.shouldBeBetween(today, tomorrow) today.shouldBeBetween(today, today)4val today = LocalDate.now() val tomorrow = LocalDate.now().plus(1, ChronoUnit.DAYS) val yesterday = LocalDate.now().minus(1, ChronoUnit.DAYS) today.shouldNotBeBetween(tomorrow, tomorrow.plus(1, ChronoUnit.DAYS)) today.shouldNotBeBetween(yesterday.minus(1, ChronoUnit.DAYS), yesterday)5val today = LocalDateTime.now() val tomorrow = LocalDateTime.now().plus(1, ChronoUnit.DAYS) val yesterday = LocalDateTime.now().minus(1, ChronoUnit.DAYS) today.shouldBeBetween(yesterday, tomorrow) today.shouldBeBetween(yesterday, today) today.shouldBeBetween(today, tomorrow) today.shouldBeBetween(today, today)6val today = LocalDateTime.now() val tomorrow = LocalDateTime.now().plus(1, ChronoUnit

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1 val instant = Instant.now()2 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5))3 val instant = Instant.now()4 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5)5 val instant = Instant.now()6 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS)7 val instant = Instant.now()8 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS, 5)9 val instant = Instant.now()10 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS, 5, 5)11 val instant = Instant.now()12 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS, 5, 5, 5)13 val instant = Instant.now()14 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS, 5, 5, 5, 5)15 val instant = Instant.now()16 instant.shouldBeBetween(Instant.now().minusSeconds(5), Instant.now().plusSeconds(5), 5, TimeUnit.SECONDS, 5, 5, 5, 5, 5)17 val instant = Instant.now()18 instant.shouldBeBetween(Instant

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1"Instant should be between" {2val instant = Instant.now()3instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))4}5"Instant should be between" {6val instant = Instant.now()7instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))8}9"Instant should be between" {10val instant = Instant.now()11instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))12}13"Instant should be between" {14val instant = Instant.now()15instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))16}17"Instant should be between" {18val instant = Instant.now()19instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))20}21"Instant should be between" {22val instant = Instant.now()23instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))24}25"Instant should be between" {26val instant = Instant.now()27instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))28}29"Instant should be between" {30val instant = Instant.now()31instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))32}33"Instant should be between" {34val instant = Instant.now()35instant.shouldBeBetween(Instant.now().minusSeconds(1), Instant.now().plusSeconds(1))36}

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.date.instant.shouldBeBetween2import java.time.Instant3import java.time.temporal.ChronoUnit4import kotlin.test.Test5class InstantTest {6fun `instant should be between`() {7val instant = Instant.now()8instant.shouldBeBetween(instant.minus(1, ChronoUnit.DAYS), instant.plus(1, ChronoUnit.DAYS))9}10}11import io.kotest.matchers.date.instant.shouldBeAfter12import java.time.Instant13import kotlin.test.Test14class InstantTest {15fun `instant should be after`() {16val instant = Instant.now()17instant.shouldBeAfter(instant.minus(1, ChronoUnit.DAYS))18}19}20import io.kotest.matchers.date.instant.shouldBeBefore21import java.time.Instant22import kotlin.test.Test23class InstantTest {24fun `instant should be before`() {25val instant = Instant.now()26instant.shouldBeBefore(instant.plus(1, ChronoUnit.DAYS))27}28}29import io.kotest.matchers.date.instant.shouldBeToday30import java.time.Instant31import kotlin.test.Test32class InstantTest {33fun `instant should be today`() {34val instant = Instant.now()35instant.shouldBeToday()36}37}38import io.kotest.matchers.date.instant.shouldBeYesterday39import java.time.Instant40import kotlin.test.Test41class InstantTest {42fun `instant should be yesterday`() {43val instant = Instant.now()44instant.shouldBeYesterday()45}46}47import io.kotest.matchers.date.instant.shouldBeTomorrow48import java.time.Instant49import kotlin.test.Test50class InstantTest {51fun `instant should be tomorrow`() {52val instant = Instant.now()53instant.shouldBeTomorrow()54}55}56import io.kotest.matchers.date.instant.shouldBeWithin57import java.time

Full Screen

Full Screen

Instant.shouldBeBetween

Using AI Code Generation

copy

Full Screen

1class InstantShouldBeBetweenTest : ShouldSpec({2"Instant should be between" {3}4})5class InstantShouldBeBetweenTest : ShouldSpec({6"Instant should be between" {7}8})9class InstantShouldBeBetweenTest : ShouldSpec({10"Instant should be between" {11}12})13class InstantShouldBeBetweenTest : ShouldSpec({14"Instant should be between" {15}16})17class InstantShouldBeBetweenTest : ShouldSpec({18"Instant should be between" {19}20})21class InstantShouldBeBetweenTest : ShouldSpec({22"Instant should be between" {23}24})25class InstantShouldBeBetweenTest : ShouldSpec({26"Instant should be between" {27}28})29class InstantShouldBeBetweenTest : ShouldSpec({30"Instant should be between" {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful