HHH-5845 - Collection proxy of deleted state

This commit is contained in:
Lukasz Antoniak 2013-08-02 12:37:20 +02:00
parent f99e1e4b4a
commit bf11088e70
26 changed files with 421 additions and 281 deletions

View File

@ -73,7 +73,7 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen
final QueryBuilder validQuery = commonPart.deepCopy();
final QueryBuilder removedQuery = commonPart.deepCopy();
createValidDataRestrictions(
globalCfg, auditStrategy, referencedIdData, validQuery, validQuery.getRootParameters(), true
globalCfg, auditStrategy, referencedIdData, validQuery, validQuery.getRootParameters()
);
createValidAndRemovedDataRestrictions( globalCfg, auditStrategy, referencedIdData, removedQuery );
@ -99,8 +99,7 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen
*/
private void createValidDataRestrictions(
GlobalConfiguration globalCfg, AuditStrategy auditStrategy,
MiddleIdData referencedIdData, QueryBuilder qb, Parameters rootParameters,
boolean inclusive) {
MiddleIdData referencedIdData, QueryBuilder qb, Parameters rootParameters) {
final String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
// (selecting e entities at revision :revision)
// --> based on auditStrategy (see above)
@ -108,7 +107,7 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen
globalCfg, qb, rootParameters, revisionPropertyPath,
verEntCfg.getRevisionEndFieldName(), true, referencedIdData, revisionPropertyPath,
verEntCfg.getOriginalIdPropName(), REFERENCED_ENTITY_ALIAS, REFERENCED_ENTITY_ALIAS_DEF_AUD_STR,
inclusive
true
);
// e.revision_type != DEL
rootParameters.addWhereWithNamedParam( getRevisionTypePath(), false, "!=", DEL_REVISION_TYPE_PARAMETER );
@ -126,7 +125,7 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen
// Restrictions to match all rows deleted at exactly given revision.
final Parameters removed = disjoint.addSubParameters( "and" );
// Excluding current revision, because we need to match data valid at the previous one.
createValidDataRestrictions( globalCfg, auditStrategy, referencedIdData, remQb, valid, false );
createValidDataRestrictions( globalCfg, auditStrategy, referencedIdData, remQb, valid );
// e.revision = :revision
removed.addWhereWithNamedParam( verEntCfg.getRevisionNumberPath(), false, "=", REVISION_PARAMETER );
// e.revision_type = DEL

View File

@ -180,7 +180,7 @@ public final class ThreeEntityQueryGenerator extends AbstractRelationQueryGenera
originalIdPropertyName,
REFERENCED_ENTITY_ALIAS,
REFERENCED_ENTITY_ALIAS_DEF_AUD_STR,
inclusive
true
);
// (selecting f entities at revision :revision)
// --> based on auditStrategy (see above)
@ -188,15 +188,15 @@ public final class ThreeEntityQueryGenerator extends AbstractRelationQueryGenera
globalCfg,
qb,
rootParameters,
REFERENCED_ENTITY_ALIAS + "." + revisionPropertyPath,
REFERENCED_ENTITY_ALIAS + "." + verEntCfg.getRevisionEndFieldName(),
INDEX_ENTITY_ALIAS + "." + revisionPropertyPath,
INDEX_ENTITY_ALIAS + "." + verEntCfg.getRevisionEndFieldName(),
false,
referencedIdData,
revisionPropertyPath,
originalIdPropertyName,
INDEX_ENTITY_ALIAS,
INDEX_ENTITY_ALIAS_DEF_AUD_STR,
inclusive
true
);
// (with ee association at revision :revision)
// --> based on auditStrategy (see above)

View File

@ -152,7 +152,7 @@ public final class TwoEntityQueryGenerator extends AbstractRelationQueryGenerato
originalIdPropertyName,
REFERENCED_ENTITY_ALIAS,
REFERENCED_ENTITY_ALIAS_DEF_AUD_STR,
inclusive
true
);
// (with ee association at revision :revision)
// --> based on auditStrategy (see above)

View File

@ -58,9 +58,9 @@ public class CollectionRefIngEntity implements Serializable {
this.reference = reference;
}
public CollectionRefIngEntity(String data, CollectionRefEdEntity reference) {
public CollectionRefIngEntity(Integer id, String data) {
this.id = id;
this.data = data;
this.reference = reference;
}
public Integer getId() {

View File

@ -106,7 +106,6 @@ public class NotOwnedBidirectional extends BaseEnversJPAFunctionalTestCase {
@Test
public void testHistoryOfPersonalContact() {
System.out.println( getAuditReader().find( PersonalContact.class, pc_id, 1 ).getAddresses() );
assert getAuditReader().find( PersonalContact.class, pc_id, 1 ).getAddresses().equals(
TestTools.makeSet( new Address( a1_id, "a1" ) )
);

View File

@ -106,7 +106,6 @@ public class NotOwnedBidirectional extends BaseEnversJPAFunctionalTestCase {
@Test
public void testHistoryOfPersonalContact() {
System.out.println( getAuditReader().find( PersonalContact.class, pc_id, 1 ).getAddresses() );
assert getAuditReader().find( PersonalContact.class, pc_id, 1 ).getAddresses().equals(
TestTools.makeSet( new Address( a1_id, "a1" ) )
);

View File

@ -156,10 +156,10 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListOwnedEntity rev5 = getAuditReader().find( ListOwnedEntity.class, ed1_id, 5 );
assert rev1.getReferencing().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferencing(), ing1, ing2 );
assert TestTools.checkList( rev3.getReferencing(), ing1, ing2 );
assert TestTools.checkList( rev4.getReferencing(), ing2 );
assert TestTools.checkList( rev5.getReferencing(), ing2 );
assert TestTools.checkCollection( rev2.getReferencing(), ing1, ing2 );
assert TestTools.checkCollection( rev3.getReferencing(), ing1, ing2 );
assert TestTools.checkCollection( rev4.getReferencing(), ing2 );
assert TestTools.checkCollection( rev5.getReferencing(), ing2 );
}
@Test
@ -174,10 +174,10 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListOwnedEntity rev5 = getAuditReader().find( ListOwnedEntity.class, ed2_id, 5 );
assert rev1.getReferencing().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferencing(), ing2 );
assert TestTools.checkList( rev3.getReferencing(), ing1, ing2 );
assert TestTools.checkList( rev4.getReferencing(), ing1, ing2 );
assert TestTools.checkList( rev5.getReferencing(), ing2 );
assert TestTools.checkCollection( rev2.getReferencing(), ing2 );
assert TestTools.checkCollection( rev3.getReferencing(), ing1, ing2 );
assert TestTools.checkCollection( rev4.getReferencing(), ing1, ing2 );
assert TestTools.checkCollection( rev5.getReferencing(), ing2 );
}
@Test
@ -192,9 +192,9 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListOwningEntity rev5 = getAuditReader().find( ListOwningEntity.class, ing1_id, 5 );
assert rev1.getReferences().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferences(), ed1 );
assert TestTools.checkList( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev4.getReferences(), ed2 );
assert TestTools.checkCollection( rev2.getReferences(), ed1 );
assert TestTools.checkCollection( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev4.getReferences(), ed2 );
assert rev5.getReferences().equals( Collections.EMPTY_LIST );
}
@ -210,9 +210,9 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListOwningEntity rev5 = getAuditReader().find( ListOwningEntity.class, ing2_id, 5 );
assert rev1.getReferences().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev4.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev5.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev2.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev4.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev5.getReferences(), ed1, ed2 );
}
}

