Search in sources :

Example 1 with RandomValues.randomLocalDate

use of com.cadenzauk.core.RandomValues.randomLocalDate in project siesta by cadenzauk.

the class DataTypeTest method toDatabaseLocalDate.

@ParameterizedTest
@MethodSource("timeZones")
void toDatabaseLocalDate(String timeZone) {
    try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
        LocalDate input = RandomValues.randomLocalDate();
        Date expected = Date.valueOf(input);
        when(db.dialect()).thenReturn(new AnsiDialect());
        Object result = DataType.LOCAL_DATE.toDatabase(db, input);
        assertThat(result, is(expected));
    }
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) RandomValues.randomLocalDate(com.cadenzauk.core.RandomValues.randomLocalDate) LocalDate(java.time.LocalDate) Date(java.sql.Date) RandomValues.randomLocalDate(com.cadenzauk.core.RandomValues.randomLocalDate) LocalDate(java.time.LocalDate) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

RandomValues.randomLocalDate (com.cadenzauk.core.RandomValues.randomLocalDate)1 UncheckedAutoCloseable (com.cadenzauk.core.lang.UncheckedAutoCloseable)1 AnsiDialect (com.cadenzauk.siesta.dialect.AnsiDialect)1 Date (java.sql.Date)1 LocalDate (java.time.LocalDate)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1