HHH-6605 - Moved extractRevisionNumbers test method to TestTools class
This commit is contained in:
parent
d7904dbf0d
commit
fcb57dd17f
|
@ -1,10 +1,8 @@
|
|||
package org.hibernate.envers.test;
|
||||
|
||||
import org.hibernate.envers.DefaultRevisionEntity;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -29,12 +27,4 @@ public abstract class AbstractEnversTest {
|
|||
public String getAuditStrategy() {
|
||||
return auditStrategy;
|
||||
}
|
||||
|
||||
public List<Integer> extractRevisionNumbers(List queryResults) {
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
for (Object queryResult : queryResults) {
|
||||
result.add(((DefaultRevisionEntity) ((Object[]) queryResult)[1]).getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.envers.query.AuditEntity;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Car;
|
||||
import org.hibernate.envers.test.integration.entityNames.manyToManyAudited
|
||||
.Person;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.integration.entityNames.manyToManyAudited.Person;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -16,6 +14,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Hernán Chanfreau
|
||||
|
@ -25,23 +25,15 @@ import static junit.framework.Assert.assertEquals;
|
|||
public class HasChangedAuditedManyToManyTest extends AbstractModifiedFlagsOneSessionTest{
|
||||
|
||||
private long id_car1;
|
||||
private long id_car2;
|
||||
|
||||
private long id_pers1;
|
||||
private long id_pers2;
|
||||
|
||||
private Person person1;
|
||||
private Car car1;
|
||||
|
||||
private Person person1_1;
|
||||
private Car car1_2;
|
||||
|
||||
protected void initMappings() throws MappingException, URISyntaxException {
|
||||
URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/entityNames/manyToManyAudited/mappings.hbm.xml");
|
||||
config.addFile(new File(url.toURI()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Priority(10)
|
||||
public void initData() {
|
||||
|
@ -80,8 +72,7 @@ public class HasChangedAuditedManyToManyTest extends AbstractModifiedFlagsOneSes
|
|||
getSession().persist(car1);
|
||||
getSession().persist(car2);
|
||||
getSession().getTransaction().commit();
|
||||
id_car2 = car2.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasChangedPerson1() throws Exception {
|
||||
|
@ -90,14 +81,14 @@ public class HasChangedAuditedManyToManyTest extends AbstractModifiedFlagsOneSes
|
|||
.add(AuditEntity.property("cars").hasChanged())
|
||||
.getResultList();
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = getAuditReader().createQuery().forRevisionsOfEntity(Person.class, "Personaje", false, false)
|
||||
.add(AuditEntity.id().eq(id_pers1))
|
||||
.add(AuditEntity.property("cars").hasNotChanged())
|
||||
.getResultList();
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -107,7 +98,7 @@ public class HasChangedAuditedManyToManyTest extends AbstractModifiedFlagsOneSes
|
|||
.add(AuditEntity.property("cars").hasChanged())
|
||||
.getResultList();
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = getAuditReader().createQuery().forRevisionsOfEntity(Person.class, "Personaje", false, false)
|
||||
.add(AuditEntity.id().eq(id_pers2))
|
||||
|
@ -123,7 +114,7 @@ public class HasChangedAuditedManyToManyTest extends AbstractModifiedFlagsOneSes
|
|||
.add(AuditEntity.property("owners").hasChanged())
|
||||
.getResultList();
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = getAuditReader().createQuery().forRevisionsOfEntity(Car.class, false, false)
|
||||
.add(AuditEntity.id().eq(id_car1))
|
||||
|
|
|
@ -25,17 +25,16 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.onetoone.bidirectional
|
||||
.BiRefEdEntity;
|
||||
import org.hibernate.envers.test.integration.onetoone.bidirectional
|
||||
.BiRefIngEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefEdEntity;
|
||||
import org.hibernate.envers.test.integration.onetoone.bidirectional.BiRefIngEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -45,10 +44,7 @@ public class HasChangedBidirectional2 extends AbstractModifiedFlagsEntityTest {
|
|||
private Integer ed1_id;
|
||||
private Integer ed2_id;
|
||||
|
||||
private Integer ing1_id;
|
||||
private Integer ing2_id;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(BiRefEdEntity.class);
|
||||
cfg.addAnnotatedClass(BiRefIngEntity.class);
|
||||
}
|
||||
|
@ -112,20 +108,18 @@ public class HasChangedBidirectional2 extends AbstractModifiedFlagsEntityTest {
|
|||
ed1_id = ed1.getId();
|
||||
ed2_id = ed2.getId();
|
||||
|
||||
ing1_id = ing1.getId();
|
||||
ing2_id = ing2.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(BiRefEdEntity.class, ed1_id,
|
||||
"referencing");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(BiRefEdEntity.class, ed2_id,
|
||||
"referencing");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(4), extractRevisionNumbers(list));
|
||||
}
|
||||
}
|
|
@ -28,13 +28,14 @@ import org.hibernate.ejb.Ejb3Configuration;
|
|||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.ChildEntity;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.ParentEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -73,11 +74,11 @@ public class HasChangedChildAuditing extends AbstractModifiedFlagsEntityTest {
|
|||
public void testChildHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ChildEntity.class, id1, "data");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(ChildEntity.class, id1, "number");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ChildEntity.class, id1, "data");
|
||||
assertEquals(0, list.size());
|
||||
|
@ -90,7 +91,7 @@ public class HasChangedChildAuditing extends AbstractModifiedFlagsEntityTest {
|
|||
public void testParentHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ParentEntity.class, id1, "data");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ParentEntity.class, id1, "data");
|
||||
assertEquals(0, list.size());
|
||||
|
|
|
@ -26,19 +26,17 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation
|
||||
.ChildIngEntity;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation
|
||||
.ParentNotIngEntity;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation
|
||||
.ReferencedEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation.ChildIngEntity;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation.ParentNotIngEntity;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.childrelation.ReferencedEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -47,9 +45,8 @@ import static junit.framework.Assert.assertEquals;
|
|||
public class HasChangedChildReferencing extends AbstractModifiedFlagsEntityTest {
|
||||
private Integer re_id1;
|
||||
private Integer re_id2;
|
||||
private Integer c_id;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(ChildIngEntity.class);
|
||||
cfg.addAnnotatedClass(ParentNotIngEntity.class);
|
||||
cfg.addAnnotatedClass(ReferencedEntity.class);
|
||||
|
@ -62,7 +59,7 @@ public class HasChangedChildReferencing extends AbstractModifiedFlagsEntityTest
|
|||
|
||||
re_id1 = 1;
|
||||
re_id2 = 10;
|
||||
c_id = 100;
|
||||
Integer c_id = 100;
|
||||
|
||||
// Rev 1
|
||||
em.getTransaction().begin();
|
||||
|
@ -102,15 +99,15 @@ public class HasChangedChildReferencing extends AbstractModifiedFlagsEntityTest
|
|||
public void testReferencedEntityHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ReferencedEntity.class, re_id1, "referencing");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ReferencedEntity.class, re_id1, "referencing");
|
||||
assertEquals(1, list.size()); // initially referencing collection is null
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(ReferencedEntity.class, re_id2, "referencing");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(3), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
}
|
|
@ -28,15 +28,15 @@ import org.hibernate.envers.test.Priority;
|
|||
import org.hibernate.envers.test.entities.components.Component1;
|
||||
import org.hibernate.envers.test.entities.components.Component2;
|
||||
import org.hibernate.envers.test.entities.components.ComponentTestEntity;
|
||||
import org.hibernate.envers.test.integration.collection.mapkey
|
||||
.ComponentMapKeyEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.integration.collection.mapkey.ComponentMapKeyEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -97,7 +97,7 @@ public class HasChangedComponentMapKey extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChangedMapEntity() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ComponentMapKeyEntity.class, cmke_id, "idmap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ComponentMapKeyEntity.class,
|
||||
cmke_id, "idmap");
|
||||
|
@ -109,7 +109,7 @@ public class HasChangedComponentMapKey extends AbstractModifiedFlagsEntityTest {
|
|||
List list = queryForPropertyHasChanged(ComponentTestEntity.class,
|
||||
cte1_id, "comp1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ComponentTestEntity.class, cte1_id,
|
||||
"comp1");
|
||||
|
@ -117,7 +117,7 @@ public class HasChangedComponentMapKey extends AbstractModifiedFlagsEntityTest {
|
|||
|
||||
list = queryForPropertyHasChanged(ComponentTestEntity.class, cte2_id, "comp1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ComponentTestEntity.class, cte2_id, "comp1");
|
||||
assertEquals(0, list.size());
|
||||
|
|
|
@ -29,13 +29,14 @@ import org.hibernate.envers.test.Priority;
|
|||
import org.hibernate.envers.test.entities.components.Component1;
|
||||
import org.hibernate.envers.test.entities.components.Component2;
|
||||
import org.hibernate.envers.test.entities.components.ComponentTestEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -130,7 +131,7 @@ public class HasChangedComponents extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChangedId1() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ComponentTestEntity.class, id1, "comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ComponentTestEntity.class, id1, "comp1");
|
||||
assertEquals(0, list.size());
|
||||
|
@ -140,7 +141,7 @@ public class HasChangedComponents extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChangedId2() throws Exception {
|
||||
List list = queryForPropertyHasChangedWithDeleted(ComponentTestEntity.class, id2, "comp1");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChangedWithDeleted(ComponentTestEntity.class, id2, "comp1");
|
||||
assertEquals(0, list.size());
|
||||
|
@ -150,7 +151,7 @@ public class HasChangedComponents extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChangedId3() throws Exception {
|
||||
List list = queryForPropertyHasChangedWithDeleted(ComponentTestEntity.class, id3, "comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChangedWithDeleted(ComponentTestEntity.class, id3, "comp1");
|
||||
assertEquals(0, list.size());
|
||||
|
@ -160,10 +161,10 @@ public class HasChangedComponents extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChangedId4() throws Exception {
|
||||
List list = queryForPropertyHasChangedWithDeleted(ComponentTestEntity.class, id4, "comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChangedWithDeleted(ComponentTestEntity.class, id4, "comp1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,14 @@ import org.hibernate.ejb.Ejb3Configuration;
|
|||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.customtype.Component;
|
||||
import org.hibernate.envers.test.entities.customtype.CompositeCustomTypeEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -89,7 +90,7 @@ public class HasChangedCompositeCustom extends AbstractModifiedFlagsEntityTest {
|
|||
public void testHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(CompositeCustomTypeEntity.class,ccte_id, "component");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(CompositeCustomTypeEntity.class,ccte_id, "component");
|
||||
assertEquals(0, list.size());
|
||||
|
|
|
@ -25,19 +25,17 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached
|
||||
.DoubleListJoinColumnBidirectionalRefEdEntity1;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached
|
||||
.DoubleListJoinColumnBidirectionalRefEdEntity2;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached
|
||||
.DoubleListJoinColumnBidirectionalRefIngEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.DoubleListJoinColumnBidirectionalRefEdEntity1;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.DoubleListJoinColumnBidirectionalRefEdEntity2;
|
||||
import org.hibernate.envers.test.entities.onetomany.detached.DoubleListJoinColumnBidirectionalRefIngEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* Test for a double "fake" bidirectional mapping where one side uses @OneToMany+@JoinColumn
|
||||
|
@ -164,19 +162,19 @@ public class HasChangedDoubleJoinColumnBidirectionalList extends AbstractModifie
|
|||
DoubleListJoinColumnBidirectionalRefEdEntity1.class, ed1_1_id,
|
||||
"owner");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefEdEntity1.class, ed1_1_id,
|
||||
"owner");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(
|
||||
DoubleListJoinColumnBidirectionalRefEdEntity1.class, ed1_2_id,
|
||||
"owner");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1,2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefEdEntity1.class, ed1_2_id,
|
||||
|
@ -190,7 +188,7 @@ public class HasChangedDoubleJoinColumnBidirectionalList extends AbstractModifie
|
|||
DoubleListJoinColumnBidirectionalRefEdEntity2.class, ed2_1_id,
|
||||
"owner");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefEdEntity2.class, ed2_1_id,
|
||||
|
@ -201,13 +199,13 @@ public class HasChangedDoubleJoinColumnBidirectionalList extends AbstractModifie
|
|||
DoubleListJoinColumnBidirectionalRefEdEntity2.class, ed2_2_id,
|
||||
"owner");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefEdEntity2.class, ed2_2_id,
|
||||
"owner");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(3), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -216,13 +214,13 @@ public class HasChangedDoubleJoinColumnBidirectionalList extends AbstractModifie
|
|||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing1_id,
|
||||
"references1");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(
|
||||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing2_id,
|
||||
"references1");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing1_id,
|
||||
|
@ -241,13 +239,13 @@ public class HasChangedDoubleJoinColumnBidirectionalList extends AbstractModifie
|
|||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing1_id,
|
||||
"references2");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(
|
||||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing2_id,
|
||||
"references2");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
DoubleListJoinColumnBidirectionalRefIngEntity.class, ing1_id,
|
||||
|
|
|
@ -28,13 +28,14 @@ import org.hibernate.envers.test.Priority;
|
|||
import org.hibernate.envers.test.entities.collection.EnumSetEntity;
|
||||
import org.hibernate.envers.test.entities.collection.EnumSetEntity.E1;
|
||||
import org.hibernate.envers.test.entities.collection.EnumSetEntity.E2;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -94,12 +95,12 @@ public class HasChangedEnumSet extends AbstractModifiedFlagsEntityTest {
|
|||
List list = queryForPropertyHasChanged(EnumSetEntity.class, sse1_id,
|
||||
"enums1");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(EnumSetEntity.class, sse1_id,
|
||||
"enums2");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(EnumSetEntity.class, sse1_id,
|
||||
"enums1");
|
||||
|
@ -108,6 +109,6 @@ public class HasChangedEnumSet extends AbstractModifiedFlagsEntityTest {
|
|||
list = queryForPropertyHasNotChanged(EnumSetEntity.class, sse1_id,
|
||||
"enums2");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3), extractRevisionNumbers(list));
|
||||
}
|
||||
}
|
|
@ -29,10 +29,8 @@ import org.hibernate.envers.test.Priority;
|
|||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
import org.hibernate.envers.test.entities.components.Component1;
|
||||
import org.hibernate.envers.test.entities.components.Component2;
|
||||
import org.hibernate.envers.test.integration.modifiedflags.entities
|
||||
.NotUsingModifiedFlagsEntity;
|
||||
import org.hibernate.envers.test.integration.modifiedflags.entities.NotUsingModifiedFlagsEntity;
|
||||
import org.hibernate.envers.test.integration.modifiedflags.entities.RefEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
@ -40,6 +38,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Michal Skowronek (mskowr at o2 dot pl)
|
||||
|
@ -113,7 +113,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
refEntity = em.find(RefEntity.class, refEntityId);
|
||||
refEntity.setReference(null);
|
||||
refEntity.setSecondReference(entity);
|
||||
refEntity = em.merge(refEntity);
|
||||
em.merge(refEntity);
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
|
||||
entity.getEntitiesSet().remove(strTestEntity);
|
||||
entity.getEntitiesMap().put("someKey", strTestEntity);
|
||||
entity = em.merge(entity);
|
||||
em.merge(entity);
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
em.getTransaction().begin();
|
||||
|
||||
strTestEntity.setStr("second");
|
||||
strTestEntity = em.merge(strTestEntity);
|
||||
em.merge(strTestEntity);
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
|
@ -184,7 +184,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "data");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -193,7 +193,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "comp1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(3), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test(expected = QueryException.class)
|
||||
|
@ -208,7 +208,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "referencing");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(5, 6), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(5, 6), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test(expected = QueryException.class)
|
||||
|
@ -223,7 +223,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "stringSet");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 7, 8), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 7, 8), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -232,7 +232,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "stringMap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 8), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 8), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -241,7 +241,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "stringSet", "stringMap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 8), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 8), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -250,7 +250,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "entitiesSet");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 10, 11), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 10, 11), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -259,7 +259,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "entitiesMap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 11), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 11), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -268,7 +268,7 @@ public class HasChangedForDefaultNotUsing extends AbstractModifiedFlagsEntityTes
|
|||
NotUsingModifiedFlagsEntity.class,
|
||||
entityId, "entitiesSet", "entitiesMap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 11), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 11), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
}
|
|
@ -27,13 +27,14 @@ import org.hibernate.ejb.Ejb3Configuration;
|
|||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
import org.hibernate.envers.test.integration.collection.mapkey.IdMapKeyEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -42,10 +43,7 @@ import static junit.framework.Assert.assertEquals;
|
|||
public class HasChangedIdMapKey extends AbstractModifiedFlagsEntityTest {
|
||||
private Integer imke_id;
|
||||
|
||||
private Integer ste1_id;
|
||||
private Integer ste2_id;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(IdMapKeyEntity.class);
|
||||
cfg.addAnnotatedClass(StrTestEntity.class);
|
||||
}
|
||||
|
@ -86,16 +84,14 @@ public class HasChangedIdMapKey extends AbstractModifiedFlagsEntityTest {
|
|||
|
||||
imke_id = imke.getId();
|
||||
|
||||
ste1_id = ste1.getId();
|
||||
ste2_id = ste2.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasChanged() throws Exception {
|
||||
List list = queryForPropertyHasChanged(IdMapKeyEntity.class, imke_id,
|
||||
"idmap");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(IdMapKeyEntity.class, imke_id,
|
||||
"idmap");
|
||||
|
|
|
@ -26,17 +26,16 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.ManyToOneComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.ManyToOneComponentTestEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.entities.components.relations.ManyToOneComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations.ManyToOneComponentTestEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -44,10 +43,8 @@ import static junit.framework.Assert.assertEquals;
|
|||
*/
|
||||
public class HasChangedManyToOneInComponent extends AbstractModifiedFlagsEntityTest {
|
||||
private Integer mtocte_id1;
|
||||
private Integer ste_id1;
|
||||
private Integer ste_id2;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(ManyToOneComponentTestEntity.class);
|
||||
cfg.addAnnotatedClass(StrTestEntity.class);
|
||||
}
|
||||
|
@ -90,16 +87,14 @@ public class HasChangedManyToOneInComponent extends AbstractModifiedFlagsEntityT
|
|||
em.getTransaction().commit();
|
||||
|
||||
mtocte_id1 = mtocte1.getId();
|
||||
ste_id1 = ste1.getId();
|
||||
ste_id2 = ste2.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasChangedId1() throws Exception {
|
||||
List list = queryForPropertyHasChanged(ManyToOneComponentTestEntity.class,
|
||||
mtocte_id1, "comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(ManyToOneComponentTestEntity.class,
|
||||
mtocte_id1, "comp1");
|
||||
|
|
|
@ -26,17 +26,16 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.UnversionedStrTestEntity;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.NotAuditedManyToOneComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.NotAuditedManyToOneComponentTestEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations.NotAuditedManyToOneComponentTestEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -106,7 +105,7 @@ public class HasChangedNotAuditedManyToOneInComponent extends AbstractModifiedFl
|
|||
NotAuditedManyToOneComponentTestEntity.class, mtocte_id1,
|
||||
"comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(
|
||||
NotAuditedManyToOneComponentTestEntity.class, mtocte_id1,
|
||||
|
|
|
@ -26,19 +26,17 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined
|
||||
.notownedrelation.Address;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined
|
||||
.notownedrelation.Contact;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined
|
||||
.notownedrelation.PersonalContact;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.notownedrelation.Address;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.notownedrelation.Contact;
|
||||
import org.hibernate.envers.test.integration.inheritance.joined.notownedrelation.PersonalContact;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -95,14 +93,14 @@ public class HasChangedNotOwnedBidirectional extends AbstractModifiedFlagsEntity
|
|||
List list = queryForPropertyHasChanged(PersonalContact.class, pc_id,
|
||||
"addresses");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(Address.class, a1_id, "contact");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(Address.class, a2_id, "contact");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2), extractRevisionNumbers(list));
|
||||
}
|
||||
}
|
|
@ -27,13 +27,14 @@ import org.hibernate.ejb.Ejb3Configuration;
|
|||
import org.hibernate.envers.query.AuditEntity;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.basic.BasicTestEntity1;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -81,29 +82,29 @@ public class HasChangedNullProperties extends AbstractModifiedFlagsEntityTest {
|
|||
List list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class,
|
||||
id1, "str1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class,
|
||||
id1, "long1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class,
|
||||
id2, "str1");
|
||||
// str1 property was null before insert and after insert so in a way it didn't change - is it a good way to go?
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(4), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(4), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChangedWithDeleted(BasicTestEntity1.class,
|
||||
id2, "long1");
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2), extractRevisionNumbers(list));
|
||||
|
||||
list = getAuditReader().createQuery().forRevisionsOfEntity(BasicTestEntity1.class, false, true)
|
||||
.add(AuditEntity.property("str1").hasChanged())
|
||||
.add(AuditEntity.property("long1").hasChanged())
|
||||
.getResultList();
|
||||
assertEquals(1, list.size());
|
||||
assertEquals(TestTools.makeList(1), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1), extractRevisionNumbers(list));
|
||||
}
|
||||
}
|
|
@ -26,17 +26,16 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.OneToManyComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations
|
||||
.OneToManyComponentTestEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.hibernate.envers.test.entities.components.relations.OneToManyComponent;
|
||||
import org.hibernate.envers.test.entities.components.relations.OneToManyComponentTestEntity;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -44,8 +43,6 @@ import static junit.framework.Assert.assertEquals;
|
|||
*/
|
||||
public class HasChangedOneToManyInComponent extends AbstractModifiedFlagsEntityTest {
|
||||
private Integer otmcte_id1;
|
||||
private Integer ste_id1;
|
||||
private Integer ste_id2;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(OneToManyComponentTestEntity.class);
|
||||
|
@ -91,9 +88,7 @@ public class HasChangedOneToManyInComponent extends AbstractModifiedFlagsEntityT
|
|||
em.getTransaction().commit();
|
||||
|
||||
otmcte_id1 = otmcte1.getId();
|
||||
ste_id1 = ste1.getId();
|
||||
ste_id2 = ste2.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasChangedId1() throws Exception {
|
||||
|
@ -101,7 +96,7 @@ public class HasChangedOneToManyInComponent extends AbstractModifiedFlagsEntityT
|
|||
queryForPropertyHasChanged(OneToManyComponentTestEntity.class,
|
||||
otmcte_id1, "comp1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(OneToManyComponentTestEntity.class,
|
||||
otmcte_id1, "comp1");
|
||||
|
|
|
@ -26,13 +26,14 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.collection.StringMapEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -108,12 +109,12 @@ public class HasChangedStringMap extends AbstractModifiedFlagsEntityTest {
|
|||
List list = queryForPropertyHasChanged(StringMapEntity.class, sme1_id,
|
||||
"strings");
|
||||
assertEquals(3, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(StringMapEntity.class, sme2_id,
|
||||
"strings");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(StringMapEntity.class, sme1_id,
|
||||
"strings");
|
||||
|
|
|
@ -26,13 +26,14 @@ package org.hibernate.envers.test.integration.modifiedflags;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.entities.collection.StringSetEntity;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -100,12 +101,12 @@ public class HasChangedStringSet extends AbstractModifiedFlagsEntityTest {
|
|||
List list = queryForPropertyHasChanged(StringSetEntity.class, sse1_id,
|
||||
"strings");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasChanged(StringSetEntity.class, sse2_id,
|
||||
"strings");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 3), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 3), extractRevisionNumbers(list));
|
||||
|
||||
list = queryForPropertyHasNotChanged(StringSetEntity.class, sse1_id,
|
||||
"strings");
|
||||
|
|
|
@ -27,13 +27,14 @@ import org.hibernate.QueryException;
|
|||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.Priority;
|
||||
import org.hibernate.envers.test.integration.basic.BasicTestEntity2;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hibernate.envers.test.tools.TestTools.extractRevisionNumbers;
|
||||
import static org.hibernate.envers.test.tools.TestTools.makeList;
|
||||
|
||||
/**
|
||||
* @author Adam Warski (adam at warski dot org)
|
||||
|
@ -79,7 +80,7 @@ public class HasChangedUnversionedProperties extends AbstractModifiedFlagsEntity
|
|||
List list = queryForPropertyHasChanged(BasicTestEntity2.class,
|
||||
id1, "str1");
|
||||
assertEquals(2, list.size());
|
||||
assertEquals(TestTools.makeList(1, 2), extractRevisionNumbers(list));
|
||||
assertEquals(makeList(1, 2), extractRevisionNumbers(list));
|
||||
}
|
||||
|
||||
@Test(expected = QueryException.class)
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.envers.test.tools;
|
||||
|
||||
import org.hibernate.envers.DefaultRevisionEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -71,4 +75,13 @@ public class TestTools {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<Integer> extractRevisionNumbers(List queryResults) {
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
for (Object queryResult : queryResults) {
|
||||
result.add(((DefaultRevisionEntity) ((Object[]) queryResult)[1])
|
||||
.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue