From 1f7d90de8b6ba9bf6495e023e667eebd89b6e4aa Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 16 May 2014 14:36:21 -0700 Subject: [PATCH] HHH-9193 : Default audit behavior of mapped-superclass (test cases) (cherry picked from commit 95070f50a9a1e4d7fb0e2ff06331a4c9ef440187) Conflicts: hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/collections/mappedsuperclasselement/CollectionOfMappedSuperclassComponentsTest.java hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithDeclaredDataTest.java hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredDataTest.java --- ...ollectionOfMappedSuperclassComponentsTest.java | 15 +++++++++++---- .../EmbeddableWithDeclaredDataTest.java | 10 +++++++--- .../EmbeddableWithNoDeclaredData.java | 1 - .../EmbeddableWithNoDeclaredDataTest.java | 7 ++++--- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/collections/mappedsuperclasselement/CollectionOfMappedSuperclassComponentsTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/collections/mappedsuperclasselement/CollectionOfMappedSuperclassComponentsTest.java index b6e21be8e5..2ebd503ee9 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/collections/mappedsuperclasselement/CollectionOfMappedSuperclassComponentsTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/collections/mappedsuperclasselement/CollectionOfMappedSuperclassComponentsTest.java @@ -31,16 +31,16 @@ import org.junit.Test; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; +import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.TestForIssue; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; /** * @author Gail Badner */ -@TestForIssue( jiraKey = "HHH-8908" ) +@TestForIssue( jiraKey = "HHH-9193" ) @FailureExpectedWithNewMetamodel( message = "Aggregate.getSuperType() returns null when it should return a MappedSuperclass") public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFunctionalTestCase { private Integer id1; @@ -86,6 +86,7 @@ public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFun } @Test + @FailureExpected( jiraKey = "HHH-9193") public void testHistoryOfId1() { MappedSuperclassComponentSetTestEntity entity = getAuditReader().find( MappedSuperclassComponentSetTestEntity.class, @@ -96,9 +97,15 @@ public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFun assertEquals( 0, entity.getCompsNotAudited().size() ); entity = getAuditReader().find( MappedSuperclassComponentSetTestEntity.class, id1, 2 ); + + // TODO: what is the expectation here? The collection is audited, but the embeddable class + // has no data and it extends a mapped-superclass that is not audited. + // currently the collection has 1 element that has value AbstractCode.UNDEFINED + // (which seems wrong). I changed the expected size to 0 which currently fails; is that what + // should be expected? Set comps1 = entity.getComps(); - assertEquals( 1, comps1.size() ); - assertTrue( comps1.contains( new Code( 1 ) ) ); + assertEquals( 0, comps1.size() ); + // The contents of entity.getCompsNotAudited() is unspecified, so no need to test. } } \ No newline at end of file diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithDeclaredDataTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithDeclaredDataTest.java index 5494cc8415..a1674a48d6 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithDeclaredDataTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithDeclaredDataTest.java @@ -34,6 +34,7 @@ import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; +import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.TestForIssue; @@ -41,7 +42,7 @@ import org.hibernate.testing.TestForIssue; * @author Jakob Braeuchi. * @author Gail Badner */ -@TestForIssue(jiraKey = "HHH-8908") +@TestForIssue(jiraKey = "HHH-9193") @FailureExpectedWithNewMetamodel( message = "Aggregate.getSuperType() returns null when it should return a MappedSuperclass") public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestCase { private long id; @@ -70,6 +71,7 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC } @Test + @FailureExpected( jiraKey = "HHH-9193" ) public void testEmbeddableThatExtendsMappedSuperclass() { // Reload and Compare Revision @@ -85,7 +87,9 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() ); - // value is read from AUD Table - Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() ); + // only value.codeArt should be audited because it is the only audited field in EmbeddableWithDeclaredData; + // fields in AbstractEmbeddable should not be audited. + Assert.assertEquals( entityLoaded.getValue().getCodeart(), entityRev1.getValue().getCodeart() ); + Assert.assertNull( entityRev1.getValue().getCode() ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredData.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredData.java index 4a38cbc72e..4d2bea6312 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredData.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredData.java @@ -24,7 +24,6 @@ package org.hibernate.envers.test.integration.components.mappedsuperclass; import javax.persistence.Embeddable; -import javax.persistence.Transient; /** * @author Jakob Braeuchi. diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredDataTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredDataTest.java index e7cf4cd294..83c55edb3d 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredDataTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/components/mappedsuperclass/EmbeddableWithNoDeclaredDataTest.java @@ -41,7 +41,7 @@ import org.hibernate.testing.TestForIssue; * @author Jakob Braeuchi. * @author Gail Badner */ -@TestForIssue(jiraKey = "HHH-8908") +@TestForIssue(jiraKey = "HHH-9193") @FailureExpectedWithNewMetamodel( message = "Aggregate.getSuperType() returns null when it should return a MappedSuperclass") public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTestCase { private long id; @@ -85,7 +85,8 @@ public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTes Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() ); - // value is read from AUD Table - Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() ); + // value should be null because there is no data in EmbeddableWithNoDeclaredData + // and the fields in AbstractEmbeddable should not be audited. + Assert.assertNull( entityRev1.getValue() ); } }