HHH-11896 Fix test to be deterministic

This commit is contained in:
Chris Cranford 2021-12-16 20:41:54 -05:00 committed by Chris Cranford
parent 3e3d227c9a
commit 2e8d16efca
2 changed files with 8 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import jakarta.persistence.criteria.JoinType;
import org.hibernate.envers.AuditJoinTable; import org.hibernate.envers.AuditJoinTable;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.hibernate.envers.query.AuditEntity; import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.query.order.NullPrecedence;
import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase;
import org.hibernate.orm.test.envers.Priority; import org.hibernate.orm.test.envers.Priority;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -182,7 +183,7 @@ public class AssociationQueryWithOnClauseTest extends BaseEnversJPAFunctionalTes
List list = getAuditReader().createQuery() List list = getAuditReader().createQuery()
.forEntitiesAtRevision( EntityA.class, 1 ) .forEntitiesAtRevision( EntityA.class, 1 )
.traverseRelation( "bManyToOne", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) ) .traverseRelation( "bManyToOne", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) )
.addOrder( AuditEntity.property( "b", "number" ).asc() ) .addOrder( AuditEntity.property( "b", "number" ).asc().nulls( NullPrecedence.FIRST ) )
.up() .up()
.addProjection( AuditEntity.id() ) .addProjection( AuditEntity.id() )
.addProjection( AuditEntity.property( "b", "number" ) ) .addProjection( AuditEntity.property( "b", "number" ) )
@ -194,7 +195,7 @@ public class AssociationQueryWithOnClauseTest extends BaseEnversJPAFunctionalTes
public void testOneToMany() { public void testOneToMany() {
List list = getAuditReader().createQuery().forEntitiesAtRevision( EntityA.class, 1 ) List list = getAuditReader().createQuery().forEntitiesAtRevision( EntityA.class, 1 )
.traverseRelation( "bOneToMany", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) ) .traverseRelation( "bOneToMany", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) )
.addOrder( AuditEntity.property( "b", "number" ).asc() ) .addOrder( AuditEntity.property( "b", "number" ).asc().nulls( NullPrecedence.FIRST ) )
.up() .up()
.addOrder( AuditEntity.id().asc() ) .addOrder( AuditEntity.id().asc() )
.addProjection( AuditEntity.id() ) .addProjection( AuditEntity.id() )
@ -208,9 +209,10 @@ public class AssociationQueryWithOnClauseTest extends BaseEnversJPAFunctionalTes
List list = getAuditReader().createQuery() List list = getAuditReader().createQuery()
.forEntitiesAtRevision( EntityA.class, 1 ) .forEntitiesAtRevision( EntityA.class, 1 )
.traverseRelation( "bManyToMany", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) ) .traverseRelation( "bManyToMany", JoinType.LEFT, "b", AuditEntity.property( "b", "type" ).eq( "T1" ) )
.addOrder( AuditEntity.property( "b", "number" ).asc() ) .addOrder( AuditEntity.property( "b", "number" ).asc().nulls( NullPrecedence.FIRST ) )
.up() .up()
.addOrder( AuditEntity.id().asc() ).addProjection( AuditEntity.id() ) .addOrder( AuditEntity.id().asc().nulls( NullPrecedence.FIRST ) )
.addProjection(AuditEntity.id() )
.addProjection( AuditEntity.property( "b", "number" ) ) .addProjection( AuditEntity.property( "b", "number" ) )
.getResultList(); .getResultList();
assertArrayListEquals( list, tuple( a1.getId(), null ), tuple( a1.getId(), 1 ), tuple( a2.getId(), 3 ), tuple( a3.getId(), 3 ) ); assertArrayListEquals( list, tuple( a1.getId(), null ), tuple( a1.getId(), 1 ), tuple( a2.getId(), 3 ), tuple( a3.getId(), 3 ) );

View File

@ -341,7 +341,7 @@ public class ComponentQueryTest extends BaseEnversJPAFunctionalTestCase {
.forEntitiesAtRevision( Asset.class, 1 ) .forEntitiesAtRevision( Asset.class, 1 )
.addProjection( AuditEntity.id() ) .addProjection( AuditEntity.id() )
.traverseRelation( "singleSymbol", JoinType.LEFT, "s", AuditEntity.property( "s", "type" ).eq( type1 ) ) .traverseRelation( "singleSymbol", JoinType.LEFT, "s", AuditEntity.property( "s", "type" ).eq( type1 ) )
.addOrder( AuditEntity.property( "s", "identifier" ).asc() ) .addOrder( AuditEntity.property( "s", "identifier" ).asc().nulls( NullPrecedence.FIRST ) )
.up() .up()
.addOrder( AuditEntity.id().asc() ) .addOrder( AuditEntity.id().asc() )
.getResultList(); .getResultList();
@ -357,7 +357,7 @@ public class ComponentQueryTest extends BaseEnversJPAFunctionalTestCase {
.forEntitiesAtRevision( Asset.class, 1 ) .forEntitiesAtRevision( Asset.class, 1 )
.addProjection( AuditEntity.id() ) .addProjection( AuditEntity.id() )
.traverseRelation( "multiSymbols", JoinType.LEFT, "s", AuditEntity.property( "s", "type" ).eq( type1 ) ) .traverseRelation( "multiSymbols", JoinType.LEFT, "s", AuditEntity.property( "s", "type" ).eq( type1 ) )
.addOrder( AuditEntity.property( "s", "identifier" ).asc() ) .addOrder( AuditEntity.property( "s", "identifier" ).asc().nulls( NullPrecedence.FIRST ) )
.up() .up()
.addOrder( AuditEntity.id().asc() ) .addOrder( AuditEntity.id().asc() )
.getResultList(); .getResultList();