View File

@ -150,16 +150,16 @@ public class BasicWhereJoinTable extends BaseEnversJPAFunctionalTestCase {
WhereJoinTableEntity rev4 = getAuditReader().find( WhereJoinTableEntity.class, wjte1_id, 4 );
// Checking 1st list
assert TestTools.checkList( rev1.getReferences1() );
assert TestTools.checkList( rev2.getReferences1(), ite1_1 );
assert TestTools.checkList( rev3.getReferences1(), ite1_1 );
assert TestTools.checkList( rev4.getReferences1() );
assert TestTools.checkCollection( rev1.getReferences1() );
assert TestTools.checkCollection( rev2.getReferences1(), ite1_1 );
assert TestTools.checkCollection( rev3.getReferences1(), ite1_1 );
assert TestTools.checkCollection( rev4.getReferences1() );
// Checking 2nd list
assert TestTools.checkList( rev1.getReferences2() );
assert TestTools.checkList( rev2.getReferences2(), ite2_1 );
assert TestTools.checkList( rev3.getReferences2(), ite2_1 );
assert TestTools.checkList( rev4.getReferences2(), ite2_1 );
assert TestTools.checkCollection( rev1.getReferences2() );
assert TestTools.checkCollection( rev2.getReferences2(), ite2_1 );
assert TestTools.checkCollection( rev3.getReferences2(), ite2_1 );
assert TestTools.checkCollection( rev4.getReferences2(), ite2_1 );
}
@Test
@ -174,15 +174,15 @@ public class BasicWhereJoinTable extends BaseEnversJPAFunctionalTestCase {
WhereJoinTableEntity rev4 = getAuditReader().find( WhereJoinTableEntity.class, wjte2_id, 4 );
// Checking 1st list
assert TestTools.checkList( rev1.getReferences1() );
assert TestTools.checkList( rev2.getReferences1() );
assert TestTools.checkList( rev3.getReferences1(), ite1_1, ite1_2 );
assert TestTools.checkList( rev4.getReferences1(), ite1_1, ite1_2 );
assert TestTools.checkCollection( rev1.getReferences1() );
assert TestTools.checkCollection( rev2.getReferences1() );
assert TestTools.checkCollection( rev3.getReferences1(), ite1_1, ite1_2 );
assert TestTools.checkCollection( rev4.getReferences1(), ite1_1, ite1_2 );
// Checking 2nd list
assert TestTools.checkList( rev1.getReferences2() );
assert TestTools.checkList( rev2.getReferences2() );
assert TestTools.checkList( rev3.getReferences2() );
assert TestTools.checkList( rev4.getReferences2(), ite2_2 );
assert TestTools.checkCollection( rev1.getReferences2() );
assert TestTools.checkCollection( rev2.getReferences2() );
assert TestTools.checkCollection( rev3.getReferences2() );
assert TestTools.checkCollection( rev4.getReferences2(), ite2_2 );
}
}

View File

@ -163,11 +163,11 @@ public class BasicBiowned extends BaseEnversJPAFunctionalTestCase {
ListBiowning1Entity rev4 = getAuditReader().find( ListBiowning1Entity.class, o1_1_id, 4 );
ListBiowning1Entity rev5 = getAuditReader().find( ListBiowning1Entity.class, o1_1_id, 5 );
assert TestTools.checkList( rev1.getReferences() );
assert TestTools.checkList( rev2.getReferences(), o2_1 );
assert TestTools.checkList( rev3.getReferences(), o2_1, o2_2 );
assert TestTools.checkList( rev4.getReferences() );
assert TestTools.checkList( rev5.getReferences(), o2_2 );
assert TestTools.checkCollection( rev1.getReferences() );
assert TestTools.checkCollection( rev2.getReferences(), o2_1 );
assert TestTools.checkCollection( rev3.getReferences(), o2_1, o2_2 );
assert TestTools.checkCollection( rev4.getReferences() );
assert TestTools.checkCollection( rev5.getReferences(), o2_2 );
}
@Test
@ -181,12 +181,11 @@ public class BasicBiowned extends BaseEnversJPAFunctionalTestCase {
ListBiowning1Entity rev4 = getAuditReader().find( ListBiowning1Entity.class, o1_2_id, 4 );
ListBiowning1Entity rev5 = getAuditReader().find( ListBiowning1Entity.class, o1_2_id, 5 );
assert TestTools.checkList( rev1.getReferences() );
assert TestTools.checkList( rev2.getReferences(), o2_2 );
assert TestTools.checkList( rev3.getReferences(), o2_2 );
assert TestTools.checkList( rev4.getReferences(), o2_1, o2_2 );
System.out.println( "rev5.getReferences() = " + rev5.getReferences() );
assert TestTools.checkList( rev5.getReferences(), o2_2 );
assert TestTools.checkCollection( rev1.getReferences() );
assert TestTools.checkCollection( rev2.getReferences(), o2_2 );
assert TestTools.checkCollection( rev3.getReferences(), o2_2 );
assert TestTools.checkCollection( rev4.getReferences(), o2_1, o2_2 );
assert TestTools.checkCollection( rev5.getReferences(), o2_2 );
}
@Test
@ -200,11 +199,11 @@ public class BasicBiowned extends BaseEnversJPAFunctionalTestCase {
ListBiowning2Entity rev4 = getAuditReader().find( ListBiowning2Entity.class, o2_1_id, 4 );
ListBiowning2Entity rev5 = getAuditReader().find( ListBiowning2Entity.class, o2_1_id, 5 );
assert TestTools.checkList( rev1.getReferences() );
assert TestTools.checkList( rev2.getReferences(), o1_1 );
assert TestTools.checkList( rev3.getReferences(), o1_1 );
assert TestTools.checkList( rev4.getReferences(), o1_2 );
assert TestTools.checkList( rev5.getReferences() );
assert TestTools.checkCollection( rev1.getReferences() );
assert TestTools.checkCollection( rev2.getReferences(), o1_1 );
assert TestTools.checkCollection( rev3.getReferences(), o1_1 );
assert TestTools.checkCollection( rev4.getReferences(), o1_2 );
assert TestTools.checkCollection( rev5.getReferences() );
}
@Test
@ -218,10 +217,10 @@ public class BasicBiowned extends BaseEnversJPAFunctionalTestCase {
ListBiowning2Entity rev4 = getAuditReader().find( ListBiowning2Entity.class, o2_2_id, 4 );
ListBiowning2Entity rev5 = getAuditReader().find( ListBiowning2Entity.class, o2_2_id, 5 );
assert TestTools.checkList( rev1.getReferences() );
assert TestTools.checkList( rev2.getReferences(), o1_2 );
assert TestTools.checkList( rev3.getReferences(), o1_1, o1_2 );
assert TestTools.checkList( rev4.getReferences(), o1_2 );
assert TestTools.checkList( rev5.getReferences(), o1_1, o1_2 );
assert TestTools.checkCollection( rev1.getReferences() );
assert TestTools.checkCollection( rev2.getReferences(), o1_2 );
assert TestTools.checkCollection( rev3.getReferences(), o1_1, o1_2 );
assert TestTools.checkCollection( rev4.getReferences(), o1_2 );
assert TestTools.checkCollection( rev5.getReferences(), o1_1, o1_2 );
}
}

