use of com.cadenzauk.core.junit.TestCase in project siesta by cadenzauk.
the class MethodUtilTest method annotationsMultiple.
@Test
void annotationsMultiple() {
Method method = MethodUtil.fromReference(TestDerivedClass.class, TestClass::method2);
Stream<TestCase> annotations = MethodUtil.annotations(TestCase.class, method);
assertThat(annotations.count(), is(3L));
}
use of com.cadenzauk.core.junit.TestCase 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 com.cadenzauk.core.junit.TestCase 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 com.cadenzauk.core.junit.TestCase in project siesta by cadenzauk.
the class DatabaseIntegrationTest method currentTimestampLocalTest.
@ParameterizedTest
@ArgumentsSource(TestCaseArgumentsProvider.class)
@TestCase({ "America/Anchorage" })
@TestCase({ "America/Sao_Paulo" })
@TestCase({ "UTC" })
@TestCase({ "Europe/London" })
@TestCase({ "Africa/Johannesburg" })
@TestCase({ "Pacific/Chatham" })
void currentTimestampLocalTest(String timeZone) {
Database database = testDatabase(dataSource, dialect);
try (UncheckedAutoCloseable ignored = TemporalTestUtil.withTimeZone(timeZone)) {
LocalDateTime before = LocalDateTime.now(database.databaseTimeZone()).minusSeconds(10);
LocalDateTime now = database.select(currentTimestampLocal()).single();
LocalDateTime after = LocalDateTime.now(database.databaseTimeZone()).plusSeconds(10);
System.out.printf("%s <= %s <= %s%n", before, now, after);
assertThat(before.isAfter(now), is(false));
assertThat(now.isAfter(after), is(false));
}
}
use of com.cadenzauk.core.junit.TestCase in project siesta by cadenzauk.
the class DatabaseIntegrationTest method currentDateTest.
@ParameterizedTest
@ArgumentsSource(TestCaseArgumentsProvider.class)
@TestCase({ "America/Anchorage" })
@TestCase({ "America/Sao_Paulo" })
@TestCase({ "UTC" })
@TestCase({ "Europe/London" })
@TestCase({ "Africa/Johannesburg" })
@TestCase({ "Pacific/Chatham" })
void currentDateTest(String timeZone) {
Database database = testDatabase(dataSource, dialect);
try (UncheckedAutoCloseable ignored = TemporalTestUtil.withTimeZone(timeZone)) {
LocalDate before = LocalDate.now(database.databaseTimeZone());
LocalDate now = database.select(currentDate()).single();
LocalDate after = LocalDate.now(database.databaseTimeZone());
System.out.printf("%s <= %s <= %s%n", before, now, after);
assertThat(before.isAfter(now), is(false));
assertThat(now.isAfter(after), is(false));
}
}
Aggregations