Search in sources :

Example 46 with ParameterizedTest

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);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 47 with ParameterizedTest

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));
}
Also used : TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 48 with ParameterizedTest

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));
    }
}
Also used : LocalTime(java.time.LocalTime) RandomValues.randomLocalTime(com.cadenzauk.core.RandomValues.randomLocalTime) TestRow(com.cadenzauk.siesta.model.TestRow) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) TestCase(com.cadenzauk.core.junit.TestCase) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 49 with ParameterizedTest

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));
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) RandomValues.randomZonedDateTime(com.cadenzauk.core.RandomValues.randomZonedDateTime) TestRow(com.cadenzauk.siesta.model.TestRow) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) TestCase(com.cadenzauk.core.junit.TestCase) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 50 with ParameterizedTest

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));
    }
}
Also used : LocalTime(java.time.LocalTime) RandomValues.randomLocalTime(com.cadenzauk.core.RandomValues.randomLocalTime) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2045 MethodSource (org.junit.jupiter.params.provider.MethodSource)1116 EnumSource (org.junit.jupiter.params.provider.EnumSource)325 ValueSource (org.junit.jupiter.params.provider.ValueSource)302 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 CsvSource (org.junit.jupiter.params.provider.CsvSource)113 ArrayList (java.util.ArrayList)112 ByteBuffer (java.nio.ByteBuffer)81 List (java.util.List)81 Path (java.nio.file.Path)75 Test (org.junit.jupiter.api.Test)74 InterruptAfter (io.aeron.test.InterruptAfter)72 IOException (java.io.IOException)72 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 TimeUnit (java.util.concurrent.TimeUnit)65 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)62 CountDownLatch (java.util.concurrent.CountDownLatch)61 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)60 Stream (java.util.stream.Stream)59