View File

@ -199,17 +199,17 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p1_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p1_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1(), c1_1 );
assert TestTools.checkList( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkList( rev4.getChildren1(), c1_2 );
assert TestTools.checkList( rev5.getChildren1() );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_2 );
assert TestTools.checkCollection( rev5.getChildren1() );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2() );
assert TestTools.checkList( rev3.getChildren2(), c2_2 );
assert TestTools.checkList( rev4.getChildren2(), c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2() );
assert TestTools.checkCollection( rev3.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_2 );
}
@Test
@ -224,17 +224,17 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p2_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p2_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1() );
assert TestTools.checkList( rev3.getChildren1(), c1_1 );
assert TestTools.checkList( rev4.getChildren1(), c1_1 );
assert TestTools.checkList( rev5.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1() );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev5.getChildren1(), c1_1 );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2(), c2_1 );
assert TestTools.checkList( rev3.getChildren2(), c2_1 );
assert TestTools.checkList( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev3.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_1 );
}
@Test
@ -248,11 +248,11 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
Child1Entity rev4 = getAuditReader().find( Child1Entity.class, c1_1_id, 4 );
Child1Entity rev5 = getAuditReader().find( Child1Entity.class, c1_1_id, 5 );
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p1 );
assert TestTools.checkList( rev3.getParents(), p1, p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p1 );
assert TestTools.checkCollection( rev3.getParents(), p1, p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
// TODO: was disabled?
@ -266,11 +266,11 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
Child1Entity rev4 = getAuditReader().find( Child1Entity.class, c1_2_id, 4 );
Child1Entity rev5 = getAuditReader().find( Child1Entity.class, c1_2_id, 5 );
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1 );
assert TestTools.checkList( rev5.getParents() );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1 );
assert TestTools.checkCollection( rev5.getParents() );
}
@Test
@ -283,11 +283,11 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
Child2Entity rev4 = getAuditReader().find( Child2Entity.class, c2_1_id, 4 );
Child2Entity rev5 = getAuditReader().find( Child2Entity.class, c2_1_id, 5 );
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p2 );
assert TestTools.checkList( rev3.getParents(), p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p2 );
assert TestTools.checkCollection( rev3.getParents(), p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
@Test
@ -301,10 +301,10 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
Child2Entity rev4 = getAuditReader().find( Child2Entity.class, c2_2_id, 4 );
Child2Entity rev5 = getAuditReader().find( Child2Entity.class, c2_2_id, 5 );
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1, p2 );
assert TestTools.checkList( rev5.getParents(), p1 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1, p2 );
assert TestTools.checkCollection( rev5.getParents(), p1 );
}
}

View File

@ -151,9 +151,9 @@ public class BasicUniList extends BaseEnversJPAFunctionalTestCase {
ListUniEntity rev5 = getAuditReader().find( ListUniEntity.class, ing1_id, 5 );
assert rev1.getReferences().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferences(), ed1 );
assert TestTools.checkList( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev4.getReferences(), ed2 );
assert TestTools.checkCollection( rev2.getReferences(), ed1 );
assert TestTools.checkCollection( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev4.getReferences(), ed2 );
assert rev5.getReferences().equals( Collections.EMPTY_LIST );
}
@ -169,9 +169,9 @@ public class BasicUniList extends BaseEnversJPAFunctionalTestCase {
ListUniEntity rev5 = getAuditReader().find( ListUniEntity.class, ing2_id, 5 );
assert rev1.getReferences().equals( Collections.EMPTY_LIST );
assert TestTools.checkList( rev2.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev4.getReferences(), ed1, ed2 );
assert TestTools.checkList( rev5.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev2.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev3.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev4.getReferences(), ed1, ed2 );
assert TestTools.checkCollection( rev5.getReferences(), ed1, ed2 );
}
}

View File

@ -11,7 +11,7 @@ import org.hibernate.envers.test.entities.manytomany.unidirectional.M2MIndexedLi
import org.junit.Test;
import static org.hibernate.envers.test.tools.TestTools.checkList;
import static org.hibernate.envers.test.tools.TestTools.checkCollection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -114,9 +114,9 @@ public class M2MIndexedListNotAuditedTarget extends BaseEnversJPAFunctionalTestC
3
);
assertTrue( checkList( rev1.getReferences(), uste1, uste2 ) );
assertTrue( checkList( rev2.getReferences(), uste1, uste2 ) );
assertTrue( checkList( rev3.getReferences(), uste2, uste1 ) );
assertTrue( checkCollection( rev1.getReferences(), uste1, uste2 ) );
assertTrue( checkCollection( rev2.getReferences(), uste1, uste2 ) );
assertTrue( checkCollection( rev3.getReferences(), uste2, uste1 ) );
}
@Test
@ -138,7 +138,7 @@ public class M2MIndexedListNotAuditedTarget extends BaseEnversJPAFunctionalTestC
);
assertNull( rev1 );
assertTrue( checkList( rev2.getReferences(), uste2 ) );
assertTrue( checkList( rev3.getReferences(), uste2 ) );
assertTrue( checkCollection( rev2.getReferences(), uste2 ) );
assertTrue( checkCollection( rev3.getReferences(), uste2 ) );
}
}

View File

