diff options
author | kmoore | 2008-02-04 15:53:33 +0000 |
---|---|---|
committer | kmoore | 2008-02-04 15:53:33 +0000 |
commit | ba3c7d583caf5e1db6312af7e4664ef23fbad5ae (patch) | |
tree | bd8b6e16a9428e4ce9f6a0ebea66f5ac2adadbdc | |
parent | 69e7f6ec3691b0df5a55ef1dae79b1eb45c88c21 (diff) | |
download | webtools.dali-ba3c7d583caf5e1db6312af7e4664ef23fbad5ae.tar.gz webtools.dali-ba3c7d583caf5e1db6312af7e4664ef23fbad5ae.tar.xz webtools.dali-ba3c7d583caf5e1db6312af7e4664ef23fbad5ae.zip |
cleaning up type mapping morphing tests, several mistakes
3 files changed, 59 insertions, 25 deletions
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java index 2e69d1452d..1e2d1fa84f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddableTests.java @@ -19,7 +19,6 @@ import org.eclipse.jpt.core.internal.context.base.IMappedSuperclass; import org.eclipse.jpt.core.internal.context.java.JavaNullTypeMapping; import org.eclipse.jpt.core.internal.resource.java.Embeddable; import org.eclipse.jpt.core.internal.resource.java.JPA; -import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource; import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource; import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase; import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; @@ -59,8 +58,7 @@ public class JavaEmbeddableTests extends ContextModelTestCase assertTrue(javaPersistentType().getMapping() instanceof IEntity); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); - JavaPersistentAttributeResource attributeResource = typeResource.attributes().next(); - assertNull(attributeResource.mappingAnnotation(Embeddable.ANNOTATION_NAME)); + assertNull(typeResource.mappingAnnotation(Embeddable.ANNOTATION_NAME)); } public void testMorphToMappedSuperclass() throws Exception { @@ -71,8 +69,7 @@ public class JavaEmbeddableTests extends ContextModelTestCase assertTrue(javaPersistentType().getMapping() instanceof IMappedSuperclass); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); - JavaPersistentAttributeResource attributeResource = typeResource.attributes().next(); - assertNull(attributeResource.mappingAnnotation(Embeddable.ANNOTATION_NAME)); + assertNull(typeResource.mappingAnnotation(Embeddable.ANNOTATION_NAME)); } public void testMorphToNull() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java index 3fb053666a..c89b7c13e2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEntityTests.java @@ -50,7 +50,6 @@ import org.eclipse.jpt.core.internal.resource.java.Entity; import org.eclipse.jpt.core.internal.resource.java.IdClass; import org.eclipse.jpt.core.internal.resource.java.Inheritance; import org.eclipse.jpt.core.internal.resource.java.JPA; -import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource; import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource; import org.eclipse.jpt.core.internal.resource.java.JavaResource; import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueries; @@ -345,25 +344,34 @@ public class JavaEntityTests extends ContextModelTestCase entity.addSpecifiedSecondaryTable(0); entity.addSpecifiedPrimaryKeyJoinColumn(0); entity.addSpecifiedAttributeOverride(0); + entity.addSpecifiedAssociationOverride(0); entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED); entity.setSpecifiedDiscriminatorValue("asdf"); + entity.getDiscriminatorColumn().setSpecifiedName("BAR"); entity.addTableGenerator(); entity.addSequenceGenerator(); + entity.setIdClass("myIdClass"); + entity.addNamedNativeQuery(0); + entity.addNamedQuery(0); javaPersistentType().setMappingKey(IMappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof IMappedSuperclass); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); - JavaPersistentAttributeResource attributeResource = typeResource.attributes().next(); - assertNull(attributeResource.mappingAnnotation(Entity.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(Table.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(SecondaryTable.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(PrimaryKeyJoinColumn.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(AttributeOverride.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(Inheritance.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(DiscriminatorValue.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(TableGenerator.ANNOTATION_NAME)); - assertNull(attributeResource.annotation(SequenceGenerator.ANNOTATION_NAME)); + assertNull(typeResource.mappingAnnotation(Entity.ANNOTATION_NAME)); + assertNull(typeResource.annotation(Table.ANNOTATION_NAME)); + assertNull(typeResource.annotation(SecondaryTable.ANNOTATION_NAME)); + assertNull(typeResource.annotation(PrimaryKeyJoinColumn.ANNOTATION_NAME)); + assertNull(typeResource.annotation(AttributeOverride.ANNOTATION_NAME)); + assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME)); + assertNull(typeResource.annotation(Inheritance.ANNOTATION_NAME)); + assertNull(typeResource.annotation(DiscriminatorValue.ANNOTATION_NAME)); + assertNull(typeResource.annotation(DiscriminatorColumn.ANNOTATION_NAME)); + assertNull(typeResource.annotation(TableGenerator.ANNOTATION_NAME)); + assertNull(typeResource.annotation(SequenceGenerator.ANNOTATION_NAME)); + assertNotNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedQuery.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedNativeQuery.ANNOTATION_NAME)); } public void testMorphToEmbeddable() throws Exception { @@ -375,10 +383,15 @@ public class JavaEntityTests extends ContextModelTestCase entity.addSpecifiedSecondaryTable(0); entity.addSpecifiedPrimaryKeyJoinColumn(0); entity.addSpecifiedAttributeOverride(0); + entity.addSpecifiedAssociationOverride(0); entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED); entity.setSpecifiedDiscriminatorValue("asdf"); + entity.getDiscriminatorColumn().setSpecifiedName("BAR"); entity.addTableGenerator(); entity.addSequenceGenerator(); + entity.setIdClass("myIdClass"); + entity.addNamedNativeQuery(0); + entity.addNamedQuery(0); javaPersistentType().setMappingKey(IMappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof IEmbeddable); @@ -389,10 +402,15 @@ public class JavaEntityTests extends ContextModelTestCase assertNull(typeResource.annotation(SecondaryTable.ANNOTATION_NAME)); assertNull(typeResource.annotation(PrimaryKeyJoinColumn.ANNOTATION_NAME)); assertNull(typeResource.annotation(AttributeOverride.ANNOTATION_NAME)); + assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME)); assertNull(typeResource.annotation(Inheritance.ANNOTATION_NAME)); assertNull(typeResource.annotation(DiscriminatorValue.ANNOTATION_NAME)); + assertNull(typeResource.annotation(DiscriminatorColumn.ANNOTATION_NAME)); assertNull(typeResource.annotation(TableGenerator.ANNOTATION_NAME)); assertNull(typeResource.annotation(SequenceGenerator.ANNOTATION_NAME)); + assertNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedQuery.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedNativeQuery.ANNOTATION_NAME)); } public void testMorphToNull() throws Exception { @@ -404,10 +422,15 @@ public class JavaEntityTests extends ContextModelTestCase entity.addSpecifiedSecondaryTable(0); entity.addSpecifiedPrimaryKeyJoinColumn(0); entity.addSpecifiedAttributeOverride(0); + entity.addSpecifiedAssociationOverride(0); entity.setSpecifiedInheritanceStrategy(InheritanceType.JOINED); entity.setSpecifiedDiscriminatorValue("asdf"); + entity.getDiscriminatorColumn().setSpecifiedName("BAR"); entity.addTableGenerator(); entity.addSequenceGenerator(); + entity.setIdClass("myIdClass"); + entity.addNamedNativeQuery(0); + entity.addNamedQuery(0); javaPersistentType().setMappingKey(IMappingKeys.NULL_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof JavaNullTypeMapping); @@ -418,10 +441,15 @@ public class JavaEntityTests extends ContextModelTestCase assertNull(typeResource.annotation(SecondaryTable.ANNOTATION_NAME)); assertNull(typeResource.annotation(PrimaryKeyJoinColumn.ANNOTATION_NAME)); assertNull(typeResource.annotation(AttributeOverride.ANNOTATION_NAME)); + assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME)); assertNull(typeResource.annotation(Inheritance.ANNOTATION_NAME)); assertNull(typeResource.annotation(DiscriminatorValue.ANNOTATION_NAME)); + assertNull(typeResource.annotation(DiscriminatorColumn.ANNOTATION_NAME)); assertNull(typeResource.annotation(TableGenerator.ANNOTATION_NAME)); assertNull(typeResource.annotation(SequenceGenerator.ANNOTATION_NAME)); + assertNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedQuery.ANNOTATION_NAME)); + assertNull(typeResource.annotation(NamedNativeQuery.ANNOTATION_NAME)); } public void testAccessNoAnnotations() throws Exception { @@ -597,21 +625,21 @@ public class JavaEntityTests extends ContextModelTestCase addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); createTestEntityWithName(); - assertEquals(ENTITY_NAME, javaEntity().getTableName()); + assertEquals(ENTITY_NAME, javaEntity().tableName()); } public void testGetTableName2() throws Exception { createTestEntity(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - assertEquals(TYPE_NAME, javaEntity().getTableName()); + assertEquals(TYPE_NAME, javaEntity().tableName()); } public void testGetTableName3() throws Exception { createTestEntityWithTable(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - assertEquals(TABLE_NAME, javaEntity().getTableName()); + assertEquals(TABLE_NAME, javaEntity().tableName()); } public void testSetTableNameWithNullTable() throws Exception { @@ -625,7 +653,7 @@ public class JavaEntityTests extends ContextModelTestCase table.setSpecifiedName(TABLE_NAME); assertSourceContains("@Table(name=\"" + TABLE_NAME + "\")"); - assertEquals(TABLE_NAME, javaEntity().getTableName()); + assertEquals(TABLE_NAME, javaEntity().tableName()); assertEquals(TABLE_NAME, table.getName()); table.setSpecifiedCatalog(TABLE_NAME); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java index f0275ba494..111753d8f2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaMappedSuperclassTests.java @@ -19,7 +19,6 @@ import org.eclipse.jpt.core.internal.context.base.IMappedSuperclass; import org.eclipse.jpt.core.internal.context.java.JavaNullTypeMapping; import org.eclipse.jpt.core.internal.resource.java.IdClass; import org.eclipse.jpt.core.internal.resource.java.JPA; -import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource; import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource; import org.eclipse.jpt.core.internal.resource.java.MappedSuperclass; import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase; @@ -56,35 +55,45 @@ public class JavaMappedSuperclassTests extends ContextModelTestCase createTestMappedSuperclass(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping(); + mappedSuperclass.setIdClass("myIdClass"); + javaPersistentType().setMappingKey(IMappingKeys.ENTITY_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof IEntity); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); - JavaPersistentAttributeResource attributeResource = typeResource.attributes().next(); - assertNull(attributeResource.mappingAnnotation(MappedSuperclass.ANNOTATION_NAME)); + assertNull(typeResource.mappingAnnotation(MappedSuperclass.ANNOTATION_NAME)); + assertNotNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); } public void testMorphToEmbeddable() throws Exception { createTestMappedSuperclass(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping(); + mappedSuperclass.setIdClass("myIdClass"); + javaPersistentType().setMappingKey(IMappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof IEmbeddable); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); - JavaPersistentAttributeResource attributeResource = typeResource.attributes().next(); - assertNull(attributeResource.mappingAnnotation(MappedSuperclass.ANNOTATION_NAME)); + assertNull(typeResource.mappingAnnotation(MappedSuperclass.ANNOTATION_NAME)); + assertNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); } public void testMorphToNull() throws Exception { createTestMappedSuperclass(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping(); + mappedSuperclass.setIdClass("myIdClass"); + javaPersistentType().setMappingKey(IMappingKeys.NULL_TYPE_MAPPING_KEY); assertTrue(javaPersistentType().getMapping() instanceof JavaNullTypeMapping); JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME); assertNull(typeResource.mappingAnnotation(MappedSuperclass.ANNOTATION_NAME)); + assertNull(typeResource.annotation(IdClass.ANNOTATION_NAME)); } |