Search in sources :

Example 21 with UncheckedAutoCloseable

use of com.cadenzauk.core.lang.UncheckedAutoCloseable in project siesta by cadenzauk.

the class ZonedDateTimeConverterTest method convertToEntityAttributeGregorianShouldNotThrow.

@ParameterizedTest
@MethodSource("timezones")
void convertToEntityAttributeGregorianShouldNotThrow(String timeZone) {
    ZonedDateTime dateTime = ZonedDateTime.of(LocalDateUtil.START_OF_GREGORIAN_CALENDAR, LocalTime.MIN, ZoneId.of(timeZone));
    Timestamp input = Timestamp.from(dateTime.toInstant());
    try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
        ZonedDateTimeConverter sut = new ZonedDateTimeConverter(ZoneId.of(timeZone));
        ZonedDateTime result = sut.convertToEntityAttribute(input);
        assertThat(result, notNullValue());
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) Timestamp(java.sql.Timestamp) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 22 with UncheckedAutoCloseable

use of com.cadenzauk.core.lang.UncheckedAutoCloseable in project siesta by cadenzauk.

the class ZonedDateTimeConverterTest method convertToDatabaseColumnGregorianShouldNotThrow.

@ParameterizedTest
@MethodSource("timezones")
void convertToDatabaseColumnGregorianShouldNotThrow(String timeZone) {
    ZonedDateTime input = ZonedDateTime.of(LocalDateUtil.START_OF_GREGORIAN_CALENDAR, LocalTime.MIN, ZoneId.of(timeZone));
    try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
        ZonedDateTimeConverter sut = new ZonedDateTimeConverter(ZoneId.of(timeZone));
        Timestamp result = sut.convertToDatabaseColumn(input);
        assertThat(result, notNullValue());
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) Timestamp(java.sql.Timestamp) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

UncheckedAutoCloseable (com.cadenzauk.core.lang.UncheckedAutoCloseable)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)22 MethodSource (org.junit.jupiter.params.provider.MethodSource)16 ZonedDateTime (java.time.ZonedDateTime)10 TestDatabase.testDatabase (com.cadenzauk.siesta.model.TestDatabase.testDatabase)9 Timestamp (java.sql.Timestamp)7 TestCase (com.cadenzauk.core.junit.TestCase)6 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)6 RandomValues.randomLocalDateTime (com.cadenzauk.core.RandomValues.randomLocalDateTime)5 AnsiDialect (com.cadenzauk.siesta.dialect.AnsiDialect)5 LocalDate (java.time.LocalDate)5 LocalDateTime (java.time.LocalDateTime)5 RandomValues.randomZonedDateTime (com.cadenzauk.core.RandomValues.randomZonedDateTime)3 TestRow (com.cadenzauk.siesta.model.TestRow)3 RandomValues.randomLocalDate (com.cadenzauk.core.RandomValues.randomLocalDate)2 RandomValues.randomLocalTime (com.cadenzauk.core.RandomValues.randomLocalTime)2 Date (java.sql.Date)2 LocalTime (java.time.LocalTime)2 ZoneId (java.time.ZoneId)1