@ -35,7 +35,7 @@ import org.hibernate.envers.test.entities.manytomany.unidirectional.M2MTargetNot
import org.junit.Test;
import static org.hibernate.envers.test.tools.TestTools.checkList;
import static org.hibernate.envers.test.tools.TestTools.checkCollection;
import static org.junit.Assert.assertTrue;
/**
@ -153,10 +153,10 @@ public class M2MRelationNotAuditedTarget extends BaseEnversJPAFunctionalTestCase
M2MTargetNotAuditedEntity rev3 = getAuditReader().find( M2MTargetNotAuditedEntity.class, tnae1_id, 3 );
M2MTargetNotAuditedEntity rev4 = getAuditReader().find( M2MTargetNotAuditedEntity.class, tnae1_id, 4 );
assertTrue( checkList( rev1.getReferences() ) );
assertTrue( checkList( rev2.getReferences(), uste1 ) );
assertTrue( checkList( rev3.getReferences(), uste1 ) );
assertTrue( checkList( rev4.getReferences(), uste1, uste2 ) );
assertTrue( checkCollection( rev1.getReferences() ) );
assertTrue( checkCollection( rev2.getReferences(), uste1 ) );
assertTrue( checkCollection( rev3.getReferences(), uste1 ) );
assertTrue( checkCollection( rev4.getReferences(), uste1, uste2 ) );
}
@Test
@ -169,9 +169,9 @@ public class M2MRelationNotAuditedTarget extends BaseEnversJPAFunctionalTestCase
M2MTargetNotAuditedEntity rev3 = getAuditReader().find( M2MTargetNotAuditedEntity.class, tnae2_id, 3 );
M2MTargetNotAuditedEntity rev4 = getAuditReader().find( M2MTargetNotAuditedEntity.class, tnae2_id, 4 );
assertTrue( checkList( rev1.getReferences(), uste1, uste2 ) );
assertTrue( checkList( rev2.getReferences(), uste2 ) );
assertTrue( checkList( rev3.getReferences() ) );
assertTrue( checkList( rev4.getReferences(), uste1 ) );
assertTrue( checkCollection( rev1.getReferences(), uste1, uste2 ) );
assertTrue( checkCollection( rev2.getReferences(), uste2 ) );
assertTrue( checkCollection( rev3.getReferences() ) );
assertTrue( checkCollection( rev4.getReferences(), uste1 ) );
}
}

View File

@ -118,9 +118,9 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListRefEdEntity rev2 = getAuditReader().find( ListRefEdEntity.class, ed1_id, 2 );
ListRefEdEntity rev3 = getAuditReader().find( ListRefEdEntity.class, ed1_id, 3 );
assert TestTools.checkList( rev1.getReffering(), ing1, ing2 );
assert TestTools.checkList( rev2.getReffering(), ing2 );
assert TestTools.checkList( rev3.getReffering() );
assert TestTools.checkCollection( rev1.getReffering(), ing1, ing2 );
assert TestTools.checkCollection( rev2.getReffering(), ing2 );
assert TestTools.checkCollection( rev3.getReffering() );
}
@Test
@ -132,9 +132,9 @@ public class BasicList extends BaseEnversJPAFunctionalTestCase {
ListRefEdEntity rev2 = getAuditReader().find( ListRefEdEntity.class, ed2_id, 2 );
ListRefEdEntity rev3 = getAuditReader().find( ListRefEdEntity.class, ed2_id, 3 );
assert TestTools.checkList( rev1.getReffering() );
assert TestTools.checkList( rev2.getReffering(), ing1 );
assert TestTools.checkList( rev3.getReffering(), ing1, ing2 );
assert TestTools.checkCollection( rev1.getReffering() );
assert TestTools.checkCollection( rev2.getReffering(), ing1 );
assert TestTools.checkCollection( rev3.getReffering(), ing1, ing2 );
}
@Test

View File

@ -126,10 +126,10 @@ public class BasicDetachedList extends BaseEnversJPAFunctionalTestCase {
ListRefCollEntity rev3 = getAuditReader().find( ListRefCollEntity.class, coll1_id, 3 );
ListRefCollEntity rev4 = getAuditReader().find( ListRefCollEntity.class, coll1_id, 4 );
assert TestTools.checkList( rev1.getCollection(), str1 );
assert TestTools.checkList( rev2.getCollection(), str1, str2 );
assert TestTools.checkList( rev3.getCollection(), str2 );
assert TestTools.checkList( rev4.getCollection() );
assert TestTools.checkCollection( rev1.getCollection(), str1 );
assert TestTools.checkCollection( rev2.getCollection(), str1, str2 );
assert TestTools.checkCollection( rev3.getCollection(), str2 );
assert TestTools.checkCollection( rev4.getCollection() );
assert "coll1".equals( rev1.getData() );
assert "coll1".equals( rev2.getData() );

View File

@ -34,7 +34,7 @@ import org.hibernate.envers.test.entities.onetomany.detached.DoubleListJoinColum
import org.junit.Test;
import static org.hibernate.envers.test.tools.TestTools.checkList;
import static org.hibernate.envers.test.tools.TestTools.checkCollection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -266,15 +266,15 @@ public class DoubleJoinColumnBidirectionalList extends BaseEnversJPAFunctionalTe
4
);
assertTrue( checkList( rev1.getReferences1(), ed1_1_fromRev1 ) );
assertTrue( checkList( rev2.getReferences1(), ed1_1_fromRev1, ed1_2 ) );
assertTrue( checkList( rev3.getReferences1(), ed1_1_fromRev3, ed1_2 ) );
assertTrue( checkList( rev4.getReferences1() ) );
assertTrue( checkCollection( rev1.getReferences1(), ed1_1_fromRev1 ) );
assertTrue( checkCollection( rev2.getReferences1(), ed1_1_fromRev1, ed1_2 ) );
assertTrue( checkCollection( rev3.getReferences1(), ed1_1_fromRev3, ed1_2 ) );
assertTrue( checkCollection( rev4.getReferences1() ) );
assertTrue( checkList( rev1.getReferences2(), ed2_1 ) );
assertTrue( checkList( rev2.getReferences2(), ed2_1, ed2_2_fromRev1 ) );
assertTrue( checkList( rev3.getReferences2(), ed2_1, ed2_2_fromRev3 ) );
assertTrue( checkList( rev4.getReferences2(), ed2_2_fromRev3 ) );
assertTrue( checkCollection( rev1.getReferences2(), ed2_1 ) );
assertTrue( checkCollection( rev2.getReferences2(), ed2_1, ed2_2_fromRev1 ) );
assertTrue( checkCollection( rev3.getReferences2(), ed2_1, ed2_2_fromRev3 ) );
assertTrue( checkCollection( rev4.getReferences2(), ed2_2_fromRev3 ) );
}
@Test
@ -319,15 +319,15 @@ public class DoubleJoinColumnBidirectionalList extends BaseEnversJPAFunctionalTe
4
);
assertTrue( checkList( rev1.getReferences1(), ed1_2 ) );
assertTrue( checkList( rev2.getReferences1() ) );
assertTrue( checkList( rev3.getReferences1() ) );
assertTrue( checkList( rev4.getReferences1(), ed1_1_fromRev3, ed1_2 ) );
assertTrue( checkCollection( rev1.getReferences1(), ed1_2 ) );
assertTrue( checkCollection( rev2.getReferences1() ) );
assertTrue( checkCollection( rev3.getReferences1() ) );
assertTrue( checkCollection( rev4.getReferences1(), ed1_1_fromRev3, ed1_2 ) );
assertTrue( checkList( rev1.getReferences2(), ed2_2_fromRev1 ) );
assertTrue( checkList( rev2.getReferences2() ) );
assertTrue( checkList( rev3.getReferences2() ) );
assertTrue( checkList( rev4.getReferences2(), ed2_1 ) );
assertTrue( checkCollection( rev1.getReferences2(), ed2_2_fromRev1 ) );
assertTrue( checkCollection( rev2.getReferences2() ) );
assertTrue( checkCollection( rev3.getReferences2() ) );
assertTrue( checkCollection( rev4.getReferences2(), ed2_1 ) );
}
@Test

View File

@ -33,7 +33,7 @@ import org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidir
import org.junit.Test;
import static org.hibernate.envers.test.tools.TestTools.checkList;
import static org.hibernate.envers.test.tools.TestTools.checkCollection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -199,10 +199,10 @@ public class JoinColumnBidirectionalList extends BaseEnversJPAFunctionalTestCase
4
);
assertTrue( checkList( rev1.getReferences(), ed1_fromRev1 ) );
assertTrue( checkList( rev2.getReferences(), ed1_fromRev1, ed2 ) );
assertTrue( checkList( rev3.getReferences(), ed1_fromRev3, ed2 ) );
assertTrue( checkList( rev4.getReferences() ) );
assertTrue( checkCollection( rev1.getReferences(), ed1_fromRev1 ) );
assertTrue( checkCollection( rev2.getReferences(), ed1_fromRev1, ed2 ) );
assertTrue( checkCollection( rev3.getReferences(), ed1_fromRev3, ed2 ) );
assertTrue( checkCollection( rev4.getReferences() ) );
}
@Test
@ -237,10 +237,10 @@ public class JoinColumnBidirectionalList extends BaseEnversJPAFunctionalTestCase
4
);
assertTrue( checkList( rev1.getReferences(), ed2 ) );
assertTrue( checkList( rev2.getReferences() ) );
assertTrue( checkList( rev3.getReferences() ) );
assertTrue( checkList( rev4.getReferences(), ed1, ed2 ) );
assertTrue( checkCollection( rev1.getReferences(), ed2 ) );
assertTrue( checkCollection( rev2.getReferences() ) );
assertTrue( checkCollection( rev3.getReferences() ) );
assertTrue( checkCollection( rev4.getReferences(), ed1, ed2 ) );
}
@Test

View File

@ -34,7 +34,7 @@ import org.hibernate.envers.test.entities.onetomany.detached.ListJoinColumnBidir
import org.junit.Test;
import static org.hibernate.envers.test.tools.TestTools.checkList;
import static org.hibernate.envers.test.tools.TestTools.checkCollection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -169,8 +169,8 @@ public class JoinColumnBidirectionalListWithInheritance extends BaseEnversJPAFun
2
);
assertTrue( checkList( rev1.getReferences(), ed1 ) );
assertTrue( checkList( rev2.getReferences(), ed1, ed2 ) );
assertTrue( checkCollection( rev1.getReferences(), ed1 ) );
assertTrue( checkCollection( rev2.getReferences(), ed1, ed2 ) );
}
@Test
@ -191,8 +191,8 @@ public class JoinColumnBidirectionalListWithInheritance extends BaseEnversJPAFun
2
);
assertTrue( checkList( rev1.getReferences(), ed2 ) );
assertTrue( checkList( rev2.getReferences() ) );
assertTrue( checkCollection( rev1.getReferences(), ed2 ) );
assertTrue( checkCollection( rev2.getReferences() ) );
}
@Test

View File

@ -75,17 +75,17 @@ public class HierarchyTest extends BaseEnversJPAFunctionalTestCase {
Node ver1 = getAuditReader().find( Node.class, parentId, 1 );
Assert.assertEquals( parent, ver1 );
Assert.assertTrue( TestTools.checkList( ver1.getChildren(), child1, child2 ) );
Assert.assertTrue( TestTools.checkCollection( ver1.getChildren(), child1, child2 ) );
child1.setData( "child1 modified" );
Node ver2 = getAuditReader().find( Node.class, parentId, 2 );
Assert.assertEquals( parent, ver2 );
Assert.assertTrue( TestTools.checkList( ver2.getChildren(), child1, child2 ) );
Assert.assertTrue( TestTools.checkCollection( ver2.getChildren(), child1, child2 ) );
Node ver3 = getAuditReader().find( Node.class, parentId, 3 );
Assert.assertEquals( parent, ver3 );
Assert.assertTrue( TestTools.checkList( ver3.getChildren(), child1 ) );
Assert.assertTrue( TestTools.checkCollection( ver3.getChildren(), child1 ) );
}
@Test

View File

@ -1,6 +1,7 @@
package org.hibernate.envers.test.integration.proxy;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -17,9 +18,13 @@ import org.hibernate.envers.test.entities.IntTestPrivSeqEntity;
import org.hibernate.envers.test.entities.StrTestPrivSeqEntity;
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
import org.hibernate.envers.test.entities.collection.StringSetEntity;
import org.hibernate.envers.test.entities.manytomany.ListOwnedEntity;
import org.hibernate.envers.test.entities.manytomany.ListOwningEntity;
import org.hibernate.envers.test.entities.manytomany.SetOwnedEntity;
import org.hibernate.envers.test.entities.manytomany.SetOwningEntity;
import org.hibernate.envers.test.entities.manytomany.unidirectional.M2MIndexedListTargetNotAuditedEntity;
import org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity;
import org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity;
import org.hibernate.envers.test.entities.onetomany.SetRefEdEntity;
import org.hibernate.envers.test.entities.onetomany.SetRefIngEntity;
import org.hibernate.envers.test.integration.manytomany.ternary.TernaryMapEntity;
@ -55,7 +60,8 @@ public class RemovedObjectQueryTest extends BaseEnversJPAFunctionalTestCase {
return new Class<?>[] {
SetRefEdEntity.class, SetRefIngEntity.class, SetOwnedEntity.class, SetOwningEntity.class,
StringSetEntity.class, UnversionedStrTestEntity.class, M2MIndexedListTargetNotAuditedEntity.class,
TernaryMapEntity.class, StrTestPrivSeqEntity.class, IntTestPrivSeqEntity.class
TernaryMapEntity.class, StrTestPrivSeqEntity.class, IntTestPrivSeqEntity.class,
CollectionRefEdEntity.class, CollectionRefIngEntity.class, ListOwnedEntity.class, ListOwningEntity.class
};
}
@ -212,30 +218,108 @@ public class RemovedObjectQueryTest extends BaseEnversJPAFunctionalTestCase {
ternaryMapId = mapEntity.getId();
// Revision 16 - removing ternary map
// Revision 16 - updating ternary map
em.getTransaction().begin();
intEntity2 = em.find( IntTestPrivSeqEntity.class, intEntity2.getId() );
intEntity2.setNumber( 3 );
intEntity2 = em.merge( intEntity2 );
stringEntity2 = em.find( StrTestPrivSeqEntity.class, stringEntity2.getId() );
stringEntity2.setStr( "Value 3" );
stringEntity2 = em.merge( stringEntity2 );
em.getTransaction().commit();
// Revision 17 - removing ternary map
em.getTransaction().begin();
mapEntity = em.find( TernaryMapEntity.class, mapEntity.getId() );
em.remove( mapEntity );
em.getTransaction().commit();
CollectionRefEdEntity collEd1 = new CollectionRefEdEntity( 1, "data_ed_1" );
CollectionRefIngEntity collIng1 = new CollectionRefIngEntity( 2, "data_ing_1", collEd1 );
collEd1.setReffering( new ArrayList<CollectionRefIngEntity>() );
collEd1.getReffering().add( collIng1 );
// Revision 18 - testing one-to-many collection
em.getTransaction().begin();
em.persist( collEd1 );
em.persist( collIng1 );
em.getTransaction().commit();
// Revision 19
em.getTransaction().begin();
collIng1 = em.find( CollectionRefIngEntity.class, collIng1.getId() );
collIng1.setData( "modified data_ing_1" );
collIng1 = em.merge( collIng1 );
em.getTransaction().commit();
// Revision 20
em.getTransaction().begin();
collEd1 = em.find( CollectionRefEdEntity.class, collEd1.getId() );
collIng1 = em.find( CollectionRefIngEntity.class, collIng1.getId() );
em.remove( collIng1 );
em.remove( collEd1 );
em.getTransaction().commit();
ListOwnedEntity listEd1 = new ListOwnedEntity( 1, "data_ed_1" );
ListOwningEntity listIng1 = new ListOwningEntity( 2, "data_ing_1" );
listEd1.setReferencing( new ArrayList<ListOwningEntity>() );
listIng1.setReferences( new ArrayList<ListOwnedEntity>() );
listEd1.getReferencing().add( listIng1 );
listIng1.getReferences().add( listEd1 );
// Revision 21 - testing many-to-many collection
em.getTransaction().begin();
em.persist( listEd1 );
em.persist( listIng1 );
em.getTransaction().commit();
// Revision 22
em.getTransaction().begin();
listIng1 = em.find( ListOwningEntity.class, listIng1.getId() );
listIng1.setData( "modified data_ing_1" );
listIng1 = em.merge( listIng1 );
em.getTransaction().commit();
// Revision 23
em.getTransaction().begin();
listIng1 = em.find( ListOwningEntity.class, listIng1.getId() );
listEd1 = em.find( ListOwnedEntity.class, listEd1.getId() );
em.remove( listIng1 );
em.remove( listEd1 );
em.getTransaction().commit();
em.close();
}
@Test
public void testTernaryMap() {
final TernaryMapEntity ternaryMap = new TernaryMapEntity();
ternaryMap.setId( ternaryMapId );
ternaryMap.getMap().put( intEntity1, stringEntity1 );
ternaryMap.getMap().put( new IntTestPrivSeqEntity( 2, intEntity2.getId() ) , new StrTestPrivSeqEntity( "Value 2", stringEntity2.getId() ) );
TernaryMapEntity entity = getAuditReader().find( TernaryMapEntity.class, ternaryMapId, 15 );
Assert.assertEquals( ternaryMap.getMap(), entity.getMap() );
ternaryMap.getMap().clear();
ternaryMap.getMap().put( intEntity1, stringEntity1 );
ternaryMap.getMap().put( intEntity2, stringEntity2 );
entity = getAuditReader().find( TernaryMapEntity.class, ternaryMapId, 16 );
Assert.assertEquals( ternaryMap.getMap(), entity.getMap() );
List queryResult = getAuditReader().createQuery().forRevisionsOfEntity( TernaryMapEntity.class, false, true )
.add( AuditEntity.id().eq( ternaryMapId ) )
.add( AuditEntity.revisionType().eq( RevisionType.DEL ) )
.getResultList();
Object[] objArray = (Object[]) queryResult.get( 0 );
Assert.assertEquals( 16, getRevisionNumber( objArray[1] ) );
Assert.assertEquals( 17, getRevisionNumber( objArray[1] ) );
TernaryMapEntity mapEntity = (TernaryMapEntity) objArray[0];
Assert.assertEquals(
TestTools.makeMap( intEntity1, stringEntity1, intEntity2, stringEntity2 ),
mapEntity.getMap()
);
entity = (TernaryMapEntity) objArray[0];
Assert.assertEquals( ternaryMap.getMap(), entity.getMap() );
}
@Test
@ -251,7 +335,7 @@ public class RemovedObjectQueryTest extends BaseEnversJPAFunctionalTestCase {
M2MIndexedListTargetNotAuditedEntity relationNotAuditedEntity = (M2MIndexedListTargetNotAuditedEntity) objArray[0];
Assert.assertTrue(
TestTools.checkList(
TestTools.checkCollection(
relationNotAuditedEntity.getReferences(),
unversionedEntity1, unversionedEntity2
)
@ -274,6 +358,34 @@ public class RemovedObjectQueryTest extends BaseEnversJPAFunctionalTestCase {
// One to many tests.
@Test
public void testOneToManyCollectionSemantics() {
final CollectionRefEdEntity edVer1 = new CollectionRefEdEntity( 1, "data_ed_1" );
final CollectionRefIngEntity ingVer1 = new CollectionRefIngEntity( 2, "data_ing_1" );
final CollectionRefIngEntity ingVer2 = new CollectionRefIngEntity( 2, "modified data_ing_1" );
CollectionRefEdEntity entity = getAuditReader().find( CollectionRefEdEntity.class, 1, 18 );
Assert.assertEquals( edVer1, entity );
Assert.assertTrue( TestTools.checkCollection( entity.getReffering(), ingVer1 ) );
entity = getAuditReader().find( CollectionRefEdEntity.class, 1, 19 );
Assert.assertTrue( TestTools.checkCollection( entity.getReffering(), ingVer2 ) );
List queryResult = getAuditReader().createQuery().forRevisionsOfEntity( CollectionRefEdEntity.class, false, true )
.add( AuditEntity.id().eq( 1 ) )
.add( AuditEntity.revisionType().eq( RevisionType.DEL ) )
.getResultList();
Object[] objArray = (Object[]) queryResult.get( 0 );
Assert.assertEquals( 20, getRevisionNumber( objArray[1] ) );
entity = (CollectionRefEdEntity) objArray[0];
Assert.assertEquals( "data_ed_1", entity.getData() );
Assert.assertTrue( TestTools.checkCollection( entity.getReffering(), ingVer2 ) );
}
@Test
public void testReferencedOneToManySameRevision() {
List queryResult = getAuditReader().createQuery().forRevisionsOfEntity( SetRefIngEntity.class, false, true )
@ -360,6 +472,34 @@ public class RemovedObjectQueryTest extends BaseEnversJPAFunctionalTestCase {
// Many to many tests.
@Test
public void testManyToManyCollectionSemantics() {
final ListOwnedEntity edVer1 = new ListOwnedEntity( 1, "data_ed_1" );
final ListOwningEntity ingVer1 = new ListOwningEntity( 2, "data_ing_1" );
final ListOwningEntity ingVer2 = new ListOwningEntity( 2, "modified data_ing_1" );
ListOwnedEntity entity = getAuditReader().find( ListOwnedEntity.class, 1, 21 );
Assert.assertEquals( edVer1, entity );
Assert.assertTrue( TestTools.checkCollection( entity.getReferencing(), ingVer1 ) );
entity = getAuditReader().find( ListOwnedEntity.class, 1, 22 );
Assert.assertTrue( TestTools.checkCollection( entity.getReferencing(), ingVer2 ) );
List queryResult = getAuditReader().createQuery().forRevisionsOfEntity( ListOwnedEntity.class, false, true )
.add( AuditEntity.id().eq( 1 ) )
.add( AuditEntity.revisionType().eq( RevisionType.DEL ) )
.getResultList();
Object[] objArray = (Object[]) queryResult.get( 0 );
Assert.assertEquals( 23, getRevisionNumber( objArray[1] ) );
entity = (ListOwnedEntity) objArray[0];
Assert.assertEquals( "data_ed_1", entity.getData() );
Assert.assertTrue( TestTools.checkCollection( entity.getReferencing(), ingVer2 ) );
}
@Test
public void testOwnedManyToManySameRevision() {
List queryResult = getAuditReader().createQuery().forRevisionsOfEntity( SetOwningEntity.class, false, true )

View File

@ -134,7 +134,7 @@ public class AggregateQuery extends BaseEnversJPAFunctionalTestCase {
.add( AuditEntity.id().between( 2, 3 ) )
.getResultList();
Assert.assertTrue(
TestTools.checkList(
TestTools.checkCollection(
list,
new IntTestEntity( 10, 2 ), new IntTestEntity( 8, 3 ), new IntTestEntity( 52, 2 )
)

View File

@ -311,7 +311,7 @@ public class SimpleQuery extends BaseEnversJPAFunctionalTestCase {
.addProjection( AuditEntity.revisionType() ).add( AuditEntity.id().eq( id1 ) )
.getSingleResult();
Assert.assertTrue( TestTools.checkList( result, site1, site2, site3 ) );
Assert.assertTrue( TestTools.checkCollection( result, site1, site2, site3 ) );
Assert.assertEquals( revisionType, RevisionType.ADD );
}
@ -330,7 +330,7 @@ public class SimpleQuery extends BaseEnversJPAFunctionalTestCase {
.addProjection( AuditEntity.revisionType() ).add( AuditEntity.id().eq( id1 ) )
.getSingleResult();
Assert.assertTrue( TestTools.checkList( result, site1, site2 ) );
Assert.assertTrue( TestTools.checkCollection( result, site1, site2 ) );
Assert.assertEquals( revisionType, RevisionType.MOD );
}
@ -348,7 +348,7 @@ public class SimpleQuery extends BaseEnversJPAFunctionalTestCase {
.addProjection( AuditEntity.revisionType() ).add( AuditEntity.id().eq( id1 ) )
.getSingleResult();
Assert.assertTrue( TestTools.checkList( result, site1 ) );
Assert.assertTrue( TestTools.checkCollection( result, site1 ) );
Assert.assertEquals( revisionType, RevisionType.DEL );
}

View File

@ -91,14 +91,14 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrTestEntity ste = new StrTestEntity( "x", steId );
StrIntTestEntity site = new StrIntTestEntity( "y", 1, siteId );
assert TestTools.checkList( getCrossTypeRevisionChangesReader().findEntities( 1 ), ste, site );
assert TestTools.checkCollection( getCrossTypeRevisionChangesReader().findEntities( 1 ), ste, site );
}
@Test
public void testTrackModifiedEntities() {
StrIntTestEntity site = new StrIntTestEntity( "y", 2, siteId );
assert TestTools.checkList( getCrossTypeRevisionChangesReader().findEntities( 2 ), site );
assert TestTools.checkCollection( getCrossTypeRevisionChangesReader().findEntities( 2 ), site );
}
@Test
@ -106,7 +106,7 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrTestEntity ste = new StrTestEntity( null, steId );
StrIntTestEntity site = new StrIntTestEntity( null, null, siteId );
assert TestTools.checkList( getCrossTypeRevisionChangesReader().findEntities( 3 ), site, ste );
assert TestTools.checkCollection( getCrossTypeRevisionChangesReader().findEntities( 3 ), site, ste );
}
@Test
@ -120,9 +120,9 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrIntTestEntity site = new StrIntTestEntity( "y", 1, siteId );
Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType( 1 );
assert TestTools.checkList( result.get( RevisionType.ADD ), site, ste );
assert TestTools.checkList( result.get( RevisionType.MOD ) );
assert TestTools.checkList( result.get( RevisionType.DEL ) );
assert TestTools.checkCollection( result.get( RevisionType.ADD ), site, ste );
assert TestTools.checkCollection( result.get( RevisionType.MOD ) );
assert TestTools.checkCollection( result.get( RevisionType.DEL ) );
}
@Test
@ -130,9 +130,9 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrIntTestEntity site = new StrIntTestEntity( "y", 2, siteId );
Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType( 2 );
assert TestTools.checkList( result.get( RevisionType.ADD ) );
assert TestTools.checkList( result.get( RevisionType.MOD ), site );
assert TestTools.checkList( result.get( RevisionType.DEL ) );
assert TestTools.checkCollection( result.get( RevisionType.ADD ) );
assert TestTools.checkCollection( result.get( RevisionType.MOD ), site );
assert TestTools.checkCollection( result.get( RevisionType.DEL ) );
}
@Test
@ -141,9 +141,9 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrIntTestEntity site = new StrIntTestEntity( null, null, siteId );
Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType( 3 );
assert TestTools.checkList( result.get( RevisionType.ADD ) );
assert TestTools.checkList( result.get( RevisionType.MOD ) );
assert TestTools.checkList( result.get( RevisionType.DEL ), site, ste );
assert TestTools.checkCollection( result.get( RevisionType.ADD ) );
assert TestTools.checkCollection( result.get( RevisionType.MOD ) );
assert TestTools.checkCollection( result.get( RevisionType.DEL ), site, ste );
}
@Test
@ -151,7 +151,7 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrTestEntity ste = new StrTestEntity( "x", steId );
StrIntTestEntity site = new StrIntTestEntity( "y", 1, siteId );
assert TestTools.checkList(
assert TestTools.checkCollection(
getCrossTypeRevisionChangesReader().findEntities( 1, RevisionType.ADD ),
ste,
site
@ -162,7 +162,10 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
public void testFindChangedEntitiesByRevisionTypeMOD() {
StrIntTestEntity site = new StrIntTestEntity( "y", 2, siteId );
assert TestTools.checkList( getCrossTypeRevisionChangesReader().findEntities( 2, RevisionType.MOD ), site );
assert TestTools.checkCollection(
getCrossTypeRevisionChangesReader().findEntities( 2, RevisionType.MOD ),
site
);
}
@Test
@ -170,7 +173,7 @@ public class DefaultTrackingEntitiesTest extends BaseEnversJPAFunctionalTestCase
StrTestEntity ste = new StrTestEntity( null, steId );
StrIntTestEntity site = new StrIntTestEntity( null, null, siteId );
assert TestTools.checkList(
assert TestTools.checkCollection(
getCrossTypeRevisionChangesReader().findEntities( 3, RevisionType.DEL ),
ste,
site

View File

@ -291,17 +291,17 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p1_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p1_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1(), c1_1 );
assert TestTools.checkList( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkList( rev4.getChildren1(), c1_2 );
assert TestTools.checkList( rev5.getChildren1() );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_2 );
assert TestTools.checkCollection( rev5.getChildren1() );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2() );
assert TestTools.checkList( rev3.getChildren2(), c2_2 );
assert TestTools.checkList( rev4.getChildren2(), c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2() );
assert TestTools.checkCollection( rev3.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_2 );
}
@Test
@ -319,17 +319,17 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p2_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p2_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1() );
assert TestTools.checkList( rev3.getChildren1(), c1_1 );
assert TestTools.checkList( rev4.getChildren1(), c1_1 );
assert TestTools.checkList( rev5.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1() );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev5.getChildren1(), c1_1 );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2(), c2_1 );
assert TestTools.checkList( rev3.getChildren2(), c2_1 );
assert TestTools.checkList( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev3.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_1 );
}
@Test
@ -358,11 +358,11 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p1 );
assert TestTools.checkList( rev3.getParents(), p1, p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p1 );
assert TestTools.checkCollection( rev3.getParents(), p1, p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
// TODO: this was disabled?
@ -391,11 +391,11 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1 );
assert TestTools.checkList( rev5.getParents() );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1 );
assert TestTools.checkCollection( rev5.getParents() );
}
@Test
@ -423,11 +423,11 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p2 );
assert TestTools.checkList( rev3.getParents(), p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p2 );
assert TestTools.checkCollection( rev3.getParents(), p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
@Test
@ -456,11 +456,11 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1, p2 );
assert TestTools.checkList( rev5.getParents(), p1 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1, p2 );
assert TestTools.checkCollection( rev5.getParents(), p1 );
}
private List<Map<String, Object>> getRevisions(

View File

@ -289,17 +289,17 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p1_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p1_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1(), c1_1 );
assert TestTools.checkList( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkList( rev4.getChildren1(), c1_2 );
assert TestTools.checkList( rev5.getChildren1() );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1, c1_2 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_2 );
assert TestTools.checkCollection( rev5.getChildren1() );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2() );
assert TestTools.checkList( rev3.getChildren2(), c2_2 );
assert TestTools.checkList( rev4.getChildren2(), c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2() );
assert TestTools.checkCollection( rev3.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_2 );
}
@Test
@ -317,17 +317,17 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
ParentEntity rev4 = getAuditReader().find( ParentEntity.class, p2_id, 4 );
ParentEntity rev5 = getAuditReader().find( ParentEntity.class, p2_id, 5 );
assert TestTools.checkList( rev1.getChildren1() );
assert TestTools.checkList( rev2.getChildren1() );
assert TestTools.checkList( rev3.getChildren1(), c1_1 );
assert TestTools.checkList( rev4.getChildren1(), c1_1 );
assert TestTools.checkList( rev5.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev1.getChildren1() );
assert TestTools.checkCollection( rev2.getChildren1() );
assert TestTools.checkCollection( rev3.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev4.getChildren1(), c1_1 );
assert TestTools.checkCollection( rev5.getChildren1(), c1_1 );
assert TestTools.checkList( rev1.getChildren2() );
assert TestTools.checkList( rev2.getChildren2(), c2_1 );
assert TestTools.checkList( rev3.getChildren2(), c2_1 );
assert TestTools.checkList( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkList( rev5.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev1.getChildren2() );
assert TestTools.checkCollection( rev2.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev3.getChildren2(), c2_1 );
assert TestTools.checkCollection( rev4.getChildren2(), c2_1, c2_2 );
assert TestTools.checkCollection( rev5.getChildren2(), c2_1 );
}
@Test
@ -356,11 +356,11 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p1 );
assert TestTools.checkList( rev3.getParents(), p1, p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p1 );
assert TestTools.checkCollection( rev3.getParents(), p1, p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
// TODO: this was disabled?
@ -389,11 +389,11 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1 );
assert TestTools.checkList( rev5.getParents() );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1 );
assert TestTools.checkCollection( rev5.getParents() );
}
@Test
@ -421,11 +421,11 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents(), p2 );
assert TestTools.checkList( rev3.getParents(), p2 );
assert TestTools.checkList( rev4.getParents(), p2 );
assert TestTools.checkList( rev5.getParents(), p2 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents(), p2 );
assert TestTools.checkCollection( rev3.getParents(), p2 );
assert TestTools.checkCollection( rev4.getParents(), p2 );
assert TestTools.checkCollection( rev5.getParents(), p2 );
}
@Test
@ -454,11 +454,11 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
5
);
assert TestTools.checkList( rev1.getParents() );
assert TestTools.checkList( rev2.getParents() );
assert TestTools.checkList( rev3.getParents(), p1 );
assert TestTools.checkList( rev4.getParents(), p1, p2 );
assert TestTools.checkList( rev5.getParents(), p1 );
assert TestTools.checkCollection( rev1.getParents() );
assert TestTools.checkCollection( rev2.getParents() );
assert TestTools.checkCollection( rev3.getParents(), p1 );
assert TestTools.checkCollection( rev4.getParents(), p1, p2 );
assert TestTools.checkCollection( rev5.getParents(), p1 );
}
private List<Map<String, Object>> getRevisions(

View File

@ -25,6 +25,7 @@ package org.hibernate.envers.test.tools;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -63,7 +64,7 @@ public class TestTools {
return ret;
}
public static <T> boolean checkList(List<T> list, T... objects) {
public static <T> boolean checkCollection(Collection<T> list, T... objects) {
if ( list.size() != objects.length ) {
return false;
}