Added unit test for issue HHH-9199
(cherry picked from commit 85eca1aa01
)
This commit is contained in:
parent
a06160cf68
commit
f4b410a65e
|
@ -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