use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class ZonedDateTimeConverterTest method convertToDatabaseColumnPreGregorianShouldThrow.
@ParameterizedTest
@MethodSource("timezones")
void convertToDatabaseColumnPreGregorianShouldThrow(String timeZone) {
ZonedDateTime input = ZonedDateTime.of(LocalDateUtil.START_OF_GREGORIAN_CALENDAR, LocalTime.MIN, ZoneId.of(timeZone)).minusNanos(1);
try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
ZonedDateTimeConverter sut = new ZonedDateTimeConverter(ZoneId.of(timeZone));
calling(() -> sut.convertToDatabaseColumn(input)).shouldThrow(IllegalArgumentException.class);
}
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class DatabaseIntegrationTest method castExpression.
@ParameterizedTest
@MethodSource("parametersForCastExpression")
<T> void castExpression(TypedExpression<T> castExpr, T expectedResult) {
Database database = testDatabase(dataSource, dialect);
T result = database.select(castExpr).single();
assertThat(result, is(expectedResult));
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class DatabaseIntegrationTest method canRoundTripLocalTimes.
@ParameterizedTest
@ArgumentsSource(TestCaseArgumentsProvider.class)
@TestCase({ "America/Anchorage" })
@TestCase({ "America/Sao_Paulo" })
@TestCase({ "UTC" })
@TestCase({ "Europe/London" })
@TestCase({ "Africa/Johannesburg" })
@TestCase({ "Pacific/Chatham" })
void canRoundTripLocalTimes(String timeZone) {
Database database = testDatabase(dataSource, dialect);
try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
LocalTime expected = randomLocalTime();
TestRow input = TestRow.of(expected);
database.insert(input);
LocalTime result = database.from(TestRow.class).select(TestRow::localTimeOpt).where(TestRow::guid).isEqualTo(input.guid()).single();
assertThat(result, is(expected));
}
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class DatabaseIntegrationTest method canRoundTripZonedDateTimes.
@ParameterizedTest
@ArgumentsSource(TestCaseArgumentsProvider.class)
@TestCase({ "America/Anchorage" })
@TestCase({ "America/Sao_Paulo" })
@TestCase({ "UTC" })
@TestCase({ "Europe/London" })
@TestCase({ "Africa/Johannesburg" })
@TestCase({ "Pacific/Chatham" })
void canRoundTripZonedDateTimes(String timeZone) {
Database database = testDatabase(dataSource, dialect);
try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
ZonedDateTime expected = randomZonedDateTime(ZoneId.of("UTC"));
TestRow input = TestRow.of(expected);
database.insert(input);
ZonedDateTime result = database.from(TestRow.class).select(TestRow::utcDateTimeOpt).where(TestRow::guid).isEqualTo(input.guid()).single();
assertThat(result, is(expected));
}
}
use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.
the class DatabaseIntegrationTest method localTimeiteral.
@SuppressWarnings("UnnecessaryLocalVariable")
@ParameterizedTest
@MethodSource("parametersForLocalTimeLiteral")
void localTimeiteral(String timeZone, LocalTime value) {
Database database = testDatabase(dataSource, dialect);
try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
LocalTime expected = value;
LocalTime result = database.select(literal(value)).single();
assertThat(result, is(expected));
}
}
Aggregations