HHH-17460 - Ongoing JPA 32 work
This commit is contained in:
parent
894a182798
commit
7659c79f7a
|
@ -1,5 +1,6 @@
|
|||
package org.hibernate.orm.test.timezones;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
|
@ -53,13 +54,17 @@ public class AutoZonedTest {
|
|||
scope.inSession( s -> {
|
||||
Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() );
|
||||
assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() );
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.hibernate.orm.test.timezones;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
|
@ -53,13 +54,17 @@ public class ColumnZonedTest {
|
|||
scope.inSession( s -> {
|
||||
Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() );
|
||||
assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() );
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.hibernate.orm.test.timezones;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
|
@ -50,13 +51,17 @@ public class DefaultZonedTest {
|
|||
scope.inSession( s -> {
|
||||
Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
if ( dialect.getTimeZoneSupport() == TimeZoneSupport.NATIVE ) {
|
||||
assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() );
|
||||
|
|
|
@ -57,13 +57,17 @@ public class JDBCTimeZoneZonedTest {
|
|||
ZoneId systemZone = ZoneId.systemDefault();
|
||||
ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() );
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
assertEquals( systemZone, z.zonedDateTime.getZone() );
|
||||
assertEquals( systemOffset, z.offsetDateTime.getOffset() );
|
||||
|
|
|
@ -56,13 +56,17 @@ public class PassThruZonedTest {
|
|||
ZoneId systemZone = ZoneId.systemDefault();
|
||||
ZoneOffset systemOffset = systemZone.getRules().getOffset( Instant.now() );
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
assertEquals( systemZone, z.zonedDateTime.getZone() );
|
||||
assertEquals( systemOffset, z.offsetDateTime.getOffset() );
|
||||
|
|
|
@ -46,12 +46,12 @@ public class UTCNormalizedInstantTest {
|
|||
final Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( z.utcInstant, dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( instant, dialect )
|
||||
DateTimeUtils.adjustToDefaultPrecision( z.utcInstant, dialect ),
|
||||
DateTimeUtils.adjustToDefaultPrecision( instant, dialect )
|
||||
);
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( z.localInstant, dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( instant, dialect )
|
||||
DateTimeUtils.adjustToDefaultPrecision( z.localInstant, dialect ),
|
||||
DateTimeUtils.adjustToDefaultPrecision( instant, dialect )
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -79,13 +79,16 @@ public class UTCNormalizedInstantTest {
|
|||
scope.inSession( s-> {
|
||||
final Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( z.utcInstant, dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( instant, dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( z.utcInstant, dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( instant, dialect )
|
||||
);
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( z.localInstant, dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( instant, dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( z.localInstant, dialect );
|
||||
assertEquals(
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.hibernate.orm.test.timezones;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
|
@ -53,13 +54,17 @@ public class UTCNormalizedZonedTest {
|
|||
scope.inSession( s-> {
|
||||
Zoned z = s.find(Zoned.class, id);
|
||||
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
|
||||
Instant expected = DateTimeUtils.adjustToDefaultPrecision( nowZoned.toInstant(), dialect );
|
||||
Instant actual = DateTimeUtils.adjustToDefaultPrecision( z.zonedDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
expected = DateTimeUtils.adjustToDefaultPrecision( nowOffset.toInstant(), dialect );
|
||||
actual = DateTimeUtils.adjustToDefaultPrecision( z.offsetDateTime.toInstant(), dialect );
|
||||
assertEquals(
|
||||
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
|
||||
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
assertEquals( ZoneId.of("Z"), z.zonedDateTime.getZone() );
|
||||
assertEquals( ZoneOffset.ofHours(0), z.offsetDateTime.getOffset() );
|
||||
|
|
Loading…
Reference in New Issue