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