Search in sources :

Example 1 with EnumMapEntity

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

the class EnumMapTest method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getOrCreateEntityManager();
    try {
        // revision 1
        EnumMapEntity entity = new EnumMapEntity();
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_A, new EnumMapType("A"));
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_B, new EnumMapType("B"));
        em.getTransaction().begin();
        em.persist(entity);
        em.getTransaction().commit();
        // revision 2
        em.getTransaction().begin();
        entity = em.find(EnumMapEntity.class, entity.getId());
        entity.getTypes().remove(EnumMapEntity.EnumType.TYPE_A);
        entity.getTypes().put(EnumMapEntity.EnumType.TYPE_C, new EnumMapType("C"));
        em.getTransaction().commit();
        entityId = entity.getId();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) EnumMapType(org.hibernate.envers.test.entities.collection.EnumMapType) EnumMapEntity(org.hibernate.envers.test.entities.collection.EnumMapEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 2 with EnumMapEntity

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

the class EnumMapTest method testAuditEnumMapCollection.

@Test
public void testAuditEnumMapCollection() {
    EnumMapEntity rev1 = getAuditReader().find(EnumMapEntity.class, entityId, 1);
    assertTrue(rev1.getTypes().keySet().containsAll(Arrays.asList(EnumMapEntity.EnumType.TYPE_A, EnumMapEntity.EnumType.TYPE_B)));
    EnumMapEntity rev2 = getAuditReader().find(EnumMapEntity.class, entityId, 2);
    assertTrue(rev2.getTypes().keySet().containsAll(Arrays.asList(EnumMapEntity.EnumType.TYPE_B, EnumMapEntity.EnumType.TYPE_C)));
}
Also used : EnumMapEntity(org.hibernate.envers.test.entities.collection.EnumMapEntity) Test(org.junit.Test)

Aggregations

EnumMapEntity (org.hibernate.envers.test.entities.collection.EnumMapEntity)2 Test (org.junit.Test)2 EntityManager (javax.persistence.EntityManager)1 Priority (org.hibernate.envers.test.Priority)1 EnumMapType (org.hibernate.envers.test.entities.collection.EnumMapType)1