diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java')
-rw-r--r-- | jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java | 248 |
1 files changed, 0 insertions, 248 deletions
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java deleted file mode 100644 index 9ac65c6d5d..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTransientMappingTests.java +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.context.java; - -import java.util.Iterator; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.BasicMapping; -import org.eclipse.jpt.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.core.context.EmbeddedMapping; -import org.eclipse.jpt.core.context.IdMapping; -import org.eclipse.jpt.core.context.ManyToManyMapping; -import org.eclipse.jpt.core.context.ManyToOneMapping; -import org.eclipse.jpt.core.context.OneToManyMapping; -import org.eclipse.jpt.core.context.OneToOneMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.TransientMapping; -import org.eclipse.jpt.core.context.VersionMapping; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; -import org.eclipse.jpt.core.tests.internal.context.ContextModelTestCase; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; - -public class JavaTransientMappingTests extends ContextModelTestCase -{ - - private ICompilationUnit createTestEntityWithTransientMapping() throws Exception { - return this.createTestType(new DefaultAnnotationWriter() { - @Override - public Iterator<String> imports() { - return new ArrayIterator<String>(JPA.ENTITY, JPA.TRANSIENT); - } - @Override - public void appendTypeAnnotationTo(StringBuilder sb) { - sb.append("@Entity").append(CR); - } - - @Override - public void appendIdFieldAnnotationTo(StringBuilder sb) { - sb.append("@Transient").append(CR); - } - }); - } - - public JavaTransientMappingTests(String name) { - super(name); - } - - public void testMorphToBasicMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof BasicMapping); - assertFalse(persistentAttribute.getMapping().isDefault()); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(BasicAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToDefault() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof BasicMapping); - assertTrue(persistentAttribute.getMapping().isDefault()); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToVersionMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof VersionMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(VersionAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToEmbeddedMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(EmbeddedAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToIdMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof IdMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(IdAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToEmbeddedIdMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToOneToOneMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof OneToOneMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(OneToOneAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToOneToManyMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(OneToManyAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToManyToOneMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(ManyToOneAnnotation.ANNOTATION_NAME)); - } - - public void testMorphToManyToManyMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getMapping(); - assertFalse(transientMapping.isDefault()); - - persistentAttribute.setSpecifiedMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); - assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping); - - JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); - JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); - assertNull(attributeResource.getMappingAnnotation(TransientAnnotation.ANNOTATION_NAME)); - assertNotNull(attributeResource.getMappingAnnotation(ManyToManyAnnotation.ANNOTATION_NAME)); - } - - public void testTransientMapping() throws Exception { - createTestEntityWithTransientMapping(); - addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - - PersistentAttribute persistentAttribute = javaPersistentType().attributes().next(); - TransientMapping transientMapping = (TransientMapping) persistentAttribute.getSpecifiedMapping(); - - assertNotNull(transientMapping); - } - -} |