Added unit test for issue HHH-9199
This commit is contained in:
parent
799ab91cf5
commit
85eca1aa01
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.hibernate.envers.test.integration.collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||
import org.hibernate.envers.test.entities.collection.EmbeddableSetEntity;
|
||||
import org.hibernate.envers.test.entities.components.Component3;
|
||||
import org.hibernate.envers.test.tools.TestTools;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Felix Feisst (feisst dot felix at gmail dot com)
|
||||
*/
|
||||
public class EmbeddableSet extends BaseEnversJPAFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] { EmbeddableSetEntity.class };
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoval() {
|
||||
EntityManager em = getEntityManager();
|
||||
|
||||
final Component3 comp1 = new Component3( "comp1", null, null );
|
||||
final Component3 comp2 = new Component3( "comp2", null, null );
|
||||
|
||||
EmbeddableSetEntity entity = new EmbeddableSetEntity();
|
||||
|
||||
em.getTransaction().begin();
|
||||
|
||||
entity.getComponentSet().add( comp1 );
|
||||
entity.getComponentSet().add( comp2 );
|
||||
|
||||
em.persist( entity );
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
em.getTransaction().begin();
|
||||
|
||||
entity.getComponentSet().remove( comp1 );
|
||||
|
||||
em.getTransaction().commit();
|
||||
|
||||
EmbeddableSetEntity rev1 = getAuditReader().find( EmbeddableSetEntity.class, entity.getId(), 1 );
|
||||
EmbeddableSetEntity rev2 = getAuditReader().find( EmbeddableSetEntity.class, entity.getId(), 2 );
|
||||
assertEquals( "Unexpected components", TestTools.makeSet( comp1, comp2 ), rev1.getComponentSet() );
|
||||
assertEquals( "Unexpected components", TestTools.makeSet( comp2 ), rev2.getComponentSet() );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue