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.Priority;
import org.hibernate.testing.FailureExpected;
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" )
public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFunctionalTestCase {
private Integer id1;
@ -84,6 +84,7 @@ public class CollectionOfMappedSuperclassComponentsTest extends BaseEnversJPAFun
}
@Test
@FailureExpected( jiraKey = "HHH-9193")
public void testHistoryOfId1() {
MappedSuperclassComponentSetTestEntity entity = getAuditReader().find(
MappedSuperclassComponentSetTestEntity.class,
@ -94,9 +95,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<Code> 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.
}
}

View File

@ -34,13 +34,14 @@ 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.TestForIssue;
/**
* @author Jakob Braeuchi.
* @author Gail Badner
*/
@TestForIssue(jiraKey = "HHH-8908")
@TestForIssue(jiraKey = "HHH-9193")
public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
private long id;
@ -68,6 +69,7 @@ public class EmbeddableWithDeclaredDataTest extends BaseEnversJPAFunctionalTestC
}
@Test
@FailureExpected( jiraKey = "HHH-9193" )
public void testEmbeddableThatExtendsMappedSuperclass() {
// Reload and Compare Revision
@ -83,7 +85,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() );
}
}

View File

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

View File

@ -40,7 +40,7 @@ import org.hibernate.testing.TestForIssue;
* @author Jakob Braeuchi.
* @author Gail Badner
*/
@TestForIssue(jiraKey = "HHH-8908")
@TestForIssue(jiraKey = "HHH-9193")
public class EmbeddableWithNoDeclaredDataTest extends BaseEnversJPAFunctionalTestCase {
private long id;
@ -83,7 +83,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() );
}
}