Search in sources :

Example 66 with StrTestEntity

use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.

the class Listener method testHistoryOfId1.

@Test
public void testHistoryOfId1() {
    StrTestEntity ver1 = new StrTestEntity("x", id);
    StrTestEntity ver2 = new StrTestEntity("y", id);
    assert getAuditReader().find(StrTestEntity.class, id, 1).equals(ver1);
    assert getAuditReader().find(StrTestEntity.class, id, 2).equals(ver2);
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Example 67 with StrTestEntity

use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.

the class Listener method initData.

@Test
@Priority(10)
public void initData() throws InterruptedException {
    timestamp1 = System.currentTimeMillis();
    Thread.sleep(100);
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    TestRevisionListener.data = "data1";
    StrTestEntity te = new StrTestEntity("x");
    em.persist(te);
    id = te.getId();
    em.getTransaction().commit();
    timestamp2 = System.currentTimeMillis();
    Thread.sleep(100);
    // Revision 2
    em.getTransaction().begin();
    te = em.find(StrTestEntity.class, id);
    TestRevisionListener.data = "data2";
    te.setStr("y");
    em.getTransaction().commit();
    timestamp3 = System.currentTimeMillis();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 68 with StrTestEntity

use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.

the class DefaultTrackingEntitiesTest method testTrackAddedEntitiesGroupByRevisionType.

@Test
public void testTrackAddedEntitiesGroupByRevisionType() {
    StrTestEntity ste = new StrTestEntity("x", steId);
    StrIntTestEntity site = new StrIntTestEntity("y", 1, siteId);
    Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType(1);
    assert TestTools.checkCollection(result.get(RevisionType.ADD), site, ste);
    assert TestTools.checkCollection(result.get(RevisionType.MOD));
    assert TestTools.checkCollection(result.get(RevisionType.DEL));
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) RevisionType(org.hibernate.envers.RevisionType) List(java.util.List) Test(org.junit.Test)

Example 69 with StrTestEntity

use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.

the class DefaultTrackingEntitiesTest method testFindChangedEntitiesByRevisionTypeADD.

@Test
public void testFindChangedEntitiesByRevisionTypeADD() {
    StrTestEntity ste = new StrTestEntity("x", steId);
    StrIntTestEntity site = new StrIntTestEntity("y", 1, siteId);
    assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(1, RevisionType.ADD), ste, site);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Example 70 with StrTestEntity

use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.

the class TrackingEntitiesMultipleChangesTest method testTrackAddedTwoEntities.

@Test
public void testTrackAddedTwoEntities() {
    StrTestEntity ste1 = new StrTestEntity("x", steId1);
    StrTestEntity ste2 = new StrTestEntity("y", steId2);
    Assert.assertEquals(TestTools.makeSet(ste1, ste2), new HashSet<Object>(getCrossTypeRevisionChangesReader().findEntities(1)));
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Aggregations

StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)103 Test (org.junit.Test)99 EntityManager (javax.persistence.EntityManager)51 Priority (org.hibernate.envers.test.Priority)48 Session (org.hibernate.Session)8 StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)8 TestForIssue (org.hibernate.testing.TestForIssue)5 ListRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity)4 SetRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.SetRefCollEntity)4 ManyToOneComponent (org.hibernate.envers.test.entities.components.relations.ManyToOneComponent)3 ManyToOneComponentTestEntity (org.hibernate.envers.test.entities.components.relations.ManyToOneComponentTestEntity)3 OneToManyComponent (org.hibernate.envers.test.entities.components.relations.OneToManyComponent)3 OneToManyComponentTestEntity (org.hibernate.envers.test.entities.components.relations.OneToManyComponentTestEntity)3 SortedSetEntity (org.hibernate.envers.test.entities.manytomany.SortedSetEntity)3 ListUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.ListUniEntity)3 SetUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.SetUniEntity)3 List (java.util.List)2 RevisionType (org.hibernate.envers.RevisionType)2 JoinTableEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.JoinTableEntity)2 MapUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.MapUniEntity)2