From f4b410a65e35e1685d09f2ff608423b8a367e2b5 Mon Sep 17 00:00:00 2001 From: Felix Feisst Date: Fri, 16 May 2014 16:42:18 +0200 Subject: [PATCH] Added unit test for issue HHH-9199 (cherry picked from commit 85eca1aa01da77dec8b5fe8212e2f8e7938b2879) --- .../integration/collection/EmbeddableSet.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/EmbeddableSet.java diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/EmbeddableSet.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/EmbeddableSet.java new file mode 100644 index 0000000000..06d6ef9d8f --- /dev/null +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/EmbeddableSet.java @@ -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() ); + } + +}