HHH-9193 : Default audit behavior of mapped-superclass (test cases)

This commit is contained in:
Gail Badner 2014-05-16 14:36:21 -07:00
parent 27da278f07
commit 95070f50a9
4 changed files with 22 additions and 11 deletions

View File

@ -31,15 +31,15 @@ import org.junit.Test;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.Priority;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@TestForIssue( jiraKey = "HHH-8908" ) @TestForIssue( jiraKey = "HHH-9193" )
public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFunctionalTestCase { public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFunctionalTestCase {
private Integer id1; private Integer id1;
@ -84,6 +84,7 @@ public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFun
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-9193")
public void testHistoryOfId1() { public void testHistoryOfId1() {
MappedSuperclassComponentSetTestEntity entity = getAuditReader().find( MappedSuperclassComponentSetTestEntity entity = getAuditReader().find(
MappedSuperclassComponentSetTestEntity.class, MappedSuperclassComponentSetTestEntity.class,
@ -94,9 +95,15 @@ public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFun
assertEquals( 0, entity.getCompsNotAudited().size() ); assertEquals( 0, entity.getCompsNotAudited().size() );
entity = getAuditReader().find( MappedSuperclassComponentSetTestEntity.class, id1, 2 ); 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<Code> comps1 = entity.getComps(); Set<Code> comps1 = entity.getComps();
assertEquals( 1, comps1.size() ); assertEquals( 0, comps1.size() );
assertTrue( comps1.contains( new Code( 1 ) ) );
// The contents of entity.getCompsNotAudited() is unspecified, so no need to test. // The contents of entity.getCompsNotAudited() is unspecified, so no need to test.
} }
} }

View File

@ -34,13 +34,14 @@ import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.AuditReaderFactory;
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.Priority;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
/** /**
* @author Jakob Braeuchi. * @author Jakob Braeuchi.
* @author Gail Badner * @author Gail Badner
*/ */
@TestForIssue(jiraKey = "HHH-8908") @TestForIssue(jiraKey = "HHH-9193")
public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestCase { public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
private long id; private long id;
@ -68,6 +69,7 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-9193" )
public void testEmbeddableThatExtendsMappedSuperclass() { public void testEmbeddableThatExtendsMappedSuperclass() {
// Reload and Compare Revision // Reload and Compare Revision
@ -83,7 +85,9 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() ); Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
// value is read from AUD Table // only value.codeArt should be audited because it is the only audited field in EmbeddableWithDeclaredData;
Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() ); // fields in AbstractEmbeddable should not be audited.
Assert.assertEquals( entityLoaded.getValue().getCodeart(), entityRev1.getValue().getCodeart() );
Assert.assertNull( entityRev1.getValue().getCode() );
} }
} }

View File

@ -24,7 +24,6 @@
package org.hibernate.envers.test.integration.components.mappedsuperclass; package org.hibernate.envers.test.integration.components.mappedsuperclass;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.persistence.Transient;
/** /**
* @author Jakob Braeuchi. * @author Jakob Braeuchi.

View File

@ -40,7 +40,7 @@ import org.hibernate.testing.TestForIssue;
* @author Jakob Braeuchi. * @author Jakob Braeuchi.
* @author Gail Badner * @author Gail Badner
*/ */
@TestForIssue(jiraKey = "HHH-8908") @TestForIssue(jiraKey = "HHH-9193")
public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTestCase { public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
private long id; private long id;
@ -83,7 +83,8 @@ public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTes
Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() ); Assert.assertEquals( entityLoaded.getName(), entityRev1.getName() );
// value is read from AUD Table // value should be null because there is no data in EmbeddableWithNoDeclaredData
Assert.assertEquals( entityLoaded.getValue(), entityRev1.getValue() ); // and the fields in AbstractEmbeddable should not be audited.
Assert.assertNull( entityRev1.getValue() );
} }
} }