From 6e1fe9374b66770e9f684c0d4bd76ab7c8aa4fd3 Mon Sep 17 00:00:00 2001 From: Florian Heck Date: Thu, 18 Apr 2024 16:56:09 +0200 Subject: [PATCH] HHH-17975 add testcase for retrieving revision by an Instant --- .../integration/revfordate/RevisionForDate.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/revfordate/RevisionForDate.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/revfordate/RevisionForDate.java index 208c2dd52d..1dfa239985 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/revfordate/RevisionForDate.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/revfordate/RevisionForDate.java @@ -121,4 +121,20 @@ public class RevisionForDate extends BaseEnversJPAFunctionalTestCase { assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp4 ) ) ).getTime() <= timestamp4; } + + @Test + @SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size") + public void testRevisionsForInstant() { + AuditReader vr = getAuditReader(); + + assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp2 ).toInstant() ) ).getTime() <= timestamp2; + assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp2 ).toInstant() ).intValue() + 1 ) + .getTime() > timestamp2; + + assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp3 ).toInstant() ) ).getTime() <= timestamp3; + assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp3 ).toInstant() ).intValue() + 1 ) + .getTime() > timestamp3; + + assert vr.getRevisionDate( vr.getRevisionNumberForDate( new Date( timestamp4 ).toInstant() ) ).getTime() <= timestamp4; + } }