Search in sources :

Example 41 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class DataTypeTest method getZonedDateTime.

@ParameterizedTest
@MethodSource("timeZones")
void getZonedDateTime(String timeZone) throws SQLException {
    ZonedDateTime expected = ZonedDateTime.of(randomLocalDateTime(), ZoneId.of("UTC"));
    Timestamp returnVal = Timestamp.from(expected.toInstant());
    when(rs.getTimestamp(eq("someColumn"), any())).thenReturn(returnVal);
    when(db.databaseTimeZone()).thenReturn(ZoneId.of(timeZone));
    when(db.dialect()).thenReturn(new AnsiDialect());
    Optional<ZonedDateTime> result = DataType.ZONED_DATE_TIME.get(rs, "someColumn", db);
    assertThat(result, is(Optional.of(expected)));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) ZonedDateTime(java.time.ZonedDateTime) Timestamp(java.sql.Timestamp) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 42 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class DataTypeTest method toDatabaseZonedDateTime.

@ParameterizedTest
@MethodSource("timeZonePairs")
void toDatabaseZonedDateTime(String dbTimeZone, String jvmTimeZone) {
    ZoneId dbZone = ZoneId.of(dbTimeZone);
    ZoneId jvmZone = ZoneId.of(jvmTimeZone);
    ZonedDateTime input = RandomValues.randomZonedDateTime(jvmZone);
    try (UncheckedAutoCloseable ignored = withTimeZone(jvmTimeZone)) {
        ZonedDateTime dbTime = input.withZoneSameInstant(dbZone);
        Timestamp expected = Timestamp.valueOf(dbTime.toLocalDateTime());
        when(db.databaseTimeZone()).thenReturn(dbZone);
        when(db.dialect()).thenReturn(new AnsiDialect());
        Object result = DataType.ZONED_DATE_TIME.toDatabase(db, input);
        assertThat(result, is(expected));
    }
}
Also used : ZoneId(java.time.ZoneId) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) 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 43 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class TypeUtilTest method primitiveComponentType.

@ParameterizedTest
@MethodSource("parametersForPrimitiveComponentType")
void primitiveComponentType(Class<?> array, Class<?> expected) {
    Type result = TypeUtil.primitiveComponentType(array);
    assertThat(result, equalTo(expected));
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 44 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class LocalDateConverterTest method convertToDatabaseColumn.

@ParameterizedTest
@MethodSource("parameters")
void convertToDatabaseColumn(String timeZone, LocalDate input, Date expected) {
    try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
        LocalDateConverter sut = new LocalDateConverter();
        Date actual = sut.convertToDatabaseColumn(input);
        assertThat(actual, is(expected));
    }
}
Also used : UncheckedAutoCloseable(com.cadenzauk.core.lang.UncheckedAutoCloseable) Date(java.sql.Date) LocalDate(java.time.LocalDate) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 45 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class ZonedDateTimeConverterTest method convertToDatabaseColumn.

@ParameterizedTest
@MethodSource("parameters")
void convertToDatabaseColumn(String timeZone, LocalDate local) {
    ZonedDateTime input = zonedDateTime(timeZone, local);
    Timestamp expected = timestamp(timeZone, local);
    try (UncheckedAutoCloseable ignored = withTimeZone(timeZone)) {
        ZonedDateTimeConverter sut = new ZonedDateTimeConverter(ZoneId.of(timeZone));
        Timestamp actual = sut.convertToDatabaseColumn(input);
        assertThat(actual, is(expected));
    }
}
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

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1880 MethodSource (org.junit.jupiter.params.provider.MethodSource)1020 EnumSource (org.junit.jupiter.params.provider.EnumSource)321 ValueSource (org.junit.jupiter.params.provider.ValueSource)270 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 ArrayList (java.util.ArrayList)97 ByteBuffer (java.nio.ByteBuffer)78 CsvSource (org.junit.jupiter.params.provider.CsvSource)78 Path (java.nio.file.Path)71 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 IOException (java.io.IOException)65 List (java.util.List)59 Test (org.junit.jupiter.api.Test)58 HashMap (java.util.HashMap)55 Map (java.util.Map)54 HashSet (java.util.HashSet)52 lombok.val (lombok.val)52 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)50 TimeUnit (java.util.concurrent.TimeUnit)48