HHH-12754 - Fix broken envers tests on other database platforms.

This commit is contained in:
Chris Cranford 2018-07-03 12:09:26 -04:00
parent 58613cba73
commit 6dea02bac5
7 changed files with 40 additions and 55 deletions

View File

@ -7,7 +7,6 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -17,7 +16,6 @@ import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OrderColumn;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -104,15 +102,15 @@ public class ListEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 6 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 6 ), results );
} );
}
}

View File

@ -7,7 +7,6 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@ -16,7 +15,6 @@ import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OrderColumn;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -103,15 +101,15 @@ public class ListNoEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 6 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 6 ), results );
} );
}
}

View File

@ -7,9 +7,7 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -17,7 +15,6 @@ import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -119,15 +116,15 @@ public class MapEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 4 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 4 ), results );
} );
}
}

View File

@ -7,16 +7,13 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -116,15 +113,15 @@ public class MapNoEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 4 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 4 ), results );
} );
}
}

View File

@ -7,9 +7,7 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@ -17,7 +15,6 @@ import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -123,15 +120,15 @@ public class SetEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 4 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 4 ), results );
} );
}
}

View File

@ -7,18 +7,13 @@
package org.hibernate.envers.test.integration.collection.embeddable;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Tuple;
import org.hibernate.envers.Audited;
import org.hibernate.envers.strategy.ValidityAuditStrategy;
@ -127,15 +122,15 @@ public class SetNoEqualsHashCodeTest extends BaseEnversJPAFunctionalTestCase {
public void testAuditRowsForDefaultAuditStrategy() {
if ( !ValidityAuditStrategy.class.getName().equals( getAuditStrategy() ) ) {
doInJPA( this::entityManagerFactory, entityManager -> {
List<Tuple> results = entityManager
.createNativeQuery(
Long results = entityManager
.createQuery(
"SELECT COUNT(1) FROM TestEntity_embs1_AUD",
Tuple.class
Long.class
)
.getResultList();
.getSingleResult();
assertEquals( 1, results.size() );
assertEquals( BigInteger.valueOf( 4 ), results.get( 0 ).get( 0 ) );
assertNotNull( results );
assertEquals( Long.valueOf( 4 ), results );
} );
}
}

View File

@ -15,6 +15,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.envers.test.BaseEnversFunctionalTestCase;
import org.hibernate.envers.test.Priority;
import org.hibernate.envers.test.entities.customtype.UnspecifiedEnumTypeEntity;
import org.hibernate.type.IntegerType;
import org.junit.Assert;
import org.junit.Test;
@ -103,7 +104,9 @@ public class UnspecifiedEnumTypeTest extends BaseEnversFunctionalTestCase {
@SuppressWarnings("unchecked")
List<Object[]> values = session
.createSQLQuery( "SELECT enum1, enum2 FROM ENUM_ENTITY_AUD ORDER BY rev ASC" )
.createNativeQuery( "SELECT enum1 e1, enum2 e2 FROM ENUM_ENTITY_AUD ORDER BY rev ASC" )
.addScalar( "e1", IntegerType.INSTANCE )
.addScalar( "e2", IntegerType.INSTANCE )
.list();
session.close();