Search in sources :

Example 1 with StrIntTestEntity

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

the class DefaultTrackingEntitiesTest method testTrackAddedEntities.

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

Example 2 with StrIntTestEntity

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

the class DefaultTrackingEntitiesTest method testTrackModifiedEntitiesGroupByRevisionType.

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

Example 3 with StrIntTestEntity

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

the class DefaultTrackingEntitiesTest method testTrackDeletedEntities.

@Test
public void testTrackDeletedEntities() {
    StrTestEntity ste = new StrTestEntity(null, steId);
    StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
    assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(3), site, ste);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Example 4 with StrIntTestEntity

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

the class DefaultTrackingEntitiesTest method testTrackDeletedEntitiesGroupByRevisionType.

@Test
public void testTrackDeletedEntitiesGroupByRevisionType() {
    StrTestEntity ste = new StrTestEntity(null, steId);
    StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
    Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType(3);
    assert TestTools.checkCollection(result.get(RevisionType.ADD));
    assert TestTools.checkCollection(result.get(RevisionType.MOD));
    assert TestTools.checkCollection(result.get(RevisionType.DEL), site, ste);
}
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 5 with StrIntTestEntity

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

the class NullPropertyQuery method initData.

@Test
@Priority(10)
public void initData() {
    // Revision 1
    EntityManager em = getEntityManager();
    em.getTransaction().begin();
    StrIntTestEntity nullSite = new StrIntTestEntity(null, 1);
    StrIntTestEntity notNullSite = new StrIntTestEntity("data", 2);
    em.persist(nullSite);
    em.persist(notNullSite);
    idSimplePropertyNull = nullSite.getId();
    idSimplePropertyNotNull = notNullSite.getId();
    em.getTransaction().commit();
    // Revision 2
    em.getTransaction().begin();
    SetRefIngEmbIdEntity nullParentSrieie = new SetRefIngEmbIdEntity(idMulticolumnReferenceToParentNull, "data", null);
    em.persist(nullParentSrieie);
    em.getTransaction().commit();
    // Revision 3
    em.getTransaction().begin();
    CollectionRefEdEntity parent = new CollectionRefEdEntity(idParent, "data");
    CollectionRefIngEntity notNullParentCrie = new CollectionRefIngEntity(idReferenceToParentNotNull, "data", parent);
    em.persist(parent);
    em.persist(notNullParentCrie);
    em.getTransaction().commit();
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) EntityManager(javax.persistence.EntityManager) SetRefIngEmbIdEntity(org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity) CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)36 Test (org.junit.Test)36 List (java.util.List)14 EntityManager (javax.persistence.EntityManager)12 Priority (org.hibernate.envers.test.Priority)12 StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)8 TestForIssue (org.hibernate.testing.TestForIssue)7 RevisionType (org.hibernate.envers.RevisionType)6 HashSet (java.util.HashSet)3 AuditDisjunction (org.hibernate.envers.query.criteria.AuditDisjunction)2 AuditCriterion (org.hibernate.envers.query.criteria.AuditCriterion)1 EmbId (org.hibernate.envers.test.entities.ids.EmbId)1 EmbIdTestEntity (org.hibernate.envers.test.entities.ids.EmbIdTestEntity)1 MulId (org.hibernate.envers.test.entities.ids.MulId)1 MulIdTestEntity (org.hibernate.envers.test.entities.ids.MulIdTestEntity)1 CollectionRefEdEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity)1 CollectionRefIngEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity)1 SetRefIngEmbIdEntity (org.hibernate.envers.test.entities.onetomany.ids.SetRefIngEmbIdEntity)1