HHH-17576 fix tests to not demand that fractional seconds are stored for Times

This commit is contained in:
Gavin King 2024-09-10 00:46:48 +02:00
parent 6d64e854e2
commit 4a4c55f830
5 changed files with 10 additions and 8 deletions

View File

@ -35,8 +35,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
) )
public class LocalTimeTest { public class LocalTimeTest {
private static final LocalTime LOCAL_TIME = DateTimeUtils.adjustToDefaultPrecision( private static final LocalTime LOCAL_TIME = DateTimeUtils.adjustToPrecision(
LocalTime.now(), LocalTime.now(), 0,
DialectContext.getDialect() DialectContext.getDialect()
); );

View File

@ -45,6 +45,7 @@ import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision; import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToPrecision;
/** /**
* Tests for "direct" JDBC handling of {@linkplain java.time Java Time} types. * Tests for "direct" JDBC handling of {@linkplain java.time Java Time} types.
@ -177,7 +178,7 @@ public class GlobalJavaTimeJdbcTypeTests {
@SkipForDialect(dialectClass = AltibaseDialect.class, reason = "Altibase drivers truncate fractional seconds from the LocalTime") @SkipForDialect(dialectClass = AltibaseDialect.class, reason = "Altibase drivers truncate fractional seconds from the LocalTime")
void testLocalTime(SessionFactoryScope scope) { void testLocalTime(SessionFactoryScope scope) {
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
final LocalTime startTime = adjustToDefaultPrecision( LocalTime.now(), dialect ); final LocalTime startTime = adjustToPrecision( LocalTime.now(), 0, dialect );
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {
final EntityWithJavaTimeValues entity = new EntityWithJavaTimeValues(); final EntityWithJavaTimeValues entity = new EntityWithJavaTimeValues();

View File

@ -46,6 +46,7 @@ import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision; import static org.hibernate.type.descriptor.DateTimeUtils.adjustToDefaultPrecision;
import static org.hibernate.type.descriptor.DateTimeUtils.adjustToPrecision;
/** /**
* Tests for "direct" JDBC handling of {@linkplain java.time Java Time} types. * Tests for "direct" JDBC handling of {@linkplain java.time Java Time} types.
@ -178,7 +179,7 @@ public class JavaTimeJdbcTypeTests {
@SkipForDialect(dialectClass = AltibaseDialect.class, reason = "Altibase drivers truncate fractional seconds from the LocalTime") @SkipForDialect(dialectClass = AltibaseDialect.class, reason = "Altibase drivers truncate fractional seconds from the LocalTime")
void testLocalTime(SessionFactoryScope scope) { void testLocalTime(SessionFactoryScope scope) {
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect(); final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
final LocalTime startTime = adjustToDefaultPrecision( LocalTime.now(), dialect ); final LocalTime startTime = adjustToPrecision( LocalTime.now(), 0, dialect );
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {
final EntityWithJavaTimeValues entity = new EntityWithJavaTimeValues(); final EntityWithJavaTimeValues entity = new EntityWithJavaTimeValues();

View File

@ -63,9 +63,9 @@ public class FractionalSecondsTests {
final PersistentClass entityBinding = scope.getEntityBinding( TestEntity.class ); final PersistentClass entityBinding = scope.getEntityBinding( TestEntity.class );
checkPrecision( "theInstant", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theInstant", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theLocalDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theLocalDateTime", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theLocalTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theLocalTime", 0, entityBinding, domainModel );
checkPrecision( "theOffsetDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theOffsetDateTime", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theOffsetTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theOffsetTime", 0, entityBinding, domainModel );
checkPrecision( "theZonedDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theZonedDateTime", defaultPrecision, entityBinding, domainModel );
final PersistentClass entityBinding0 = scope.getEntityBinding( TestEntity0.class ); final PersistentClass entityBinding0 = scope.getEntityBinding( TestEntity0.class );

View File

@ -65,9 +65,9 @@ public class JavaTimeFractionalSecondsTests {
final PersistentClass entityBinding = scope.getEntityBinding( TestEntity.class ); final PersistentClass entityBinding = scope.getEntityBinding( TestEntity.class );
checkPrecision( "theInstant", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theInstant", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theLocalDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theLocalDateTime", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theLocalTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theLocalTime", 0, entityBinding, domainModel );
checkPrecision( "theOffsetDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theOffsetDateTime", defaultPrecision, entityBinding, domainModel );
checkPrecision( "theOffsetTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theOffsetTime", 0, entityBinding, domainModel );
checkPrecision( "theZonedDateTime", defaultPrecision, entityBinding, domainModel ); checkPrecision( "theZonedDateTime", defaultPrecision, entityBinding, domainModel );
final PersistentClass entityBinding0 = scope.getEntityBinding( TestEntity0.class ); final PersistentClass entityBinding0 = scope.getEntityBinding( TestEntity0.class );