diff options
author | bvosburgh | 2008-05-15 05:51:10 +0000 |
---|---|---|
committer | bvosburgh | 2008-05-15 05:51:10 +0000 |
commit | e1436751875ccd62fd3a0480d3eef2101583a1b7 (patch) | |
tree | fc58d49e142d3376ff6b9d943e19a56953c0e536 | |
parent | f0f9657d3b820c12d9658ab360947c939e6c75d9 (diff) | |
download | webtools.dali-e1436751875ccd62fd3a0480d3eef2101583a1b7.tar.gz webtools.dali-e1436751875ccd62fd3a0480d3eef2101583a1b7.tar.xz webtools.dali-e1436751875ccd62fd3a0480d3eef2101583a1b7.zip |
[225885] fix editing annotations with property access
110 files changed, 4102 insertions, 4123 deletions
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java index a067b0a21e..ff50fc7509 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/ContextModelTestCase.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IType; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; @@ -183,11 +184,11 @@ public abstract class ContextModelTestCase extends AnnotationTestCase waitForWorkspaceJobs(); } - protected IType createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - return this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + protected ICompilationUnit createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { + return this.javaProject.createCompilationUnit("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } - protected IType createEnumAndMembers(String enumName, String enumBody) throws Exception { - return this.javaProject.createType("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); + protected ICompilationUnit createEnumAndMembers(String enumName, String enumBody) throws Exception { + return this.javaProject.createCompilationUnit("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java index 812cb96f97..da8d498435 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/JpaFileTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ + * Copyright (c) 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; import java.util.Iterator; import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JpaFile; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; @@ -48,7 +47,7 @@ public class JpaFileTests extends ContextModelTestCase } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -71,8 +70,8 @@ public class JpaFileTests extends ContextModelTestCase assertEquals(entityMappings(), ormXmlJpaFile.rootStructureNodes().next()); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -136,8 +135,8 @@ public class JpaFileTests extends ContextModelTestCase public void testUpdateOrmJavaRootStructureNodePersistenceRemoved() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -146,10 +145,10 @@ public class JpaFileTests extends ContextModelTestCase } public void testUpdateJavaRootStructureNodePersistenceRemoved() throws Exception { - IType testType = createTestEntity(); + ICompilationUnit cu = createTestEntity(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -180,8 +179,8 @@ public class JpaFileTests extends ContextModelTestCase public void testUpdateOrmJavaRootStructureNodePersistenceXmlRemoved() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -190,10 +189,10 @@ public class JpaFileTests extends ContextModelTestCase } public void testUpdateJavaRootStructureNodePersistenceXmlRemoved() throws Exception { - IType testType = createTestEntity(); + ICompilationUnit cu = createTestEntity(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -204,8 +203,8 @@ public class JpaFileTests extends ContextModelTestCase public void testOrmJavaPersistentTypeRootStructureNodeRemoved() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); assertTrue(javaJpaFile.rootStructureNodes().next().getParent() instanceof OrmEntity); @@ -221,8 +220,8 @@ public class JpaFileTests extends ContextModelTestCase public void testOrmJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); @@ -236,8 +235,8 @@ public class JpaFileTests extends ContextModelTestCase } public void testJavaPersistentTypeRootStructureNodeRemoved() throws Exception { - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); JavaPersistentType javaPersistentType = javaPersistentType(); @@ -250,8 +249,8 @@ public class JpaFileTests extends ContextModelTestCase } public void testJavaPersistentTypeRootStructureNodeRemovedFromResourceModel() throws Exception { - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); JavaPersistentType javaPersistentType = javaPersistentType(); @@ -265,8 +264,8 @@ public class JpaFileTests extends ContextModelTestCase public void testImpliedJavaPersistentTypeRootStructureNodeRemoved() throws Exception { jpaProject().setDiscoversAnnotatedClasses(true); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = persistenceUnit().impliedClassRefs().next().getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); @@ -279,8 +278,8 @@ public class JpaFileTests extends ContextModelTestCase public void testJavaRootStructureNodesEntityMappingsRemoved() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); @@ -294,8 +293,8 @@ public class JpaFileTests extends ContextModelTestCase public void testJavaRootStructureNodesOrmPersistentTypeRemoved() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); @@ -309,8 +308,8 @@ public class JpaFileTests extends ContextModelTestCase public void testJavaRootStructureNodesOrmTypeMappingMorphed() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); @@ -329,8 +328,8 @@ public class JpaFileTests extends ContextModelTestCase public void testUpdateOrmJavaRootStructureNodeMappingFileRefChanged() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -347,10 +346,10 @@ public class JpaFileTests extends ContextModelTestCase } public void testUpdateJavaRootStructureNodeMappingFileRefChanged() throws Exception { - IType testType = createTestEntity(); + ICompilationUnit cu = createTestEntity(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); assertEquals(javaPersistentType(), javaJpaFile.rootStructureNodes().next()); @@ -363,8 +362,8 @@ public class JpaFileTests extends ContextModelTestCase public void testUpdateJavaRootStrucutreNodeDeleteOrmResource() throws Exception { OrmPersistentType ormPersistentType = entityMappings().addOrmPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); - IType testType = createTestEntity(); - JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) testType.getResource()); + ICompilationUnit cu = createTestEntity(); + JpaFile javaJpaFile = JptCorePlugin.getJpaFile((IFile) cu.getResource()); JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType(); assertEquals(javaPersistentType, javaJpaFile.rootStructureNodes().next()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java index 51c4b79b72..dd26243b9b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAssociationOverrideTests.java @@ -1,18 +1,18 @@ /******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ + * Copyright (c) 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.AssociationOverride; import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.JoinColumn; @@ -54,7 +54,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase "JoinColumn[] joinColumns();"); } - private IType createTestMappedSuperclass() throws Exception { + private ICompilationUnit createTestMappedSuperclass() throws Exception { createMappedSuperclassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -78,7 +78,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase }); } - private IType createTestEntityWithAssociationOverride() throws Exception { + private ICompilationUnit createTestEntityWithAssociationOverride() throws Exception { createEntityAnnotation(); createAssociationOverrideAnnotation(); @@ -95,7 +95,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -110,7 +110,7 @@ public class JavaAssociationOverrideTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java index 96e8302356..4d9c48dc08 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaAttributeOverrideTests.java @@ -1,17 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.AttributeOverride; import org.eclipse.jpt.core.context.BasicMapping; import org.eclipse.jpt.core.context.Column; @@ -60,7 +60,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase "Column column();"); } - private IType createTestMappedSuperclass() throws Exception { + private ICompilationUnit createTestMappedSuperclass() throws Exception { createMappedSuperclassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -75,7 +75,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase }); } - private IType createTestEntityWithAttributeOverride() throws Exception { + private ICompilationUnit createTestEntityWithAttributeOverride() throws Exception { createEntityAnnotation(); createAttributeOverrideAnnotation(); @@ -92,7 +92,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase }); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -107,7 +107,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -122,7 +122,7 @@ public class JavaAttributeOverrideTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java index b0c5eb0ff5..de450d0459 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaBasicMappingTests.java @@ -1,17 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AccessType; @@ -71,7 +71,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Temporal", "TemporalType value();"); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -86,7 +86,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithBasicMapping() throws Exception { + private ICompilationUnit createTestEntityWithBasicMapping() throws Exception { createEntityAnnotation(); createBasicAnnotation(); @@ -106,7 +106,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase } }); } - private IType createTestEntityWithBasicMappingFetchOptionalSpecified() throws Exception { + private ICompilationUnit createTestEntityWithBasicMappingFetchOptionalSpecified() throws Exception { createEntityAnnotation(); createBasicAnnotation(); @@ -127,7 +127,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithLob() throws Exception { + private ICompilationUnit createTestEntityWithLob() throws Exception { createEntityAnnotation(); createLobAnnotation(); @@ -148,7 +148,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithEnumerated() throws Exception { + private ICompilationUnit createTestEntityWithEnumerated() throws Exception { createEntityAnnotation(); createEnumeratedAnnotation(); @@ -169,7 +169,7 @@ public class JavaBasicMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithTemporal() throws Exception { + private ICompilationUnit createTestEntityWithTemporal() throws Exception { createEntityAnnotation(); createTemporalAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java index 427959ac8e..ba77742084 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaColumnTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.context.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.BaseColumn; import org.eclipse.jpt.core.context.BasicMapping; import org.eclipse.jpt.core.context.Column; @@ -50,7 +50,7 @@ public class JavaColumnTests extends ContextModelTestCase "int scale() default 0;"); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -65,7 +65,7 @@ public class JavaColumnTests extends ContextModelTestCase }); } - private IType createTestEntityWithDefaultBasicColumn() throws Exception { + private ICompilationUnit createTestEntityWithDefaultBasicColumn() throws Exception { createEntityAnnotation(); createColumnAnnotation(); @@ -86,7 +86,7 @@ public class JavaColumnTests extends ContextModelTestCase }); } - private IType createTestEntityWithBasicColumnTableSet() throws Exception { + private ICompilationUnit createTestEntityWithBasicColumnTableSet() throws Exception { createEntityAnnotation(); createColumnAnnotation(); createBasicAnnotation(); @@ -108,7 +108,7 @@ public class JavaColumnTests extends ContextModelTestCase } }); } - private IType createTestEntityWithBasicColumnColumnDefinitionSet() throws Exception { + private ICompilationUnit createTestEntityWithBasicColumnColumnDefinitionSet() throws Exception { createEntityAnnotation(); createColumnAnnotation(); createBasicAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java index e40d4e120e..8d59ae5e32 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaDiscriminatorColumnTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.DiscriminatorColumn; import org.eclipse.jpt.core.context.DiscriminatorType; import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; @@ -37,7 +36,7 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -52,7 +51,7 @@ public class JavaDiscriminatorColumnTests extends ContextModelTestCase }); } - private IType createTestEntityWithDiscriminatorColumn() throws Exception { + private ICompilationUnit createTestEntityWithDiscriminatorColumn() throws Exception { createEntityAnnotation(); createDiscriminatorColumnAnnotation(); 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 2d0be36a34..ef2c90d91e 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 @@ -1,17 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Embeddable; import org.eclipse.jpt.core.context.Entity; @@ -30,7 +30,7 @@ public class JavaEmbeddableTests extends ContextModelTestCase this.createAnnotationAndMembers("Embeddable", ""); } - private IType createTestEmbeddable() throws Exception { + private ICompilationUnit createTestEmbeddable() throws Exception { createEmbeddableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java index af0d14dcf1..60a012b8b7 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedIdMappingTests.java @@ -1,18 +1,18 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AttributeOverride; import org.eclipse.jpt.core.context.BasicMapping; @@ -68,7 +68,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("EmbeddedId", ""); } - private IType createTestEntityWithEmbeddedIdMapping() throws Exception { + private ICompilationUnit createTestEntityWithEmbeddedIdMapping() throws Exception { createEntityAnnotation(); createEmbeddedIdAnnotation(); @@ -92,7 +92,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase }); } - private IType createEmbeddableType() throws Exception { + private void createEmbeddableType() throws Exception { createEmbeddableAnnotation(); SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { @@ -113,7 +113,7 @@ public class JavaEmbeddedIdMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java index f51473e41f..137abdbcda 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaEmbeddedMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AttributeOverride; import org.eclipse.jpt.core.context.BasicMapping; @@ -68,7 +67,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Embedded", ""); } - private IType createTestEntityWithEmbeddedMapping() throws Exception { + private ICompilationUnit createTestEntityWithEmbeddedMapping() throws Exception { createEntityAnnotation(); createEmbeddedAnnotation(); @@ -91,7 +90,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase }); } - private IType createEmbeddableType() throws Exception { + private void createEmbeddableType() throws Exception { createEmbeddableAnnotation(); SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { @@ -112,7 +111,7 @@ public class JavaEmbeddedMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, EMBEDDABLE_TYPE_NAME + ".java", sourceWriter); } 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 e69a4697df..c050e2bf64 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 @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AccessType; @@ -142,7 +141,7 @@ public class JavaEntityTests extends ContextModelTestCase } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -157,7 +156,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestAbstractEntity() throws Exception { + private void createTestAbstractEntity() throws Exception { createEntityAnnotation(); SourceWriter sourceWriter = new SourceWriter() { @@ -173,10 +172,10 @@ public class JavaEntityTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, FILE_NAME, sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, sourceWriter); } - private IType createTestEntityAnnotationOnProperty() throws Exception { + private ICompilationUnit createTestEntityAnnotationOnProperty() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -197,7 +196,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestMappedSuperclass() throws Exception { + private ICompilationUnit createTestMappedSuperclass() throws Exception { createMappedSuperclassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -227,7 +226,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestEntityWithName() throws Exception { + private ICompilationUnit createTestEntityWithName() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -242,7 +241,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestEntityWithTable() throws Exception { + private ICompilationUnit createTestEntityWithTable() throws Exception { createEntityAnnotation(); createTableAnnotation(); @@ -259,7 +258,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -274,10 +273,10 @@ public class JavaEntityTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } - private IType createTestEntityWithInheritance() throws Exception { + private ICompilationUnit createTestEntityWithInheritance() throws Exception { createEntityAnnotation(); createInheritanceAnnotation(); @@ -294,7 +293,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestEntityWithDiscriminatorValue() throws Exception { + private ICompilationUnit createTestEntityWithDiscriminatorValue() throws Exception { createEntityAnnotation(); createDiscriminatorValueAnnotation(); @@ -311,7 +310,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestEntityWithSecondaryTable() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTable() throws Exception { createEntityAnnotation(); createSecondaryTableAnnotation(); @@ -328,7 +327,7 @@ public class JavaEntityTests extends ContextModelTestCase }); } - private IType createTestEntityWithSecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTables() throws Exception { createEntityAnnotation(); createSecondaryTablesAnnotation(); @@ -653,15 +652,15 @@ public class JavaEntityTests extends ContextModelTestCase } public void testSetTableNameWithNullTable() throws Exception { - createTestEntity(); + ICompilationUnit cu = createTestEntity(); addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); Table table = javaEntity().getTable(); assertEquals(TYPE_NAME, table.getName()); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); table.setSpecifiedName(TABLE_NAME); - assertSourceContains("@Table(name=\"" + TABLE_NAME + "\")"); + assertSourceContains("@Table(name=\"" + TABLE_NAME + "\")", cu); assertEquals(TABLE_NAME, javaEntity().getTableName()); assertEquals(TABLE_NAME, table.getName()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java index 3c5e75c373..21e03ea446 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaGeneratedValueTests.java @@ -1,17 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.GeneratedValue; import org.eclipse.jpt.core.context.GenerationType; import org.eclipse.jpt.core.context.IdMapping; @@ -36,7 +36,7 @@ public class JavaGeneratedValueTests extends ContextModelTestCase "String generator() default \"\"; "); } - private IType createTestEntityWithGeneratedValue() throws Exception { + private ICompilationUnit createTestEntityWithGeneratedValue() throws Exception { createEntityAnnotation(); createGeneratedValueAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java index 4353f16716..ed11c86c69 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaIdMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +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; @@ -65,7 +64,7 @@ public class JavaIdMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Temporal", "TemporalType value();"); } - private IType createTestEntityWithIdMapping() throws Exception { + private ICompilationUnit createTestEntityWithIdMapping() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -86,7 +85,7 @@ public class JavaIdMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithTemporal() throws Exception { + private ICompilationUnit createTestEntityWithTemporal() throws Exception { createEntityAnnotation(); createTemporalAnnotation(); @@ -108,7 +107,7 @@ public class JavaIdMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithIdMappingGeneratedValue() throws Exception { + private ICompilationUnit createTestEntityWithIdMappingGeneratedValue() throws Exception { createEntityAnnotation(); createIdAnnotation(); createGeneratedValueAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java index 7269ba9f27..8e3b989d04 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinColumnTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ + * Copyright (c) 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.java.JavaJoinColumn; import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; import org.eclipse.jpt.core.resource.java.JPA; @@ -49,7 +48,7 @@ public class JavaJoinColumnTests extends ContextModelTestCase } - private IType createTestEntityWithOneToOne() throws Exception { + private ICompilationUnit createTestEntityWithOneToOne() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); createJoinColumnAnnotation(); @@ -70,7 +69,7 @@ public class JavaJoinColumnTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidOneToOne() throws Exception { + private ICompilationUnit createTestEntityWithValidOneToOne() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); createJoinColumnAnnotation(); @@ -92,7 +91,7 @@ public class JavaJoinColumnTests extends ContextModelTestCase }); } - private IType createTargetEntity() throws Exception { + private void createTargetEntity() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -114,7 +113,7 @@ public class JavaJoinColumnTests extends ContextModelTestCase sb.append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Project.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java index ca0bd64e87..f2776c5b33 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaJoinTableTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.JoinColumn; import org.eclipse.jpt.core.context.JoinTable; import org.eclipse.jpt.core.context.UniqueConstraint; @@ -54,7 +53,7 @@ public class JavaJoinTableTests extends ContextModelTestCase "String[] columnNames(); "); } - private IType createTestEntityWithManyToMany() throws Exception { + private ICompilationUnit createTestEntityWithManyToMany() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); createJoinTableAnnotation(); @@ -75,7 +74,7 @@ public class JavaJoinTableTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidManyToMany() throws Exception { + private ICompilationUnit createTestEntityWithValidManyToMany() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); createJoinTableAnnotation(); @@ -97,7 +96,7 @@ public class JavaJoinTableTests extends ContextModelTestCase }); } - private IType createTargetEntity() throws Exception { + private void createTargetEntity() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -119,7 +118,7 @@ public class JavaJoinTableTests extends ContextModelTestCase sb.append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Project.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { createTestEntityWithManyToMany(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java index 81b2d921fd..961c029b3c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +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; @@ -60,7 +59,7 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("ManyToMany", ""); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -89,10 +88,10 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } - private IType createTestEntityWithManyToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithManyToManyMapping() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); @@ -113,7 +112,7 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidManyToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithValidManyToManyMapping() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); @@ -137,7 +136,7 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase } }); } - private IType createTestEntityWithCollectionManyToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithCollectionManyToManyMapping() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); @@ -161,7 +160,7 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase } }); } - private IType createTestEntityWithNonCollectionManyToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithNonCollectionManyToManyMapping() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java index 2867d21254..a78ffeb2d5 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToOneMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +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; @@ -62,7 +61,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("ManyToOne", ""); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -91,10 +90,10 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } - private IType createTestEntityWithManyToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithManyToOneMapping() throws Exception { createEntityAnnotation(); createManyToOneAnnotation(); @@ -115,7 +114,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidManyToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithValidManyToOneMapping() throws Exception { createEntityAnnotation(); createManyToOneAnnotation(); @@ -140,7 +139,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithCollectionManyToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithCollectionManyToOneMapping() throws Exception { createEntityAnnotation(); createManyToOneAnnotation(); @@ -165,7 +164,7 @@ public class JavaManyToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithGenericizedCollectionManyToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithGenericizedCollectionManyToOneMapping() throws Exception { createEntityAnnotation(); createManyToOneAnnotation(); 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 3bd2e944ea..66897d2c86 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 @@ -1,17 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Embeddable; import org.eclipse.jpt.core.context.Entity; @@ -31,7 +31,7 @@ public class JavaMappedSuperclassTests extends ContextModelTestCase this.createAnnotationAndMembers("MappedSuperclass", ""); } - private IType createTestMappedSuperclass() throws Exception { + private ICompilationUnit createTestMappedSuperclass() throws Exception { createMappedSuperclassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java index dee49a631b..15c0b0067d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedNativeQueryTests.java @@ -1,17 +1,18 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IType; import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.NamedNativeQuery; @@ -45,7 +46,7 @@ public class JavaNamedNativeQueryTests extends ContextModelTestCase "String value();"); } - private IType createTestEntityWithNamedNativeQuery() throws Exception { + private ICompilationUnit createTestEntityWithNamedNativeQuery() throws Exception { createEntityAnnotation(); createNamedNativeQueryAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java index 106df282b7..00bfbaf4b0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaNamedQueryTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.NamedQuery; import org.eclipse.jpt.core.context.QueryHint; @@ -45,7 +44,7 @@ public class JavaNamedQueryTests extends ContextModelTestCase "String value();"); } - private IType createTestEntityWithNamedQuery() throws Exception { + private ICompilationUnit createTestEntityWithNamedQuery() throws Exception { createEntityAnnotation(); createNamedQueryAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java index 7c4171e236..9f35bad1aa 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +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; @@ -60,7 +59,7 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("OneToMany", ""); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -89,10 +88,10 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } - private IType createTestEntityWithOneToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithOneToManyMapping() throws Exception { createEntityAnnotation(); createOneToManyAnnotation(); @@ -113,7 +112,7 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidOneToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithValidOneToManyMapping() throws Exception { createEntityAnnotation(); createOneToManyAnnotation(); @@ -138,7 +137,7 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithCollectionOneToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithCollectionOneToManyMapping() throws Exception { createEntityAnnotation(); createOneToManyAnnotation(); @@ -162,7 +161,7 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase } }); } - private IType createTestEntityWithNonCollectionOneToManyMapping() throws Exception { + private ICompilationUnit createTestEntityWithNonCollectionOneToManyMapping() throws Exception { createEntityAnnotation(); createOneToManyAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java index 9493c8b024..43ecc37ba9 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToOneMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +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; @@ -67,7 +66,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("OneToOne", ""); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -94,13 +93,13 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase sb.append(" private int zip;").append(CR); sb.append(CR); sb.append("}").append(CR); - } + } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } - private IType createTestEntityWithOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); @@ -121,7 +120,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithValidOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithValidOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); @@ -146,7 +145,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithCollectionOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithCollectionOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); @@ -171,7 +170,7 @@ public class JavaOneToOneMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithGenericizedCollectionOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityWithGenericizedCollectionOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java index 17f39f6873..c93bf5a38d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentAttributeTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.PersistentAttribute; import org.eclipse.jpt.core.context.java.JavaBasicMapping; @@ -33,7 +32,7 @@ public class JavaPersistentAttributeTests extends ContextModelTestCase } - private IType createTestEntityAnnotatedField() throws Exception { + private ICompilationUnit createTestEntityAnnotatedField() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -54,7 +53,7 @@ public class JavaPersistentAttributeTests extends ContextModelTestCase }); } - private IType createTestEntityAnnotatedMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java index f9313be0f5..058bb7bd58 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPersistentTypeTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AccessType; @@ -47,7 +46,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase this.createAnnotationAndMembers("Entity", "String name() default \"\";"); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -62,7 +61,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestEntityAnnotatedField() throws Exception { + private ICompilationUnit createTestEntityAnnotatedField() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -83,7 +82,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestEntityAnnotatedMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -103,7 +102,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase } }); } - private IType createTestEntityAnnotatedFieldAndMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedFieldAndMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -129,7 +128,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private ICompilationUnit createTestSubType() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { @@ -147,7 +146,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestSubTypeWithFieldAnnotation() throws Exception { + private ICompilationUnit createTestSubTypeWithFieldAnnotation() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { @@ -169,7 +168,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestSubTypeWithMethodAnnotation() throws Exception { + private ICompilationUnit createTestSubTypeWithMethodAnnotation() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { @@ -191,7 +190,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestSubTypeNonPersistent() throws Exception { + private ICompilationUnit createTestSubTypeNonPersistent() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() { @Override public void appendExtendsImplementsTo(StringBuilder sb) { @@ -200,7 +199,7 @@ public class JavaPersistentTypeTests extends ContextModelTestCase }); } - private IType createTestSubTypePersistentExtendsNonPersistent() throws Exception { + private ICompilationUnit createTestSubTypePersistentExtendsNonPersistent() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild2.java", "AnnotationTestTypeChild2", new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java index 57f27f280e..b403006cab 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaPrimaryKeyJoinColumnTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.PersistentAttribute; import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; @@ -42,7 +41,7 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -63,7 +62,7 @@ public class JavaPrimaryKeyJoinColumnTests extends ContextModelTestCase }); } - private IType createTestEntityWithPrimaryKeyJoinColumn() throws Exception { + private ICompilationUnit createTestEntityWithPrimaryKeyJoinColumn() throws Exception { createEntityAnnotation(); createIdAnnotation(); createPrimaryKeyJoinColumnAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java index 3e4be05d01..c8c143ac00 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaQueryHintTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.QueryHint; import org.eclipse.jpt.core.resource.java.JPA; @@ -43,7 +42,7 @@ public class JavaQueryHintTests extends ContextModelTestCase "String value();"); } - private IType createTestEntityWithNamedQuery() throws Exception { + private ICompilationUnit createTestEntityWithNamedQuery() throws Exception { createEntityAnnotation(); createNamedQueryAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java index 6204905c39..7d75bfc081 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSecondaryTableTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.IdMapping; import org.eclipse.jpt.core.context.PersistentAttribute; @@ -53,7 +52,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();"); } - private IType createTestEntityWithSecondaryTable() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTable() throws Exception { createEntityAnnotation(); createIdAnnotation(); createSecondaryTableAnnotation(); @@ -75,7 +74,7 @@ public class JavaSecondaryTableTests extends ContextModelTestCase }); } - private IType createTestEntityWithSecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTables() throws Exception { createEntityAnnotation(); createSecondaryTablesAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java index eb37d6b7d8..cbc1da2301 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaSequenceGeneratorTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.context.Generator; import org.eclipse.jpt.core.context.IdMapping; import org.eclipse.jpt.core.context.SequenceGenerator; @@ -38,7 +37,7 @@ public class JavaSequenceGeneratorTests extends ContextModelTestCase "int allocationSize() default 50;"); } - private IType createTestEntityWithSequenceGenerator() throws Exception { + private ICompilationUnit createTestEntityWithSequenceGenerator() throws Exception { createEntityAnnotation(); createSequenceGeneratorAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java index 84f2b63114..32c0d3a61d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableGeneratorTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Generator; @@ -59,7 +58,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase "String[] columnNames(); "); } - private IType createTestEntityWithTableGenerator() throws Exception { + private ICompilationUnit createTestEntityWithTableGenerator() throws Exception { createEntityAnnotation(); createTableGeneratorAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java index 493913cfeb..134aebfea0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaTableTests.java @@ -1,19 +1,18 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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 java.util.ListIterator; import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Table; @@ -50,7 +49,7 @@ public class JavaTableTests extends ContextModelTestCase "String[] columnNames(); "); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -65,7 +64,7 @@ public class JavaTableTests extends ContextModelTestCase }); } - private IType createTestEntityWithTable() throws Exception { + private ICompilationUnit createTestEntityWithTable() throws Exception { createEntityAnnotation(); createTableAnnotation(); @@ -82,7 +81,7 @@ public class JavaTableTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private ICompilationUnit createTestSubType() throws Exception { return this.createTestType(PACKAGE_NAME, "AnnotationTestTypeChild.java", "AnnotationTestTypeChild", new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { 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 index c00fdc2187..f79334a822 100644 --- 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 @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +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; @@ -50,7 +49,7 @@ public class JavaTransientMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Transient", ""); } - private IType createTestEntityWithTransientMapping() throws Exception { + private ICompilationUnit createTestEntityWithTransientMapping() throws Exception { createEntityAnnotation(); createTransientAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java index e6577fcc5b..77f268aace 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaVersionMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.IType; +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; @@ -57,7 +56,7 @@ public class JavaVersionMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Temporal", "TemporalType value();"); } - private IType createTestEntityWithVersionMapping() throws Exception { + private ICompilationUnit createTestEntityWithVersionMapping() throws Exception { createEntityAnnotation(); createVersionAnnotation(); @@ -78,7 +77,7 @@ public class JavaVersionMappingTests extends ContextModelTestCase }); } - private IType createTestEntityWithTemporal() throws Exception { + private ICompilationUnit createTestEntityWithTemporal() throws Exception { createEntityAnnotation(); createTemporalAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java index 1db379656e..5869f60a59 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmBasicMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.BasicMapping; @@ -87,7 +86,7 @@ public class OrmBasicMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Temporal", "TemporalType value();"); } - private IType createTestEntityBasicMapping() throws Exception { + private ICompilationUnit createTestEntityBasicMapping() throws Exception { createEntityAnnotation(); createBasicAnnotation(); createColumnAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java index 7b027f4d2b..c77df9fe26 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmColumnTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Column; @@ -55,7 +54,7 @@ public class OrmColumnTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -75,7 +74,7 @@ public class OrmColumnTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -90,7 +89,7 @@ public class OrmColumnTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java index 72b36218b1..f00a629567 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmDiscriminatorColumnTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.DiscriminatorType; @@ -50,7 +49,7 @@ public class OrmDiscriminatorColumnTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -70,7 +69,7 @@ public class OrmDiscriminatorColumnTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -85,7 +84,7 @@ public class OrmDiscriminatorColumnTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java index 9632e885fc..051ebf0f38 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedIdMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AttributeOverride; @@ -81,7 +80,7 @@ public class OrmEmbeddedIdMappingTests extends ContextModelTestCase "String name();" + "Column column();"); } - private IType createTestEntityEmbeddedIdMapping() throws Exception { + private ICompilationUnit createTestEntityEmbeddedIdMapping() throws Exception { createEntityAnnotation(); createEmbeddedIdAnnotation(); createAttributeOverrideAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java index fdd8858331..49d28c22b2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEmbeddedMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AttributeOverride; @@ -87,7 +86,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase "Column column();"); } - private IType createTestEntityEmbeddedMapping() throws Exception { + private ICompilationUnit createTestEntityEmbeddedMapping() throws Exception { createEntityAnnotation(); createEmbeddedAnnotation(); createAttributeOverrideAnnotation(); @@ -115,7 +114,7 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase }); } - private IType createTestEmbeddableAddress() throws Exception { + private void createTestEmbeddableAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -148,9 +147,9 @@ public class OrmEmbeddedMappingTests extends ContextModelTestCase sb.append(" private int zip;").append(CR); sb.append(CR); sb.append("}").append(CR); - } + } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } public void testUpdateName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java index 2b1ac74822..9c39a7393a 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmEntityTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AccessType; @@ -74,7 +73,7 @@ public class OrmEntityTests extends ContextModelTestCase this.createAnnotationAndMembers("MappedSuperclass", ""); } - private IType createTestEntityDefaultFieldAccess() throws Exception { + private ICompilationUnit createTestEntityDefaultFieldAccess() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -89,7 +88,7 @@ public class OrmEntityTests extends ContextModelTestCase }); } - private IType createTestEntityFieldAccess() throws Exception { + private ICompilationUnit createTestEntityFieldAccess() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -109,7 +108,7 @@ public class OrmEntityTests extends ContextModelTestCase }); } - private IType createTestEntityPropertyAccess() throws Exception { + private ICompilationUnit createTestEntityPropertyAccess() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -129,7 +128,7 @@ public class OrmEntityTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -144,10 +143,10 @@ public class OrmEntityTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } - private IType createTestSubTypeUnmapped() throws Exception { + private void createTestSubTypeUnmapped() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -156,10 +155,11 @@ public class OrmEntityTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } - private IType createTestMappedSuperclass() throws Exception { + + private ICompilationUnit createTestMappedSuperclass() throws Exception { createMappedSuperclassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -189,7 +189,7 @@ public class OrmEntityTests extends ContextModelTestCase }); } - private IType createTestAbstractType() throws Exception { + private void createTestAbstractType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -197,7 +197,7 @@ public class OrmEntityTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, FILE_NAME, sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java index 7a95b4027a..a9366c2959 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmGeneratedValueTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmGeneratedValue; @@ -50,7 +49,7 @@ public class OrmGeneratedValueTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -70,7 +69,7 @@ public class OrmGeneratedValueTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -85,7 +84,7 @@ public class OrmGeneratedValueTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java index 5fde4d5f1a..8199e6f116 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmIdMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.BasicMapping; @@ -113,7 +112,7 @@ public class OrmIdMappingTests extends ContextModelTestCase "UniqueConstraint[] uniqueConstraints() default {};"); } - private IType createTestEntityIdMapping() throws Exception { + private ICompilationUnit createTestEntityIdMapping() throws Exception { createEntityAnnotation(); createIdAnnotation(); createColumnAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java index d2d6c2440e..c167095f56 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmJoinTableTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.java.JavaEntity; @@ -73,7 +72,7 @@ public class OrmJoinTableTests extends ContextModelTestCase "String schema() default \"\";"); } - private IType createTestEntityWithValidManyToMany() throws Exception { + private ICompilationUnit createTestEntityWithValidManyToMany() throws Exception { createEntityAnnotation(); createManyToManyAnnotation(); createJoinTableAnnotation(); @@ -97,7 +96,7 @@ public class OrmJoinTableTests extends ContextModelTestCase }); } - private IType createTargetEntity() throws Exception { + private void createTargetEntity() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -119,7 +118,7 @@ public class OrmJoinTableTests extends ContextModelTestCase sb.append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Project.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Project.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java index 27b4851aa3..46762ba744 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmManyToOneMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Cascade; @@ -68,7 +67,7 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase "String table() default \"\";"); } - private IType createTestEntityManyToOneMapping() throws Exception { + private ICompilationUnit createTestEntityManyToOneMapping() throws Exception { createEntityAnnotation(); createManyToOneAnnotation(); createJoinColumnAnnotation(); @@ -96,7 +95,7 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase }); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -124,9 +123,9 @@ public class OrmManyToOneMappingTests extends ContextModelTestCase sb.append(" private int zip;").append(CR); sb.append(CR); sb.append("}").append(CR); - } + } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } public void testUpdateName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java index 04ba55d9c3..ce9da74ce2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmOneToOneMappingTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.BasicMapping; @@ -81,7 +80,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase "String table() default \"\";"); } - private IType createTestEntityOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); createJoinColumnAnnotation(); @@ -109,7 +108,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase }); } - private IType createTestTargetEntityAddress() throws Exception { + private void createTestTargetEntityAddress() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -139,7 +138,7 @@ public class OrmOneToOneMappingTests extends ContextModelTestCase sb.append("}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "Address.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); } public void testUpdateName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java index 56cac10e77..dfdf8ac27c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPersistentAttributeTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 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 - *******************************************************************************/ + * Copyright (c) 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.BasicMapping; @@ -43,7 +42,7 @@ public class OrmPersistentAttributeTests extends ContextModelTestCase persistenceResource().save(null); } - private IType createTestTypeNullAttributeMapping() throws Exception { + private ICompilationUnit createTestTypeNullAttributeMapping() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -71,7 +70,7 @@ public class OrmPersistentAttributeTests extends ContextModelTestCase this.createAnnotationAndMembers("OneToOne", ""); } - private IType createTestEntityIdMapping() throws Exception { + private ICompilationUnit createTestEntityIdMapping() throws Exception { createEntityAnnotation(); createIdAnnotation(); createColumnAnnotation(); @@ -93,7 +92,7 @@ public class OrmPersistentAttributeTests extends ContextModelTestCase }); } - private IType createTestEntityOneToOneMapping() throws Exception { + private ICompilationUnit createTestEntityOneToOneMapping() throws Exception { createEntityAnnotation(); createOneToOneAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java index 9f2b87d7d5..4dcb1d47de 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmPrimaryKeyJoinColumnTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmEntity; @@ -49,7 +48,7 @@ public class OrmPrimaryKeyJoinColumnTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -69,7 +68,7 @@ public class OrmPrimaryKeyJoinColumnTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -84,7 +83,7 @@ public class OrmPrimaryKeyJoinColumnTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java index ebada5c7eb..591ac25e33 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSecondaryTableTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.InheritanceType; @@ -58,7 +57,7 @@ public class OrmSecondaryTableTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -78,7 +77,7 @@ public class OrmSecondaryTableTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -93,7 +92,7 @@ public class OrmSecondaryTableTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java index 3a0b529be4..e7c57c86bb 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmSequenceGeneratorTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.context.SequenceGenerator; import org.eclipse.jpt.core.resource.java.JPA; @@ -45,7 +44,7 @@ public class OrmSequenceGeneratorTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -65,7 +64,7 @@ public class OrmSequenceGeneratorTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -80,7 +79,7 @@ public class OrmSequenceGeneratorTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java index af290df2df..01d1dd638b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableGeneratorTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.TableGenerator; @@ -56,7 +55,7 @@ public class OrmTableGeneratorTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -76,7 +75,7 @@ public class OrmTableGeneratorTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -91,7 +90,7 @@ public class OrmTableGeneratorTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java index d74c0d287c..1814076701 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTableTests.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.InheritanceType; @@ -54,7 +53,7 @@ public class OrmTableTests extends ContextModelTestCase this.createAnnotationAndMembers("Id", ""); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); createIdAnnotation(); @@ -74,7 +73,7 @@ public class OrmTableTests extends ContextModelTestCase }); } - private IType createTestSubType() throws Exception { + private void createTestSubType() throws Exception { SourceWriter sourceWriter = new SourceWriter() { public void appendSourceTo(StringBuilder sb) { sb.append(CR); @@ -89,7 +88,7 @@ public class OrmTableTests extends ContextModelTestCase sb.append("{}").append(CR); } }; - return this.javaProject.createType(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); + this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter); } public void testUpdateSpecifiedName() throws Exception { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java index 4707112d17..f9d8baeeb5 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmTransientMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.EmbeddedIdMapping; @@ -57,7 +56,7 @@ public class OrmTransientMappingTests extends ContextModelTestCase } - private IType createTestEntityTransientMapping() throws Exception { + private ICompilationUnit createTestEntityTransientMapping() throws Exception { createEntityAnnotation(); createTransientAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java index 9d29f2cfe8..a053b9f8a0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/OrmVersionMappingTests.java @@ -1,17 +1,16 @@ /******************************************************************************* - * Copyright (c) 2007 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 - *******************************************************************************/ + * 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.orm; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.BasicMapping; @@ -77,7 +76,7 @@ public class OrmVersionMappingTests extends ContextModelTestCase this.createAnnotationAndMembers("Temporal", "TemporalType value();"); } - private IType createTestEntityVersionMapping() throws Exception { + private ICompilationUnit createTestEntityVersionMapping() throws Exception { createEntityAnnotation(); createVersionAnnotation(); createColumnAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java index 427710ba22..08cd41c918 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/persistence/PersistenceUnitTests.java @@ -12,7 +12,7 @@ package org.eclipse.jpt.core.tests.internal.context.persistence; import java.io.IOException; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AccessType; @@ -1049,7 +1049,7 @@ public class PersistenceUnitTests extends ContextModelTestCase this.createAnnotationAndMembers("Entity", "String name() default \"\";"); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -1064,7 +1064,7 @@ public class PersistenceUnitTests extends ContextModelTestCase }); } - private IType createTestEntityWithPersistentInnerClass() throws Exception { + private ICompilationUnit createTestEntityWithPersistentInnerClass() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java index 8bd9233c40..de87fb36aa 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JpaPlatformTests.java @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.tests.internal.platform; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JpaPlatform; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.java.JavaAttributeMapping; @@ -78,7 +78,7 @@ public class JpaPlatformTests extends ContextModelTestCase this.createAnnotationAndMembers("Entity", "String name() default \"\";"); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java index 29f7c6a648..d9f77d393d 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -16,7 +16,6 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.utility.internal.CollectionTools; @@ -73,34 +72,29 @@ public class TestJavaProject extends TestFacetedProject { * The source should NOT contain a package declaration; * it will be added here. */ - public IType createType(String packageName, String compilationUnitName, String source) throws CoreException { - return this.createType(this.createPackage(packageName), compilationUnitName, new SimpleSourceWriter(source)); + public ICompilationUnit createCompilationUnit(String packageName, String compilationUnitName, String source) throws CoreException { + return this.createCompilationUnit(this.createPackage(packageName), compilationUnitName, new SimpleSourceWriter(source)); } /** * The source should NOT contain a package declaration; * it will be added here. */ - public IType createType(String packageName, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { - return this.createType(this.createPackage(packageName), compilationUnitName, sourceWriter); + public ICompilationUnit createCompilationUnit(String packageName, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { + return this.createCompilationUnit(this.createPackage(packageName), compilationUnitName, sourceWriter); } - + /** * The source should NOT contain a package declaration; * it will be added here. */ - public IType createType(IPackageFragment packageFragment, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { + public ICompilationUnit createCompilationUnit(IPackageFragment packageFragment, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { StringBuilder sb = new StringBuilder(2000); sb.append("package ").append(packageFragment.getElementName()).append(";").append(CR); sb.append(CR); sourceWriter.appendSourceTo(sb); String source = sb.toString(); - ICompilationUnit cu = packageFragment.createCompilationUnit(compilationUnitName, source, false, null); // false = "no force" - return cu.findPrimaryType(); - } - - public IType findType(String fullyQualifiedName) throws JavaModelException { - return this.javaProject.findType(fullyQualifiedName); + return packageFragment.createCompilationUnit(compilationUnitName, source, false, null); // false = "no force" } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java index 18a20a1d59..eb2ee78333 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverrideTests.java @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -44,7 +45,7 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { "String table() default \"\";"); } - private IType createTestAssociationOverrideOnField() throws Exception { + private ICompilationUnit createTestAssociationOverrideOnField() throws Exception { createAssociationOverrideAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -58,7 +59,7 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { }); } - private IType createTestAssociationOverrideWithJoinColumns() throws Exception { + private ICompilationUnit createTestAssociationOverrideWithJoinColumns() throws Exception { createAssociationOverrideAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -73,8 +74,8 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -83,8 +84,8 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -93,12 +94,12 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { associationOverride.setName("Foo"); assertEquals("Foo", associationOverride.getName()); - assertSourceContains("@AssociationOverride(name=\"Foo\")"); + assertSourceContains("@AssociationOverride(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -107,14 +108,14 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { associationOverride.setName(null); assertNull(associationOverride.getName()); - assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")"); - assertSourceContains("@AssociationOverride"); + assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")", cu); + assertSourceContains("@AssociationOverride", cu); } public void testJoinColumns() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -123,8 +124,8 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { } public void testJoinColumns2() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -137,8 +138,8 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { } public void testJoinColumns3() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -147,8 +148,8 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { } public void testAddJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -161,12 +162,12 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { assertEquals("FOO", associationOverride.joinColumnAt(1).getName()); assertNull(associationOverride.joinColumnAt(2).getName()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})", cu); } public void testRemoveJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -177,30 +178,30 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { assertEquals("BAR", joinColumns.next().getName()); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn})", cu); associationOverride.removeJoinColumn(1); joinColumns = associationOverride.joinColumns(); assertEquals("FOO", joinColumns.next().getName()); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})", cu); associationOverride.removeJoinColumn(0); joinColumns = associationOverride.joinColumns(); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn)"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn)", cu); associationOverride.setName(null); associationOverride.removeJoinColumn(0); - assertSourceDoesNotContain("@AssociationOverride"); + assertSourceDoesNotContain("@AssociationOverride", cu); } public void testMoveJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -214,19 +215,19 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { joinColumn.setTable("TABLE"); associationOverride.addJoinColumn(0).setName("FOO"); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})", cu); associationOverride.moveJoinColumn(2, 0); assertEquals("BAR", associationOverride.joinColumnAt(0).getName()); assertNull(associationOverride.joinColumnAt(1).getName()); assertEquals("FOO", associationOverride.joinColumnAt(2).getName()); assertEquals(3, associationOverride.joinColumnsSize()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})", cu); } public void testMoveJoinColumn2() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -241,19 +242,19 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { joinColumn.setTable("TABLE"); associationOverride.addJoinColumn(0).setName("FOO"); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})", cu); associationOverride.moveJoinColumn(0, 2); assertNull(associationOverride.joinColumnAt(0).getName()); assertEquals("FOO", associationOverride.joinColumnAt(1).getName()); assertEquals("BAR", associationOverride.joinColumnAt(2).getName()); assertEquals(3, associationOverride.joinColumnsSize()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})", cu); } public void testSetJoinColumnName() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE); @@ -267,6 +268,6 @@ public class AssociationOverrideTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})"); + assertSourceContains("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java index 51d356fb24..2703566784 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AssociationOverridesTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -54,7 +54,7 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } - private IType createTestAssociationOverrideOnField() throws Exception { + private ICompilationUnit createTestAssociationOverrideOnField() throws Exception { createAssociationOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -67,7 +67,7 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } }); } - private IType createTestAssociationOverrideWithJoinColumns() throws Exception { + private ICompilationUnit createTestAssociationOverrideWithJoinColumns() throws Exception { createAssociationOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -81,7 +81,7 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { }); } - private IType createTestAssociationOverride() throws Exception { + private ICompilationUnit createTestAssociationOverride() throws Exception { createAssociationOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -98,8 +98,8 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES); AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next(); @@ -109,8 +109,8 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES); AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next(); @@ -120,12 +120,12 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { associationOverride.setName("Foo"); assertEquals("Foo", associationOverride.getName()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"Foo\"))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"Foo\"))", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverridesAnnotation associationOverrides = (AssociationOverridesAnnotation) attributeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES); AssociationOverrideAnnotation associationOverride = associationOverrides.nestedAnnotations().next(); @@ -134,18 +134,18 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { associationOverride.setName(null); assertNull(associationOverride.getName()); - assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")"); - assertSourceContains("@AssociationOverride"); - assertSourceContains("@AssociationOverrides"); + assertSourceDoesNotContain("@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\")", cu); + assertSourceContains("@AssociationOverride", cu); + assertSourceContains("@AssociationOverrides", cu); } public void testAddAssociationOverrideCopyExisting() throws Exception { - IType jdtType = createTestAssociationOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAssociationOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); - assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})"); + assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDE)); assertNotNull(typeResource.getAnnotation(JPA.ASSOCIATION_OVERRIDES)); @@ -153,16 +153,16 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testAddAssociationOverrideToBeginningOfList() throws Exception { - IType jdtType = createTestAssociationOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAssociationOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); - assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})"); + assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})", cu); associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAZ"); - assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"BAZ\"),@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")), @AssociationOverride(name=\"BAR\")})"); + assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"BAZ\"),@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")), @AssociationOverride(name=\"BAR\")})", cu); Iterator<JavaResourceNode> associationOverrides = typeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); assertEquals("BAZ", ((AssociationOverrideAnnotation) associationOverrides.next()).getName()); @@ -175,20 +175,20 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testRemoveAssociationOverrideCopyExisting() throws Exception { - IType jdtType = createTestAssociationOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAssociationOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); associationOverride.setName("BAR"); - assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})"); + assertSourceContains("@AssociationOverrides({@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\")),@AssociationOverride(name=\"BAR\")})", cu); typeResource.removeAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES); - assertSourceContains("@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\"))"); + assertSourceContains("@AssociationOverride(name=\"FOO\", joinColumns = @JoinColumn(name=\"FOO\", columnDefinition = \"BAR\", referencedColumnName = \"BAZ\"))", cu); } public void testJoinColumns() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -197,8 +197,8 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testJoinColumns2() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -210,8 +210,8 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testJoinColumns3() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -220,8 +220,8 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { } public void testAddJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -236,12 +236,12 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { assertEquals("FOO", joinColumns.next().getName()); assertNull(joinColumns.next().getName()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns = {@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn}))", cu); } public void testRemoveJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -252,30 +252,30 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { assertEquals("BAR", joinColumns.next().getName()); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\"), @JoinColumn}))", cu); associationOverride.removeJoinColumn(1); joinColumns = associationOverride.joinColumns(); assertEquals("FOO", joinColumns.next().getName()); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn}))", cu); associationOverride.removeJoinColumn(0); joinColumns = associationOverride.joinColumns(); assertNull(joinColumns.next().getName()); assertEquals(false, joinColumns.hasNext()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns=@JoinColumn))", cu); associationOverride.setName(null); associationOverride.removeJoinColumn(0); - assertSourceDoesNotContain("@AssociationOverride"); + assertSourceDoesNotContain("@AssociationOverride", cu); } public void testMoveJoinColumn() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -288,19 +288,19 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { joinColumn.setColumnDefinition("COLUMN_DEF"); joinColumn.setTable("TABLE"); associationOverride.addJoinColumn(0).setName("FOO"); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))", cu); associationOverride.moveJoinColumn(2, 0); assertEquals("BAR", associationOverride.joinColumnAt(0).getName()); assertNull(associationOverride.joinColumnAt(1).getName()); assertEquals("FOO", associationOverride.joinColumnAt(2).getName()); assertEquals(3, associationOverride.joinColumnsSize()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")}))", cu); } public void testMoveJoinColumn2() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -315,18 +315,18 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { joinColumn.setTable("TABLE"); associationOverride.addJoinColumn(0).setName("FOO"); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn}))", cu); associationOverride.moveJoinColumn(0, 2); assertNull(associationOverride.joinColumnAt(0).getName()); assertEquals("FOO", associationOverride.joinColumnAt(1).getName()); assertEquals("BAR", associationOverride.joinColumnAt(2).getName()); assertEquals(3, associationOverride.joinColumnsSize()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")}))", cu); } public void testSetJoinColumnName() throws Exception { - IType testType = this.createTestAssociationOverrideWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAssociationOverrideWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) attributeResource.annotations(JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES).next(); @@ -340,6 +340,6 @@ public class AssociationOverridesTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn}))"); + assertSourceContains("@AssociationOverrides(@AssociationOverride(name=\"" + ASSOCIATION_OVERRIDE_NAME + "\", joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn}))", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java index b07d3c57e3..e09c06b77f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverrideTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; import org.eclipse.jpt.core.resource.java.ColumnAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -47,7 +47,7 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { "int scale() default 0;"); } - private IType createTestAttributeOverrideOnField() throws Exception { + private ICompilationUnit createTestAttributeOverrideOnField() throws Exception { createAttributeOverrideAnnotation(); createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -62,7 +62,7 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { }); } - private IType createTestAttributeOverrideWithColumnOnField() throws Exception { + private ICompilationUnit createTestAttributeOverrideWithColumnOnField() throws Exception { createAttributeOverrideAnnotation(); createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -78,8 +78,8 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); @@ -88,8 +88,8 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { } public void testGetNullColumn() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation column = attributeOverride.getColumn(); @@ -98,8 +98,8 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); @@ -108,12 +108,12 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { attributeOverride.setName("Foo"); assertEquals("Foo", attributeOverride.getName()); - assertSourceContains("@AttributeOverride(name=\"Foo\")"); + assertSourceContains("@AttributeOverride(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); @@ -122,13 +122,13 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { attributeOverride.setName(null); assertNull(attributeOverride.getName()); - assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")"); - assertSourceContains("@AttributeOverride"); + assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")", cu); + assertSourceContains("@AttributeOverride", cu); } public void testColumnGetName() throws Exception { - IType testType = this.createTestAttributeOverrideWithColumnOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation column = attributeOverride.getColumn(); @@ -136,8 +136,8 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { } public void testColumnSetName() throws Exception { - IType testType = this.createTestAttributeOverrideWithColumnOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation column = attributeOverride.getColumn(); @@ -145,16 +145,16 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { column.setName("Foo"); - assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\"))"); + assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\"))", cu); column.setName(null); assertNull(attributeOverride.getColumn()); - assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")"); + assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")", cu); } public void testAddColumn() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation column = attributeOverride.getColumn(); @@ -162,8 +162,8 @@ public class AttributeOverrideTests extends JavaResourceModelTestCase { } public void testRemoveColumn() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE); ColumnAnnotation column = attributeOverride.getColumn(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java index d217760356..1712d914ba 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/AttributeOverridesTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; import org.eclipse.jpt.core.resource.java.ColumnAnnotation; @@ -57,7 +57,7 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { "int scale() default 0;"); } - private IType createTestAttributeOverrideOnField() throws Exception { + private ICompilationUnit createTestAttributeOverrideOnField() throws Exception { createAttributeOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -71,7 +71,7 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { }); } - private IType createTestAttributeOverrideWithColumnOnField() throws Exception { + private ICompilationUnit createTestAttributeOverrideWithColumnOnField() throws Exception { createAttributeOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -85,7 +85,7 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { }); } - private IType createTestAttributeOverride() throws Exception { + private ICompilationUnit createTestAttributeOverride() throws Exception { createAttributeOverridesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -102,8 +102,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES); AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next(); @@ -113,8 +113,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testGetNullColumn() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES); AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next(); @@ -124,8 +124,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES); AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next(); @@ -135,12 +135,12 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { attributeOverride.setName("Foo"); assertEquals("Foo", attributeOverride.getName()); - assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"Foo\"))"); + assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"Foo\"))", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestAttributeOverrideOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES); AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next(); @@ -149,14 +149,14 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { attributeOverride.setName(null); assertNull(attributeOverride.getName()); - assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")"); - assertSourceContains("@AttributeOverride"); - assertSourceContains("@AttributeOverrides"); + assertSourceDoesNotContain("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")", cu); + assertSourceContains("@AttributeOverride", cu); + assertSourceContains("@AttributeOverrides", cu); } public void testColumnGetName() throws Exception { - IType testType = this.createTestAttributeOverrideWithColumnOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverridesAnnotation attributeOverrides = (AttributeOverridesAnnotation) attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES); AttributeOverrideAnnotation attributeOverride = attributeOverrides.nestedAnnotations().next(); @@ -166,8 +166,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testColumnSetName() throws Exception { - IType testType = this.createTestAttributeOverrideWithColumnOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES).next(); @@ -177,20 +177,20 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { column.setName("Foo"); - assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\")))"); + assertSourceContains("@AttributeOverrides(@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column = @Column(name=\"Foo\")))", cu); column.setName(null); assertNull(attributeOverride.getColumn()); - assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")"); + assertSourceContains("@AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\")", cu); } public void testAddAttributeOverrideCopyExisting() throws Exception { - IType jdtType = createTestAttributeOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAttributeOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); assertNotNull(typeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES)); @@ -198,16 +198,16 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testAddAttributeOverrideToBeginningOfList() throws Exception { - IType jdtType = createTestAttributeOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAttributeOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})", cu); attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAZ"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"),@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)), @AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"),@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)), @AttributeOverride(name=\"BAR\")})", cu); Iterator<JavaResourceNode> attributeOverrides = typeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); assertEquals("BAZ", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName()); @@ -220,22 +220,22 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { } public void testRemoveAttributeOverrideCopyExisting() throws Exception { - IType jdtType = createTestAttributeOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestAttributeOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1)),@AttributeOverride(name=\"BAR\")})", cu); typeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); - assertSourceContains("@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1))"); + assertSourceContains("@AttributeOverride(name=\"FOO\", column = @Column(name=\"FOO\", columnDefinition = \"BAR\", table = \"BAZ\", unique = false, nullable = false, insertable = false, updatable = false, length = 1, precision = 1, scale = 1))", cu); } //not sure i want to test this api, how can we keep ContainerAnnotation.add, move, remove from being public? //users should go throught AbstractJavapersistenceResource. this gets confusing because you would handle it differently //for non top-level annotations // public void testAdd() throws Exception { -// IType testType = this.createTestType(); -// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType); +// ICompilationUnit cu = this.createTestType(); +// JavaPersistentTypeResource typeResource = buildJavaTypeResource(cu); // JavaPersistentAttributeResource attributeResource = typeResource.fields().next(); // AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES); // assertNull(attributeOverrides); @@ -259,8 +259,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { // } // // public void testMove() throws Exception { -// IType testType = this.createTestAttributeOverrideWithColumnOnField(); -// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType); +// ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); +// JavaPersistentTypeResource typeResource = buildJavaTypeResource(cu); // JavaPersistentAttributeResource attributeResource = typeResource.fields().next(); // AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES); // @@ -275,8 +275,8 @@ public class AttributeOverridesTests extends JavaResourceModelTestCase { // } // // public void testRemove() throws Exception { -// IType testType = this.createTestAttributeOverrideWithColumnOnField(); -// JavaPersistentTypeResource typeResource = buildJavaTypeResource(testType); +// ICompilationUnit cu = this.createTestAttributeOverrideWithColumnOnField(); +// JavaPersistentTypeResource typeResource = buildJavaTypeResource(cu); // JavaPersistentAttributeResource attributeResource = typeResource.fields().next(); // AttributeOverrides attributeOverrides = (AttributeOverrides) attributeResource.annotation(JPA.ATTRIBUTE_OVERRIDES); // diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java index 6f0ff5dd23..608c6ef248 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/BasicTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.BasicAnnotation; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JPA; @@ -24,7 +24,7 @@ public class BasicTests extends JavaResourceModelTestCase { super(name); } - private IType createTestBasic() throws Exception { + private ICompilationUnit createTestBasic() throws Exception { this.createAnnotationAndMembers("Basic", "boolean optional() default true;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -38,7 +38,7 @@ public class BasicTests extends JavaResourceModelTestCase { }); } - private IType createTestBasicWithOptional() throws Exception { + private ICompilationUnit createTestBasicWithOptional() throws Exception { this.createAnnotationAndMembers("Basic", "boolean optional() default true;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -52,7 +52,7 @@ public class BasicTests extends JavaResourceModelTestCase { }); } - private IType createTestBasicWithFetch() throws Exception { + private ICompilationUnit createTestBasicWithFetch() throws Exception { this.createAnnotationAndMembers("Basic", "boolean optional() default true; FetchType fetch() default FetchType.EAGER;"); this.createEnumAndMembers("FetchType", "EAGER, LAZY"); return this.createTestType(new DefaultAnnotationWriter() { @@ -68,8 +68,8 @@ public class BasicTests extends JavaResourceModelTestCase { } public void testBasic() throws Exception { - IType testType = this.createTestBasic(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasic(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -77,8 +77,8 @@ public class BasicTests extends JavaResourceModelTestCase { } public void testGetOptional() throws Exception { - IType testType = this.createTestBasicWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -86,8 +86,8 @@ public class BasicTests extends JavaResourceModelTestCase { } public void testSetOptional() throws Exception { - IType testType = this.createTestBasicWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -96,12 +96,12 @@ public class BasicTests extends JavaResourceModelTestCase { basic.setOptional(false); assertFalse(basic.getOptional()); - assertSourceContains("@Basic(optional=false)"); + assertSourceContains("@Basic(optional=false)", cu); } public void testSetOptionalNull() throws Exception { - IType testType = this.createTestBasicWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -110,13 +110,13 @@ public class BasicTests extends JavaResourceModelTestCase { basic.setOptional(null); assertNull(basic.getOptional()); - assertSourceContains("@Basic"); - assertSourceDoesNotContain("optional"); + assertSourceContains("@Basic", cu); + assertSourceDoesNotContain("optional", cu); } public void testGetFetch() throws Exception { - IType testType = this.createTestBasicWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -124,8 +124,8 @@ public class BasicTests extends JavaResourceModelTestCase { } public void testSetFetch() throws Exception { - IType testType = this.createTestBasicWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -134,12 +134,12 @@ public class BasicTests extends JavaResourceModelTestCase { basic.setFetch(FetchType.LAZY); assertEquals(FetchType.LAZY, basic.getFetch()); - assertSourceContains("@Basic(fetch=LAZY)"); + assertSourceContains("@Basic(fetch=LAZY)", cu); } public void testSetFetchNull() throws Exception { - IType testType = this.createTestBasicWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestBasicWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); BasicAnnotation basic = (BasicAnnotation) attributeResource.getMappingAnnotation(JPA.BASIC); @@ -148,7 +148,7 @@ public class BasicTests extends JavaResourceModelTestCase { basic.setFetch(null); assertNull(basic.getFetch()); - assertSourceContains("@Basic"); - assertSourceDoesNotContain("fetch"); + assertSourceContains("@Basic", cu); + assertSourceDoesNotContain("fetch", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java index c3b7d46140..a812d8438f 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ColumnTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.ColumnAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -41,7 +41,7 @@ public class ColumnTests extends JavaResourceModelTestCase { "int scale() default 0;"); } - private IType createTestColumn() throws Exception { + private ICompilationUnit createTestColumn() throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -55,7 +55,7 @@ public class ColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithName() throws Exception { + private ICompilationUnit createTestColumnWithName() throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -69,7 +69,7 @@ public class ColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithTable() throws Exception { + private ICompilationUnit createTestColumnWithTable() throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -83,7 +83,7 @@ public class ColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestColumnWithColumnDefinition() throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -97,7 +97,7 @@ public class ColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithBooleanElement(final String booleanElement) throws Exception { + private ICompilationUnit createTestColumnWithBooleanElement(final String booleanElement) throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -111,7 +111,7 @@ public class ColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithIntElement(final String intElement) throws Exception { + private ICompilationUnit createTestColumnWithIntElement(final String intElement) throws Exception { createColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -126,8 +126,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); assertNotNull(column); @@ -135,8 +135,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); assertNotNull(column); @@ -150,8 +150,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -161,12 +161,12 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@Column(name=\"Foo\")"); + assertSourceContains("@Column(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -175,20 +175,20 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetTable() throws Exception { - IType testType = this.createTestColumnWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); assertEquals(COLUMN_TABLE, column.getTable()); } public void testSetTable() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -198,24 +198,24 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setTable("Foo"); assertEquals("Foo", column.getTable()); - assertSourceContains("@Column(table=\"Foo\")"); + assertSourceContains("@Column(table=\"Foo\")", cu); column.setTable(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -225,16 +225,16 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@Column(columnDefinition=\"Foo\")"); + assertSourceContains("@Column(columnDefinition=\"Foo\")", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetUnique() throws Exception { - IType testType = this.createTestColumnWithBooleanElement("unique"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithBooleanElement("unique"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -242,8 +242,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetUnique() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -253,15 +253,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setUnique(Boolean.FALSE); assertEquals(Boolean.FALSE, column.getUnique()); - assertSourceContains("@Column(unique=false)"); + assertSourceContains("@Column(unique=false)", cu); column.setUnique(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetNullable() throws Exception { - IType testType = this.createTestColumnWithBooleanElement("nullable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithBooleanElement("nullable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -269,8 +269,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetNullable() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -280,15 +280,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setNullable(Boolean.FALSE); assertEquals(Boolean.FALSE, column.getNullable()); - assertSourceContains("@Column(nullable=false)"); + assertSourceContains("@Column(nullable=false)", cu); column.setNullable(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetInsertable() throws Exception { - IType testType = this.createTestColumnWithBooleanElement("insertable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithBooleanElement("insertable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -296,8 +296,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetInsertable() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -307,15 +307,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setInsertable(Boolean.FALSE); assertEquals(Boolean.FALSE, column.getInsertable()); - assertSourceContains("@Column(insertable=false)"); + assertSourceContains("@Column(insertable=false)", cu); column.setInsertable(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetUpdatable() throws Exception { - IType testType = this.createTestColumnWithBooleanElement("updatable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithBooleanElement("updatable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -323,8 +323,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetUpdatable() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -334,15 +334,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setUpdatable(Boolean.FALSE); assertEquals(Boolean.FALSE, column.getUpdatable()); - assertSourceContains("@Column(updatable=false)"); + assertSourceContains("@Column(updatable=false)", cu); column.setUpdatable(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetLength() throws Exception { - IType testType = this.createTestColumnWithIntElement("length"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithIntElement("length"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -350,8 +350,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetLength() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -361,15 +361,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setLength(Integer.valueOf(5)); assertEquals(Integer.valueOf(5), column.getLength()); - assertSourceContains("@Column(length=5)"); + assertSourceContains("@Column(length=5)", cu); column.setLength(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetPrecision() throws Exception { - IType testType = this.createTestColumnWithIntElement("precision"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithIntElement("precision"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -377,8 +377,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetPrecision() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -388,15 +388,15 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setPrecision(Integer.valueOf(5)); assertEquals(Integer.valueOf(5), column.getPrecision()); - assertSourceContains("@Column(precision=5)"); + assertSourceContains("@Column(precision=5)", cu); column.setPrecision(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testGetScale() throws Exception { - IType testType = this.createTestColumnWithIntElement("scale"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithIntElement("scale"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -404,8 +404,8 @@ public class ColumnTests extends JavaResourceModelTestCase { } public void testSetScale() throws Exception { - IType testType = this.createTestColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation column = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); @@ -415,9 +415,9 @@ public class ColumnTests extends JavaResourceModelTestCase { column.setScale(Integer.valueOf(5)); assertEquals(Integer.valueOf(5), column.getScale()); - assertSourceContains("@Column(scale=5)"); + assertSourceContains("@Column(scale=5)", cu); column.setScale(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java index fde1c90a5a..8aa31a5cfa 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorColumnTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; import org.eclipse.jpt.core.resource.java.DiscriminatorType; import org.eclipse.jpt.core.resource.java.JPA; @@ -35,7 +35,7 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { "int length() default 31;"); } - private IType createTestDiscriminatorColumn() throws Exception { + private ICompilationUnit createTestDiscriminatorColumn() throws Exception { createDiscriminatorColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -49,7 +49,7 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestDiscriminatorColumnWithName() throws Exception { + private ICompilationUnit createTestDiscriminatorColumnWithName() throws Exception { createDiscriminatorColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -63,7 +63,7 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestDiscriminatorColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestDiscriminatorColumnWithColumnDefinition() throws Exception { createDiscriminatorColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -77,7 +77,7 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestDiscriminatorColumnWithDiscriminatorType() throws Exception { + private ICompilationUnit createTestDiscriminatorColumnWithDiscriminatorType() throws Exception { createDiscriminatorColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -91,7 +91,7 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestColumnWithIntElement(final String intElement) throws Exception { + private ICompilationUnit createTestColumnWithIntElement(final String intElement) throws Exception { createDiscriminatorColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -106,16 +106,16 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestDiscriminatorColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNotNull(column); assertEquals(COLUMN_NAME, column.getName()); } public void testGetNull() throws Exception { - IType testType = this.createTestDiscriminatorColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNotNull(column); assertNull(column.getName()); @@ -124,8 +124,8 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestDiscriminatorColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNotNull(column); @@ -134,12 +134,12 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@DiscriminatorColumn(name=\"Foo\")"); + assertSourceContains("@DiscriminatorColumn(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestDiscriminatorColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertEquals(COLUMN_NAME, column.getName()); @@ -147,19 +147,19 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@DiscriminatorColumn"); + assertSourceDoesNotContain("@DiscriminatorColumn", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestDiscriminatorColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestDiscriminatorColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNotNull(column); @@ -168,24 +168,24 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@DiscriminatorColumn(columnDefinition=\"Foo\")"); + assertSourceContains("@DiscriminatorColumn(columnDefinition=\"Foo\")", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@DiscriminatorColumn"); + assertSourceDoesNotContain("@DiscriminatorColumn", cu); } public void testGetLength() throws Exception { - IType testType = this.createTestColumnWithIntElement("length"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestColumnWithIntElement("length"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertEquals(Integer.valueOf(5), column.getLength()); } public void testSetLength() throws Exception { - IType testType = this.createTestDiscriminatorColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNotNull(column); @@ -194,22 +194,22 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { column.setLength(Integer.valueOf(5)); assertEquals(Integer.valueOf(5), column.getLength()); - assertSourceContains("@DiscriminatorColumn(length=5)"); + assertSourceContains("@DiscriminatorColumn(length=5)", cu); column.setLength(null); - assertSourceDoesNotContain("@DiscriminatorColumn"); + assertSourceDoesNotContain("@DiscriminatorColumn", cu); } public void testGetDiscriminatorType() throws Exception { - IType testType = this.createTestDiscriminatorColumnWithDiscriminatorType(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumnWithDiscriminatorType(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertEquals(DiscriminatorType.CHAR, column.getDiscriminatorType()); } public void testSetDiscriminatorType() throws Exception { - IType testType = this.createTestDiscriminatorColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorColumnAnnotation column = (DiscriminatorColumnAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_COLUMN); assertNull(column.getDiscriminatorType()); @@ -217,9 +217,9 @@ public class DiscriminatorColumnTests extends JavaResourceModelTestCase { column.setDiscriminatorType(DiscriminatorType.INTEGER); assertEquals(DiscriminatorType.INTEGER, column.getDiscriminatorType()); - assertSourceContains("@DiscriminatorColumn(discriminatorType=INTEGER)"); + assertSourceContains("@DiscriminatorColumn(discriminatorType=INTEGER)", cu); column.setDiscriminatorType(null); - assertSourceDoesNotContain("@DiscriminatorColumn"); + assertSourceDoesNotContain("@DiscriminatorColumn", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java index 10091f2238..db386b45e3 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/DiscriminatorValueTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -22,7 +22,7 @@ public class DiscriminatorValueTests extends JavaResourceModelTestCase { super(name); } - private IType createTestDiscriminatorValue() throws Exception { + private ICompilationUnit createTestDiscriminatorValue() throws Exception { this.createAnnotationAndMembers("DiscriminatorValue", "String value() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -36,7 +36,7 @@ public class DiscriminatorValueTests extends JavaResourceModelTestCase { }); } - private IType createTestDiscriminatorValueWithValue() throws Exception { + private ICompilationUnit createTestDiscriminatorValueWithValue() throws Exception { this.createAnnotationAndMembers("DiscriminatorValue", "String value() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -51,34 +51,34 @@ public class DiscriminatorValueTests extends JavaResourceModelTestCase { } public void testDiscriminatorValue() throws Exception { - IType testType = this.createTestDiscriminatorValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE); assertNotNull(discriminatorValue); } public void testGetValue() throws Exception { - IType testType = this.createTestDiscriminatorValueWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorValueWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE); assertEquals("discriminator", discriminatorValue.getValue()); } public void testSetValue() throws Exception { - IType testType = this.createTestDiscriminatorValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestDiscriminatorValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); DiscriminatorValueAnnotation discriminatorValue = (DiscriminatorValueAnnotation) typeResource.getAnnotation(JPA.DISCRIMINATOR_VALUE); discriminatorValue.setValue("foo"); - assertSourceContains("@DiscriminatorValue(\"foo\")"); + assertSourceContains("@DiscriminatorValue(\"foo\")", cu); discriminatorValue.setValue(null); - assertSourceDoesNotContain("@DiscriminatorValue"); + assertSourceDoesNotContain("@DiscriminatorValue", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java index 6deeb69ac9..f4ab8532d0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddableTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; import org.eclipse.jpt.core.resource.java.EntityAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -24,7 +24,7 @@ public class EmbeddableTests extends JavaResourceModelTestCase { super(name); } - private IType createTestEmbeddable() throws Exception { + private ICompilationUnit createTestEmbeddable() throws Exception { this.createAnnotationAndMembers("Embeddable", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -38,7 +38,7 @@ public class EmbeddableTests extends JavaResourceModelTestCase { }); } - private IType createTestEmbeddableAndEntity() throws Exception { + private ICompilationUnit createTestEmbeddableAndEntity() throws Exception { this.createAnnotationAndMembers("Embeddable", ""); this.createAnnotationAndMembers("Entity", ""); return this.createTestType(new DefaultAnnotationWriter() { @@ -55,16 +55,16 @@ public class EmbeddableTests extends JavaResourceModelTestCase { } public void testEmbeddable() throws Exception { - IType testType = this.createTestEmbeddable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEmbeddable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(mappingAnnotation instanceof EmbeddableAnnotation); } public void testEmbeddableAndEntity() throws Exception { - IType testType = this.createTestEmbeddableAndEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEmbeddableAndEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(mappingAnnotation instanceof EmbeddableAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java index 88cded1b54..c5b90335b7 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedIdTests.java @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -24,7 +25,7 @@ public class EmbeddedIdTests extends JavaResourceModelTestCase { super(name); } - private IType createTestEmbeddedId() throws Exception { + private ICompilationUnit createTestEmbeddedId() throws Exception { this.createAnnotationAndMembers("EmbeddedId", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -39,8 +40,8 @@ public class EmbeddedIdTests extends JavaResourceModelTestCase { } public void testEmbeddedId() throws Exception { - IType testType = this.createTestEmbeddedId(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEmbeddedId(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java index 31e46332e7..db922e4ca2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EmbeddedTests.java @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -24,7 +25,7 @@ public class EmbeddedTests extends JavaResourceModelTestCase { super(name); } - private IType createTestEmbedded() throws Exception { + private ICompilationUnit createTestEmbedded() throws Exception { this.createAnnotationAndMembers("Embedded", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -39,8 +40,8 @@ public class EmbeddedTests extends JavaResourceModelTestCase { } public void testEmbedded() throws Exception { - IType testType = this.createTestEmbedded(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEmbedded(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java index 38e88d2f86..b2fcc69c28 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EntityTests.java @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; + +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EntityAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -26,7 +27,7 @@ public class EntityTests extends JavaResourceModelTestCase { super(name); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -40,7 +41,7 @@ public class EntityTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithName() throws Exception { + private ICompilationUnit createTestEntityWithName() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -54,7 +55,7 @@ public class EntityTests extends JavaResourceModelTestCase { }); } - private IType createTestMappedSuperclassAndEntity() throws Exception { + private ICompilationUnit createTestMappedSuperclassAndEntity() throws Exception { this.createAnnotationAndMembers("MappedSuperclass", ""); this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -71,8 +72,8 @@ public class EntityTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestEntityWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY); assertTrue(entity != null); @@ -80,8 +81,8 @@ public class EntityTests extends JavaResourceModelTestCase { } public void testGetNameNull() throws Exception { - IType testType = this.createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY); assertTrue(entity != null); @@ -89,20 +90,20 @@ public class EntityTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY); assertNull(entity.getName()); entity.setName("Foo"); assertEquals("Foo", entity.getName()); - assertSourceContains("@Entity(name=\"Foo\")"); + assertSourceContains("@Entity(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestEntityWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); EntityAnnotation entity = (EntityAnnotation) typeResource.getMappingAnnotation(JPA.ENTITY); assertEquals(ENTITY_NAME, entity.getName()); @@ -110,13 +111,13 @@ public class EntityTests extends JavaResourceModelTestCase { entity.setName(null); assertNull(entity.getName()); - assertSourceContains("@Entity"); - assertSourceDoesNotContain("@Entity(name=\"Foo\")"); + assertSourceContains("@Entity", cu); + assertSourceDoesNotContain("@Entity(name=\"Foo\")", cu); } public void testMappedSuperclassAndEntity() throws Exception { - IType testType = this.createTestMappedSuperclassAndEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMappedSuperclassAndEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(mappingAnnotation instanceof EntityAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java index 37ec34c2e8..cd7dd1ef49 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/EnumeratedTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EnumType; import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; import org.eclipse.jpt.core.resource.java.JPA; @@ -24,7 +24,7 @@ public class EnumeratedTests extends JavaResourceModelTestCase { super(name); } - private IType createTestEnumerated() throws Exception { + private ICompilationUnit createTestEnumerated() throws Exception { this.createAnnotationAndMembers("Enumerated", "EnumType value();"); this.createEnumAndMembers("EnumType", "ORDINAL, STRING"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class EnumeratedTests extends JavaResourceModelTestCase { }); } - private IType createTestEnumeratedWithValue() throws Exception { + private ICompilationUnit createTestEnumeratedWithValue() throws Exception { this.createAnnotationAndMembers("Enumerated", "EnumType value();"); this.createEnumAndMembers("EnumType", "ORDINAL, STRING"); return this.createTestType(new DefaultAnnotationWriter() { @@ -55,8 +55,8 @@ public class EnumeratedTests extends JavaResourceModelTestCase { } public void testEnumerated() throws Exception { - IType testType = this.createTestEnumerated(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEnumerated(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED); @@ -64,8 +64,8 @@ public class EnumeratedTests extends JavaResourceModelTestCase { } public void testGetValue() throws Exception { - IType testType = this.createTestEnumeratedWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEnumeratedWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED); @@ -73,19 +73,19 @@ public class EnumeratedTests extends JavaResourceModelTestCase { } public void testSetValue() throws Exception { - IType testType = this.createTestEnumerated(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEnumerated(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); EnumeratedAnnotation enumerated = (EnumeratedAnnotation) attributeResource.getAnnotation(JPA.ENUMERATED); enumerated.setValue(EnumType.STRING); - assertSourceContains("@Enumerated(STRING)"); + assertSourceContains("@Enumerated(STRING)", cu); enumerated.setValue(null); - assertSourceDoesNotContain("@Enumerated"); + assertSourceDoesNotContain("@Enumerated", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java index 352b1145eb..7420cddd33 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/GeneratedValueTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; import org.eclipse.jpt.core.resource.java.GenerationType; import org.eclipse.jpt.core.resource.java.JPA; @@ -34,7 +34,7 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { createGenerationTypeEnum(); } - private IType createTestGeneratedValue() throws Exception { + private ICompilationUnit createTestGeneratedValue() throws Exception { createGeneratedValueAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -48,7 +48,7 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { }); } - private IType createTestGeneratedValueWithGenerator() throws Exception { + private ICompilationUnit createTestGeneratedValueWithGenerator() throws Exception { createGeneratedValueAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -62,7 +62,7 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { }); } - private IType createTestGeneratedValueWithStrategy() throws Exception { + private ICompilationUnit createTestGeneratedValueWithStrategy() throws Exception { createGeneratedValueAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -77,8 +77,8 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { } public void testGeneratedValue() throws Exception { - IType testType = this.createTestGeneratedValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestGeneratedValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); @@ -86,8 +86,8 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { } public void testGetGenerator() throws Exception { - IType testType = this.createTestGeneratedValueWithGenerator(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestGeneratedValueWithGenerator(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); @@ -95,8 +95,8 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { } public void testSetGenerator() throws Exception { - IType testType = this.createTestGeneratedValueWithGenerator(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestGeneratedValueWithGenerator(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); @@ -105,18 +105,18 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { generatedValue.setGenerator("foo"); assertEquals("foo", generatedValue.getGenerator()); - assertSourceContains("@GeneratedValue(generator=\"foo\")"); + assertSourceContains("@GeneratedValue(generator=\"foo\")", cu); generatedValue.setGenerator(null); assertNull(generatedValue.getGenerator()); - assertSourceDoesNotContain("generator"); - assertSourceContains("@GeneratedValue"); + assertSourceDoesNotContain("generator", cu); + assertSourceContains("@GeneratedValue", cu); } public void testGetStrategy() throws Exception { - IType testType = this.createTestGeneratedValueWithStrategy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestGeneratedValueWithStrategy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); @@ -124,8 +124,8 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { } public void testSetStrategy() throws Exception { - IType testType = this.createTestGeneratedValueWithStrategy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestGeneratedValueWithStrategy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); GeneratedValueAnnotation generatedValue = (GeneratedValueAnnotation) attributeResource.getAnnotation(JPA.GENERATED_VALUE); @@ -134,11 +134,11 @@ public class GeneratedValueTests extends JavaResourceModelTestCase { generatedValue.setStrategy(GenerationType.TABLE); assertEquals(GenerationType.TABLE, generatedValue.getStrategy()); - assertSourceContains("@GeneratedValue(strategy=TABLE)"); + assertSourceContains("@GeneratedValue(strategy=TABLE)", cu); generatedValue.setStrategy(null); assertNull(generatedValue.getStrategy()); - assertSourceDoesNotContain("strategy"); - assertSourceContains("@GeneratedValue"); + assertSourceDoesNotContain("strategy", cu); + assertSourceContains("@GeneratedValue", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java index 2654916417..d88f43bd6b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.IdClassAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -28,7 +28,7 @@ public class IdClassTests extends JavaResourceModelTestCase { this.createAnnotationAndMembers("IdClass", "Class value();"); } - private IType createTestIdClass() throws Exception { + private ICompilationUnit createTestIdClass() throws Exception { createIdClassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -42,7 +42,7 @@ public class IdClassTests extends JavaResourceModelTestCase { }); } - private IType createTestIdClassWithValue() throws Exception { + private ICompilationUnit createTestIdClassWithValue() throws Exception { createIdClassAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -57,8 +57,8 @@ public class IdClassTests extends JavaResourceModelTestCase { } public void testIdClass() throws Exception { - IType testType = this.createTestIdClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestIdClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS); assertNotNull(idClass); @@ -66,16 +66,16 @@ public class IdClassTests extends JavaResourceModelTestCase { } public void testGetValue() throws Exception { - IType testType = this.createTestIdClassWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestIdClassWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS); assertEquals(ID_CLASS_VALUE, idClass.getValue()); } public void testSetValue() throws Exception { - IType testType = this.createTestIdClassWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestIdClassWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS); assertEquals(ID_CLASS_VALUE, idClass.getValue()); @@ -83,19 +83,19 @@ public class IdClassTests extends JavaResourceModelTestCase { idClass.setValue("foo"); assertEquals("foo", idClass.getValue()); - assertSourceContains("@IdClass(foo.class)"); + assertSourceContains("@IdClass(foo.class)", cu); idClass.setValue(null); - assertSourceDoesNotContain("@IdClass"); + assertSourceDoesNotContain("@IdClass", cu); idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS); assertNull(idClass); } public void testGetFullyQualifiedClass() throws Exception { - IType testType = this.createTestIdClassWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestIdClassWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getAnnotation(JPA.ID_CLASS); assertNotNull(idClass.getValue()); @@ -105,7 +105,7 @@ public class IdClassTests extends JavaResourceModelTestCase { idClass.setValue(TYPE_NAME); assertEquals(FULLY_QUALIFIED_TYPE_NAME, idClass.getFullyQualifiedClass()); - assertSourceContains("@IdClass(" + TYPE_NAME + ".class)"); + assertSourceContains("@IdClass(" + TYPE_NAME + ".class)", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java index 9dd0af0dcd..721454d21c 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.IdAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -24,7 +24,7 @@ public class IdTests extends JavaResourceModelTestCase { super(name); } - private IType createTestId() throws Exception { + private ICompilationUnit createTestId() throws Exception { this.createAnnotationAndMembers("Id", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -39,8 +39,8 @@ public class IdTests extends JavaResourceModelTestCase { } public void testId() throws Exception { - IType testType = this.createTestId(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestId(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java index 93c503c00e..a2058e6d22 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/InheritanceTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; import org.eclipse.jpt.core.resource.java.InheritanceType; import org.eclipse.jpt.core.resource.java.JPA; @@ -23,7 +23,7 @@ public class InheritanceTests extends JavaResourceModelTestCase { super(name); } - private IType createTestInheritance() throws Exception { + private ICompilationUnit createTestInheritance() throws Exception { this.createAnnotationAndMembers("Inheritance", "InheritanceType strategy() default SINGLE_TABLE;"); this.createEnumAndMembers("InheritanceType", "SINGLE_TABLE, JOINED, TABLE_PER_CLASS"); return this.createTestType(new DefaultAnnotationWriter() { @@ -38,7 +38,7 @@ public class InheritanceTests extends JavaResourceModelTestCase { }); } - private IType createTestInheritanceWithStrategy() throws Exception { + private ICompilationUnit createTestInheritanceWithStrategy() throws Exception { this.createAnnotationAndMembers("Inheritance", "InheritanceType strategy() default SINGLE_TABLE;"); this.createEnumAndMembers("InheritanceType", "SINGLE_TABLE, JOINED, TABLE_PER_CLASS"); return this.createTestType(new DefaultAnnotationWriter() { @@ -54,33 +54,33 @@ public class InheritanceTests extends JavaResourceModelTestCase { } public void testInheritance() throws Exception { - IType testType = this.createTestInheritance(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestInheritance(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE); assertNotNull(inheritance); } public void testGetStrategy() throws Exception { - IType testType = this.createTestInheritanceWithStrategy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestInheritanceWithStrategy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE); assertEquals(InheritanceType.JOINED, inheritance.getStrategy()); } public void testSetStrategy() throws Exception { - IType testType = this.createTestInheritance(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestInheritance(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); InheritanceAnnotation inheritance = (InheritanceAnnotation) typeResource.getAnnotation(JPA.INHERITANCE); inheritance.setStrategy(InheritanceType.TABLE_PER_CLASS); - assertSourceContains("@Inheritance(strategy=TABLE_PER_CLASS)"); + assertSourceContains("@Inheritance(strategy=TABLE_PER_CLASS)", cu); inheritance.setStrategy(null); - assertSourceDoesNotContain("@Inheritance"); + assertSourceDoesNotContain("@Inheritance", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java index d6cde50613..4df0a87c68 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JPTToolsTests.java @@ -9,8 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.resource.java; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.IMethodBinding; import org.eclipse.jdt.core.dom.IVariableBinding; @@ -26,7 +25,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { super(name); } - private IType createTestTypeFieldWithModifier(final String modifier) throws Exception { + private ICompilationUnit createTestTypeFieldWithModifier(final String modifier) throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -38,12 +37,12 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - protected FieldAttribute fooField() throws JavaModelException { - return this.fieldNamed("foo"); + protected FieldAttribute fooField(ICompilationUnit cu) { + return this.buildField("foo", cu); } - private IType createTestTypeGetMethodWithModifier(final String modifier) throws Exception { + private ICompilationUnit createTestTypeGetMethodWithModifier(final String modifier) throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -61,7 +60,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeInvalidMethodName() throws Exception { + private ICompilationUnit createTestTypeInvalidMethodName() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -79,7 +78,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeConstructor() throws Exception { + private ICompilationUnit createTestTypeConstructor() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -93,7 +92,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeVoidMethodReturnType() throws Exception { + private ICompilationUnit createTestTypeVoidMethodReturnType() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -111,7 +110,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } -// private IType createTestTypeInvalidMethodReturnType() throws Exception { +// private ICompilationUnit createTestTypeInvalidMethodReturnType() throws Exception { // return this.createTestType(new DefaultAnnotationWriter() { // // @Override @@ -133,7 +132,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { // }); // } - private IType createTestTypeIsMethod() throws Exception { + private ICompilationUnit createTestTypeIsMethod() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -151,7 +150,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeIsMethodReturnInt() throws Exception { + private ICompilationUnit createTestTypeIsMethodReturnInt() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -169,7 +168,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeIsAndGetMethodWithModifier(final String modifier) throws Exception { + private ICompilationUnit createTestTypeIsAndGetMethodWithModifier(final String modifier) throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -191,7 +190,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeSetMethodWithModifier(final String modifier) throws Exception { + private ICompilationUnit createTestTypeSetMethodWithModifier(final String modifier) throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -209,7 +208,7 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - private IType createTestTypeWithMemberTypes() throws Exception { + private ICompilationUnit createTestTypeWithMemberTypes() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @Override public void appendMemberTypeTo(StringBuilder sb) { @@ -224,163 +223,163 @@ public class JPTToolsTests extends JavaResourceModelTestCase { }); } - protected MethodAttribute fooMethod() throws JavaModelException { - return this.methodNamed("getFoo"); + protected MethodAttribute fooMethod(ICompilationUnit cu) { + return this.buildMethod("getFoo", cu); } //private String foo; - persistable public void testFieldIsPersistable1() throws Exception { - IType testType = createTestTypeFieldWithModifier("private"); - FieldAttribute fieldAttribute = fooField(); - IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeFieldWithModifier("private"); + FieldAttribute fieldAttribute = fooField(cu); + IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.fieldIsPersistable(variableBinding)); } //private static String foo; - not persistable public void testFieldIsPersistable2() throws Exception { - IType testType = createTestTypeFieldWithModifier("private static"); - FieldAttribute fieldAttribute = fooField(); - IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeFieldWithModifier("private static"); + FieldAttribute fieldAttribute = fooField(cu); + IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.fieldIsPersistable(variableBinding)); } //private transient String foo; - not persistable public void testFieldIsPersistable3() throws Exception { - IType testType = createTestTypeFieldWithModifier("private transient"); - FieldAttribute fieldAttribute = fooField(); - IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeFieldWithModifier("private transient"); + FieldAttribute fieldAttribute = fooField(cu); + IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.fieldIsPersistable(variableBinding)); } //private final String foo; - persistable public void testFieldIsPersistable4() throws Exception { - IType testType = createTestTypeFieldWithModifier("private final"); - FieldAttribute fieldAttribute = fooField(); - IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeFieldWithModifier("private final"); + FieldAttribute fieldAttribute = fooField(cu); + IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.fieldIsPersistable(variableBinding)); } //public String foo; - persistable public void testFieldIsPersistable5() throws Exception { - IType testType = createTestTypeFieldWithModifier("public"); - FieldAttribute fieldAttribute = fooField(); - IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeFieldWithModifier("public"); + FieldAttribute fieldAttribute = fooField(cu); + IVariableBinding variableBinding = fieldAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.fieldIsPersistable(variableBinding)); } //public int getFoo() {} - persistable public void testMethodIsPersistablePropertyGetter1() throws Exception { - IType testType = createTestTypeGetMethodWithModifier("public"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier("public"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //protected int getFoo() {} - persistable public void testMethodIsPersistablePropertyGetter2() throws Exception { - IType testType = createTestTypeGetMethodWithModifier("protected"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier("protected"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //int getFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter3() throws Exception { - IType testType = createTestTypeGetMethodWithModifier(""); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier(""); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //private int getFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter4() throws Exception { - IType testType = createTestTypeGetMethodWithModifier("private"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier("private"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public static int getFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter5() throws Exception { - IType testType = createTestTypeGetMethodWithModifier("public static"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier("public static"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public final int getFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter6() throws Exception { - IType testType = createTestTypeGetMethodWithModifier("public final"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeGetMethodWithModifier("public final"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public void setFoo(int foo) {} - persistable public void testMethodIsPersistablePropertyGetter7() throws Exception { - IType testType = createTestTypeSetMethodWithModifier("public"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier("public"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //protected void setFoo(int foo) {} - persistable public void testMethodIsPersistablePropertyGetter8() throws Exception { - IType testType = createTestTypeSetMethodWithModifier("protected"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier("protected"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //void setFoo(int foo) {} - not persistable public void testMethodIsPersistablePropertyGetter9() throws Exception { - IType testType = createTestTypeSetMethodWithModifier(""); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier(""); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //private void setFoo(int foo) {} - not persistable public void testMethodIsPersistablePropertyGetter10() throws Exception { - IType testType = createTestTypeSetMethodWithModifier("private"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier("private"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public static void setFoo(int foo) {} - not persistable public void testMethodIsPersistablePropertyGetter11() throws Exception { - IType testType = createTestTypeSetMethodWithModifier("public static"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier("public static"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public final void setFoo(int foo) {} - not persistable public void testMethodIsPersistablePropertyGetter12() throws Exception { - IType testType = createTestTypeSetMethodWithModifier("public final"); - MethodAttribute methodAttribute = fooMethod(); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeSetMethodWithModifier("public final"); + MethodAttribute methodAttribute = fooMethod(cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public boolean isFoo() {} - persistable public void testMethodIsPersistablePropertyGetter13() throws Exception { - IType testType = createTestTypeIsMethod(); - MethodAttribute methodAttribute = this.methodNamed("isFoo"); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeIsMethod(); + MethodAttribute methodAttribute = this.buildMethod("isFoo", cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertTrue(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } //public int isFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter14() throws Exception { - IType testType = createTestTypeIsMethodReturnInt(); - MethodAttribute methodAttribute = this.methodNamed("isFoo"); - IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(testType)); + ICompilationUnit cu = createTestTypeIsMethodReturnInt(); + MethodAttribute methodAttribute = this.buildMethod("isFoo", cu); + IMethodBinding methodBinding = methodAttribute.getBinding(JDTTools.buildASTRoot(cu)); assertFalse(JPTTools.methodIsPersistablePropertyGetter(methodBinding)); } @@ -388,30 +387,30 @@ public class JPTToolsTests extends JavaResourceModelTestCase { //public int isFoo() {} - persistable //public int getFoo() {} - not persistable public void testMethodIsPersistablePropertyGetter15() throws Exception { - IType testType = createTestTypeIsAndGetMethodWithModifier("public"); - MethodAttribute isFooMethod = this.methodNamed("isFoo"); - MethodAttribute getFooMethod = this.methodNamed("getFoo"); + ICompilationUnit cu = createTestTypeIsAndGetMethodWithModifier("public"); + MethodAttribute isFooMethod = this.buildMethod("isFoo", cu); + MethodAttribute getFooMethod = this.buildMethod("getFoo", cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertTrue(JPTTools.methodIsPersistablePropertyGetter(isFooMethod.getBinding(astRoot))); assertFalse(JPTTools.methodIsPersistablePropertyGetter(getFooMethod.getBinding(astRoot))); } //public int foo() {} - not persistable public void testMethodIsPersistablePropertyGetter16() throws Exception { - IType testType = createTestTypeInvalidMethodName(); - MethodAttribute fooMethod = this.methodNamed("foo"); + ICompilationUnit cu = createTestTypeInvalidMethodName(); + MethodAttribute fooMethod = this.buildMethod("foo", cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.getBinding(astRoot))); } //public void getFoo() {} - not persistable - void return type public void testMethodIsPersistablePropertyGetter17() throws Exception { - IType testType = createTestTypeVoidMethodReturnType(); - MethodAttribute fooMethod = this.methodNamed("getFoo"); + ICompilationUnit cu = createTestTypeVoidMethodReturnType(); + MethodAttribute fooMethod = this.buildMethod("getFoo", cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.getBinding(astRoot))); } @@ -420,108 +419,99 @@ public class JPTToolsTests extends JavaResourceModelTestCase { //**this if it is returning null there instead of returning null for IMethodBinding.getReturnType() // //public Foo getFoo() {} - not persistable - Foo does not resolve // public void testMethodIsPersistablePropertyGetter18() throws Exception { -// IType testType = createTestTypeInvalidMethodReturnType(); -// MethodAttribute getFooMethod = this.methodNamed("getFoo"); +// ICompilationUnit cu = createTestTypeInvalidMethodReturnType(); +// MethodAttribute getFooMethod = this.buildMethod("getFoo"); // -// CompilationUnit astRoot = JDTTools.buildASTRoot(testType); +// CompilationUnit astRoot = JDTTools.buildASTRoot(cu); // assertFalse(JPTTools.methodIsPersistablePropertyGetter(fooMethod.binding(astRoot))); // } //method with parameters - not persistable public void testMethodIsPersistablePropertyGetter19() throws Exception { - IType testType = createTestType(); - MethodAttribute setIdMethod = idSetMethod(); + ICompilationUnit cu = createTestType(); + MethodAttribute setIdMethod = idSetMethod(cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.methodIsPersistablePropertyGetter(setIdMethod.getBinding(astRoot))); } //constructor - not persistable public void testMethodIsPersistablePropertyGetter20() throws Exception { - IType testType = createTestTypeConstructor(); - MethodAttribute constructor = methodNamed(TYPE_NAME); + ICompilationUnit cu = createTestTypeConstructor(); + MethodAttribute constructor = buildMethod(TYPE_NAME, cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.methodIsPersistablePropertyGetter(constructor.getBinding(astRoot))); } //no corresponding set method - not persistable public void testMethodIsPersistablePropertyGetter21() throws Exception { - IType testType = createTestType(); - MethodAttribute getNameMethod = nameGetMethod(); + ICompilationUnit cu = createTestType(); + MethodAttribute getNameMethod = nameGetMethod(cu); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.methodIsPersistablePropertyGetter(getNameMethod.getBinding(astRoot))); } //public class AnnotationTestType - public void testTypeIsPersistable() throws Exception { - IType testType = createTestType(); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + public void cuIsPersistable() throws Exception { + ICompilationUnit cu = createTestType(); + Type type = testType(cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertTrue(JPTTools.typeIsPersistable(type.getBinding(astRoot))); } //public final class MyFinal - public void testTypeIsPersistable2() throws Exception { - IType testType = this.javaProject.createType("finals", "MyFinal.java", "public final class MyFinal { }"); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + public void cuIsPersistable2() throws Exception { + ICompilationUnit cu = this.javaProject.createCompilationUnit("finals", "MyFinal.java", "public final class MyFinal { }"); + Type type = buildType("MyFinal", cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot))); } - //public interface AnnotationTestType - public void testTypeIsPersistable3() throws Exception { - IType testType = this.javaProject.createType("interfaces", "MyInterface.java", "public interface MyInterface { }"); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + //public interface MyInterface + public void cuIsPersistable3() throws Exception { + ICompilationUnit cu = this.javaProject.createCompilationUnit("interfaces", "MyInterface.java", "public interface MyInterface { }"); + Type type = buildType("MyInterface", cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot))); } //enum not persistable - public void testTypeIsPersistable4() throws Exception { - IType testType = this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + public void cuIsPersistable4() throws Exception { + ICompilationUnit cu = this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); + Type type = buildType("TestEnum", cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot))); } //annotation not persistable - public void testTypeIsPersistable5() throws Exception { - IType testType = this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); + public void cuIsPersistable5() throws Exception { + ICompilationUnit cu = this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); + Type type = buildType("TestAnnotation", cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot))); } //public static member type is persistable - public void testTypeIsPersistable6() throws Exception { - IType testType = this.createTestTypeWithMemberTypes(); - IType staticType = testType.getType("FooStatic"); - Type type = buildType(staticType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); - assertTrue(JPTTools.typeIsPersistable(type.getBinding(astRoot))); + public void cuIsPersistable6() throws Exception { + ICompilationUnit cu = this.createTestTypeWithMemberTypes(); + Type testType = this.testType(cu); + Type memberType = this.buildType(testType, "FooStatic", 1, cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); + assertTrue(JPTTools.typeIsPersistable(memberType.getBinding(astRoot))); } //non-static member type is not persistable - public void testTypeIsPersistable7() throws Exception { - IType testType = this.createTestTypeWithMemberTypes(); - IType staticType = testType.getType("FooNotStatic"); - Type type = buildType(staticType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); - assertFalse(JPTTools.typeIsPersistable(type.getBinding(astRoot))); + public void cuIsPersistable7() throws Exception { + ICompilationUnit cu = this.createTestTypeWithMemberTypes(); + Type testType = this.testType(cu); + Type memberType = this.buildType(testType, "FooNotStatic", 1, cu); + CompilationUnit astRoot = JDTTools.buildASTRoot(cu); + assertFalse(JPTTools.typeIsPersistable(memberType.getBinding(astRoot))); } //TODO still need to test typeIsPersistable() returns false for local and anonymous classes - - public void testIsAbstract() throws Exception { - IType testType = createTestType(); - Type type = buildType(testType); - CompilationUnit astRoot = JDTTools.buildASTRoot(testType); - - assertFalse(JPTTools.typeIsAbstract(type.getBinding(astRoot))); - } - } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java index 2f67eb27f8..9a038055ab 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java @@ -15,8 +15,8 @@ import org.eclipse.core.resources.IResourceProxy; import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ElementChangedEvent; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IElementChangedListener; -import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JptCorePlugin; @@ -28,6 +28,7 @@ import org.eclipse.jpt.core.internal.utility.jdt.NullAnnotationEditFormatter; import org.eclipse.jpt.core.resource.java.JavaResourceModel; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.tests.internal.utility.jdt.AnnotationTestCase; +import org.eclipse.jpt.utility.CommandExecutorProvider; import org.eclipse.jpt.utility.internal.StringTools; public class JavaResourceModelTestCase extends AnnotationTestCase @@ -71,12 +72,12 @@ public class JavaResourceModelTestCase extends AnnotationTestCase } } - protected IType createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - return this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + protected ICompilationUnit createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { + return this.javaProject.createCompilationUnit("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } - protected IType createEnumAndMembers(String enumName, String enumBody) throws Exception { - return this.javaProject.createType("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); + protected ICompilationUnit createEnumAndMembers(String enumName, String enumBody) throws Exception { + return this.javaProject.createCompilationUnit("javax.persistence", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); } //build up a dummy JpaProject that does not have JpaFiles in it and does not update from java changes @@ -114,23 +115,23 @@ public class JavaResourceModelTestCase extends AnnotationTestCase return config; } - protected JavaResourcePersistentType buildJavaTypeResource(IType testType) + protected JavaResourcePersistentType buildJavaTypeResource(ICompilationUnit cu) throws CoreException { - this.javaResourceModel = buildJavaResourceModel(testType); + this.javaResourceModel = buildJavaResourceModel(cu); this.javaResourceModel.resolveTypes(); - return this.javaResourceModel.getResource().getPersistentType(); + return this.javaResourceModel.getJpaCompilationUnit().getPersistentType(); } - protected JavaResourceModel buildJavaResourceModel(IType testType) throws CoreException { + protected JavaResourceModel buildJavaResourceModel(ICompilationUnit cu) throws CoreException { if (this.javaResourceModel != null) { throw new IllegalStateException(); } - IFile file = (IFile) testType.getResource(); + IFile file = (IFile) cu.getResource(); JpaProject jpaProject = buildJpaProject(); return new JavaResourceModelImpl( file, jpaProject.getJpaPlatform().getAnnotationProvider(), - MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER, + CommandExecutorProvider.Default.instance(), NullAnnotationEditFormatter.instance()); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java index 5553df00e2..b14feb7030 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java @@ -11,8 +11,10 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Collection; import java.util.Iterator; +import java.util.List; + import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.internal.resource.java.IdImpl; import org.eclipse.jpt.core.internal.resource.java.OneToOneImpl; import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; @@ -37,7 +39,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC super(name); } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -52,7 +54,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityWithNonResolvingField() throws Exception { + private ICompilationUnit createTestEntityWithNonResolvingField() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -72,7 +74,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } }); } - private IType createTestEntityWithNonResolvingMethod() throws Exception { + private ICompilationUnit createTestEntityWithNonResolvingMethod() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -106,7 +108,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityMultipleVariableDeclarationsPerLine() throws Exception { + private ICompilationUnit createTestEntityMultipleVariableDeclarationsPerLine() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Column", "String name();"); @@ -134,7 +136,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityWithIdAndBasic() throws Exception { + private ICompilationUnit createTestEntityWithIdAndBasic() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Id", ""); this.createAnnotationAndMembers("Basic", ""); @@ -157,7 +159,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityAnnotatedField() throws Exception { + private ICompilationUnit createTestEntityAnnotatedField() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Column", "String name();"); this.createAnnotationAndMembers("Id", "String name();"); @@ -182,7 +184,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityWithColumn() throws Exception { + private ICompilationUnit createTestEntityWithColumn() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Column", "String name(); String table();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -202,7 +204,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEntityWithIdColumnGeneratedValue() throws Exception { + private ICompilationUnit createTestEntityWithIdColumnGeneratedValue() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Column", "String name(); String table();"); this.createAnnotationAndMembers("GeneratedValue", ""); @@ -228,7 +230,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } - private IType createTestEntityMultipleColumns() throws Exception { + private ICompilationUnit createTestEntityMultipleColumns() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); this.createAnnotationAndMembers("Column", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -250,7 +252,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEmbeddedWithAttributeOverride() throws Exception { + private ICompilationUnit createTestEmbeddedWithAttributeOverride() throws Exception { this.createAnnotationAndMembers("Embedded", "String name();"); this.createAnnotationAndMembers("AttributeOverride", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -266,7 +268,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } }); } - private IType createTestEmbeddedWithAttributeOverrides() throws Exception { + private ICompilationUnit createTestEmbeddedWithAttributeOverrides() throws Exception { this.createAnnotationAndMembers("Embedded", "String name();"); this.createAnnotationAndMembers("AttributeOverride", "String name();"); this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();"); @@ -283,7 +285,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } }); } - private IType createTestEmbeddedWithAttributeOverridesEmpty() throws Exception { + private ICompilationUnit createTestEmbeddedWithAttributeOverridesEmpty() throws Exception { this.createAnnotationAndMembers("Embedded", "String name();"); this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -300,7 +302,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEmbeddedWith2AttributeOverrides() throws Exception { + private ICompilationUnit createTestEmbeddedWith2AttributeOverrides() throws Exception { this.createAnnotationAndMembers("Embedded", "String name();"); this.createAnnotationAndMembers("AttributeOverride", "String name();"); this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();"); @@ -318,7 +320,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestEmbeddedWithAttributeOverrideAndAttributeOverrides() throws Exception { + private ICompilationUnit createTestEmbeddedWithAttributeOverrideAndAttributeOverrides() throws Exception { this.createAnnotationAndMembers("Embedded", "String name();"); this.createAnnotationAndMembers("AttributeOverride", "String name();"); this.createAnnotationAndMembers("AttributeOverrides", "AttributeOverride[] value();"); @@ -338,7 +340,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestTypePublicAttribute() throws Exception { + private ICompilationUnit createTestTypePublicAttribute() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @@ -351,7 +353,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestTypePackageAttribute() throws Exception { + private ICompilationUnit createTestTypePackageAttribute() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @@ -364,7 +366,7 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC }); } - private IType createTestTypeFinalAttribute() throws Exception { + private ICompilationUnit createTestTypeFinalAttribute() throws Exception { return this.createTestType(new DefaultAnnotationWriter() { @@ -378,62 +380,62 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } public void testJavaAttributeAnnotations() throws Exception { - IType testType = this.createTestEntityWithColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(1, attributeResource.annotationsSize()); } public void testJavaAttributeAnnotation() throws Exception { - IType testType = this.createTestEntityWithColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertNotNull(attributeResource.getAnnotation(JPA.COLUMN)); } public void testJavaAttributeAnnotationNull() throws Exception { - IType testType = this.createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertNull(attributeResource.getAnnotation(JPA.TABLE)); } //This will result in a compilation error, but we assume the first column found public void testDuplicateAnnotations() throws Exception { - IType testType = this.createTestEntityMultipleColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityMultipleColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation columnResource = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); assertEquals("FOO", columnResource.getName()); } public void testRemoveColumn() throws Exception { - IType testType = this.createTestEntityWithColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); attributeResource.removeAnnotation(JPA.COLUMN); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } public void testRemoveColumnName() throws Exception { - IType testType = this.createTestEntityWithColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ColumnAnnotation columnResource = (ColumnAnnotation) attributeResource.getAnnotation(JPA.COLUMN); columnResource.setTable(null); - assertSourceContains("@Column(name=\"FOO\")"); + assertSourceContains("@Column(name=\"FOO\")", cu); columnResource.setName(null); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); assertNull(typeResource.getAnnotation(JPA.TABLE)); } public void testMultipleAttributeMappings() throws Exception { - IType testType = this.createTestEntityWithIdAndBasic(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithIdAndBasic(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(2, attributeResource.mappingAnnotationsSize()); @@ -443,34 +445,34 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC JavaResourceNode javaAttributeMappingAnnotation = attributeResource.getMappingAnnotation(); assertTrue(javaAttributeMappingAnnotation instanceof BasicAnnotation); - assertSourceContains("@Basic"); - assertSourceContains("@Id"); + assertSourceContains("@Basic", cu); + assertSourceContains("@Id", cu); this.createAnnotationAndMembers("OneToMany", ""); attributeResource.setMappingAnnotation(JPA.ONE_TO_MANY); assertEquals(1, attributeResource.mappingAnnotationsSize()); javaAttributeMappingAnnotation = attributeResource.getMappingAnnotation(); assertTrue(javaAttributeMappingAnnotation instanceof OneToManyAnnotation); - assertSourceDoesNotContain("@Id"); - assertSourceContains("@OneToMany"); - assertSourceDoesNotContain("@Basic"); + assertSourceDoesNotContain("@Id", cu); + assertSourceContains("@OneToMany", cu); + assertSourceDoesNotContain("@Basic", cu); } public void testSetJavaAttributeMappingAnnotation() throws Exception { - IType testType = createTestType(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestType(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(0, attributeResource.mappingAnnotationsSize()); this.createAnnotationAndMembers("Id", ""); attributeResource.setMappingAnnotation(JPA.ID); assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation); - assertSourceContains("@Id"); + assertSourceContains("@Id", cu); } public void testSetJavaAttributeMappingAnnotation2() throws Exception { - IType testType = createTestEntityWithColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntityWithColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertNull(attributeResource.getMappingAnnotation()); @@ -478,13 +480,13 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC attributeResource.setMappingAnnotation(JPA.ID); assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation); - assertSourceContains("@Id"); - assertSourceContains("@Column"); + assertSourceContains("@Id", cu); + assertSourceContains("@Column", cu); } public void testSetJavaAttributeMappingAnnotation3() throws Exception { - IType testType = createTestEntityWithIdColumnGeneratedValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntityWithIdColumnGeneratedValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation); @@ -492,61 +494,61 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC attributeResource.setMappingAnnotation(JPA.BASIC); assertTrue(attributeResource.getMappingAnnotation() instanceof BasicAnnotation); - assertSourceDoesNotContain("@Id"); - assertSourceContains("@GeneratedValue"); //not supported by Basic - assertSourceContains("@Column"); //common between Id and Basic + assertSourceDoesNotContain("@Id", cu); + assertSourceContains("@GeneratedValue", cu); //not supported by Basic + assertSourceContains("@Column", cu); //common between Id and Basic } public void testSetJavaAttributeMappingAnnotationNull() throws Exception { - IType testType = createTestEntityWithIdColumnGeneratedValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntityWithIdColumnGeneratedValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertTrue(attributeResource.getMappingAnnotation() instanceof IdAnnotation); attributeResource.setMappingAnnotation(null); assertNull(attributeResource.getMappingAnnotation()); - assertSourceDoesNotContain("@Id"); - assertSourceContains("@GeneratedValue"); //not supported by Basic - assertSourceContains("@Column"); //common between Id and Basic + assertSourceDoesNotContain("@Id", cu); + assertSourceContains("@GeneratedValue", cu); //not supported by Basic + assertSourceContains("@Column", cu); //common between Id and Basic } public void testAddJavaAttributeAnnotation() throws Exception { - IType testType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); attributeResource.addAnnotation(JPA.COLUMN); - assertSourceContains("@Column"); + assertSourceContains("@Column", cu); } public void testRemoveJavaAttributeAnnotation() throws Exception { - IType testType = createTestEntityAnnotatedField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntityAnnotatedField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); - assertSourceContains("@Column"); + assertSourceContains("@Column", cu); attributeResource.removeAnnotation(JPA.COLUMN); - assertSourceDoesNotContain("@Column"); + assertSourceDoesNotContain("@Column", cu); } //update source code to change from @Id to @OneToOne and make sure @Column is not removed public void testChangeAttributeMappingInSource() throws Exception { - IType jdtType = createTestEntityAnnotatedField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); final JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); - idField().edit(new Editor() { + idField(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { ((IdImpl) attributeResource.getMappingAnnotation()).getDeclarationAnnotationAdapter().removeAnnotation(declaration); } }); this.createAnnotationAndMembers("OneToOne", ""); - jdtType.getCompilationUnit().createImport("javax.persistence.OneToOne", null, new NullProgressMonitor()); + cu.createImport("javax.persistence.OneToOne", null, new NullProgressMonitor()); - idField().edit(new Editor() { + idField(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { OneToOneImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); } @@ -555,12 +557,12 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC assertNotNull(attributeResource.getAnnotation(JPA.COLUMN)); assertNull(attributeResource.getMappingAnnotation(JPA.ID)); assertNotNull(attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE)); - assertSourceContains("@Column"); + assertSourceContains("@Column", cu); } public void testJavaAttributeAnnotationsNestable() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(1, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES))); @@ -571,24 +573,24 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } public void testJavaAttributeAnnotationsNoNestable() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(0, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES))); } public void testJavaAttributeAnnotationsContainerNoNestable() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverridesEmpty(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverridesEmpty(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertEquals(0, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES))); } public void testJavaAttributeAnnotationsNestableAndContainer() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES)); @@ -600,25 +602,25 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC // -->> @AttributeOverride(name="FOO") public void testAddJavaAttributeAnnotationNestableContainer() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("FOO"); - assertSourceContains("@AttributeOverride(name=\"FOO\")"); + assertSourceContains("@AttributeOverride(name=\"FOO\")", cu); } // @Embedded -->> @Embedded // @AttributeOverride(name="FOO") @AttributeOverrides({@AttributeOverride(name="FOO"), @AttributeOverride(name="BAR")}) public void testAddJavaAttributeAnnotationNestableContainer2() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverride(); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverride(); this.createAnnotationAndMembers("AttributeOverrides", "String name();"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})", cu); assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES)); @@ -632,13 +634,13 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC // @Embedded // @AttributeOverrides({@AttributeOverride(name="FOO"), @AttributeOverride(name="BAR")}) public void testAddJavaAttributeAnnotationNestableContainer3() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"),@AttributeOverride(name=\"BAR\")})", cu); assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES)); @@ -646,13 +648,13 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } public void testAddJavaAttributeAnnotationNestableContainer5() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); attributeOverride.setName("BAR"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"),@AttributeOverride(name=\"FOO\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"),@AttributeOverride(name=\"FOO\")})", cu); assertNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDES)); @@ -668,8 +670,8 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC // @AttributeOverride(name=\"FOO\") // @AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"), @AttributeOverride(name=\"BOO\")}) public void testAddJavaAttributeAnnotationNestableContainer4() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverrideAndAttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); @@ -677,8 +679,8 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES))); AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),"); - assertSourceContains("@AttributeOverride})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),", cu); + assertSourceContains("@AttributeOverride})", cu); attributeOverride.setName("BOO"); assertNotNull(attributeResource.getAnnotation(JPA.ATTRIBUTE_OVERRIDE)); @@ -693,128 +695,130 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC attributeOverride = (AttributeOverrideAnnotation) attributeOverrideAnnotations.next(); assertEquals("BOO", attributeOverride.getName()); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),"); - assertSourceContains("@AttributeOverride(name=\"BOO\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"BAZ\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BOO\")})", cu); } //@Entity //@AttributeOverride(name="FOO") public void testRemoveJavaAttributeAnnotationNestableContainer() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverride(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverride(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); - assertSourceDoesNotContain("@AttributeOverride"); + assertSourceDoesNotContain("@AttributeOverride", cu); } //@Entity //@SecondaryTables(@SecondaryTable(name="FOO")) public void testRemoveJavaAttributeAnnotationNestableContainer2() throws Exception { - IType jdtType = createTestEmbeddedWithAttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWithAttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); - assertSourceDoesNotContain("@AttributeOverride"); - assertSourceDoesNotContain("@AttributeOverrides"); + assertSourceDoesNotContain("@AttributeOverride", cu); + assertSourceDoesNotContain("@AttributeOverrides", cu); } public void testRemoveJavaAttributeAnnotationIndex() throws Exception { - IType jdtType = createTestEmbeddedWith2AttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWith2AttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE , JPA.ATTRIBUTE_OVERRIDES); - assertSourceDoesNotContain("@AttributeOverride(name=\"FOO\""); - assertSourceContains("@AttributeOverride(name=\"BAR\""); - assertSourceDoesNotContain("@AttributeOverrides"); + assertSourceDoesNotContain("@AttributeOverride(name=\"FOO\"", cu); + assertSourceContains("@AttributeOverride(name=\"BAR\"", cu); + assertSourceDoesNotContain("@AttributeOverrides", cu); } public void testRemoveJavaAttributeAnnotationIndex2() throws Exception { - IType jdtType = createTestEmbeddedWith2AttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWith2AttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation)attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); newAnnotation.setName("BAZ"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),"); - assertSourceContains("@AttributeOverride(name=\"BAZ\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BAZ\")})", cu); attributeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAZ\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAZ\")})", cu); } public void testMoveJavaTypeAnnotation() throws Exception { - IType jdtType = createTestEmbeddedWith2AttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWith2AttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation)attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); newAnnotation.setName("BAZ"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),"); - assertSourceContains("@AttributeOverride(name=\"BAZ\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BAZ\")})", cu); attributeResource.move(0, 2, JPA.ATTRIBUTE_OVERRIDES); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"), @AttributeOverride(name=\"FOO\"),"); - assertSourceContains("@AttributeOverride(name=\"BAR\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAZ\"), @AttributeOverride(name=\"FOO\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BAR\")})", cu); } public void testMoveJavaTypeAnnotation2() throws Exception { - IType jdtType = createTestEmbeddedWith2AttributeOverrides(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEmbeddedWith2AttributeOverrides(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); AttributeOverrideAnnotation newAnnotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(2, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES); newAnnotation.setName("BAZ"); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),"); - assertSourceContains("@AttributeOverride(name=\"BAZ\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"FOO\"), @AttributeOverride(name=\"BAR\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BAZ\")})", cu); attributeResource.move(1, 0, JPA.ATTRIBUTE_OVERRIDES); - assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"FOO\"),"); - assertSourceContains("@AttributeOverride(name=\"BAZ\")})"); + assertSourceContains("@AttributeOverrides({@AttributeOverride(name=\"BAR\"), @AttributeOverride(name=\"FOO\"),", cu); + assertSourceContains("@AttributeOverride(name=\"BAZ\")})", cu); } //more detailed tests in JPTToolsTests public void testIsPersistableField() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); assertTrue(attributeResource.isPersistable()); } public void testIsPersistableField2() throws Exception { - IType jdtType = createTestEntityWithNonResolvingField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); - Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes"); - JavaResourcePersistentAttribute attributeResource = attributes.iterator().next(); + ICompilationUnit cu = createTestEntityWithNonResolvingField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + @SuppressWarnings("unchecked") + List<JavaResourcePersistentAttribute> attributes = (List<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "fields"); + JavaResourcePersistentAttribute attributeResource = attributes.get(0); assertEquals("foo", attributeResource.getName()); assertTrue(attributeResource.isForField()); assertTrue(attributeResource.isPersistable()); //bug 196200 changed this - this.javaProject.createType("test", "Foo.java", "public class Foo {}"); + this.javaProject.createCompilationUnit("test", "Foo.java", "public class Foo {}"); this.javaResourceModel.resolveTypes(); assertTrue(attributeResource.isPersistable()); } public void testGetQualifiedTypeName() throws Exception { - IType jdtType = createTestEntityWithNonResolvingField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); - Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes"); - JavaResourcePersistentAttribute attributeResource = attributes.iterator().next(); + ICompilationUnit cu = createTestEntityWithNonResolvingField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + @SuppressWarnings("unchecked") + List<JavaResourcePersistentAttribute> attributes = (List<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "fields"); + JavaResourcePersistentAttribute attributeResource = attributes.get(0); assertEquals("foo", attributeResource.getName()); assertEquals("test.Foo", attributeResource.getQualifiedTypeName()); //bug 196200 changed this - this.javaProject.createType("test", "Foo.java", "public class Foo {}"); + this.javaProject.createCompilationUnit("test", "Foo.java", "public class Foo {}"); this.javaResourceModel.resolveTypes(); assertEquals("test.Foo", attributeResource.getQualifiedTypeName()); @@ -823,24 +827,25 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC //more detailed tests in JPTToolsTests public void testIsPersistableMethod() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.properties().next(); assertTrue(attributeResource.isPersistable()); } public void testIsPersistableMethod2() throws Exception { - IType jdtType = createTestEntityWithNonResolvingMethod(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); - Collection<JavaResourcePersistentAttribute> attributes = (Collection<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "attributes"); - JavaResourcePersistentAttribute attributeResource = (JavaResourcePersistentAttribute) attributes.toArray()[3]; + ICompilationUnit cu = createTestEntityWithNonResolvingMethod(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + @SuppressWarnings("unchecked") + List<JavaResourcePersistentAttribute> attributes = (List<JavaResourcePersistentAttribute>) ClassTools.fieldValue(typeResource, "methods"); + JavaResourcePersistentAttribute attributeResource = attributes.get(0); assertEquals("foo", attributeResource.getName()); assertTrue(attributeResource.isForProperty()); assertTrue(attributeResource.isPersistable());//bug 196200 changed this - this.javaProject.createType("test", "Foo.java", "public class Foo {}"); + this.javaProject.createCompilationUnit("test", "Foo.java", "public class Foo {}"); this.javaResourceModel.resolveTypes(); assertTrue(attributeResource.isPersistable()); @@ -850,8 +855,8 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC //The annotations should apply to all fields defined. This is not really a useful //thing to do with JPA beyond the most basic things that use default column names public void testMultipleVariableDeclarationsPerLine() throws Exception { - IType jdtType = createTestEntityMultipleVariableDeclarationsPerLine(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityMultipleVariableDeclarationsPerLine(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(4, CollectionTools.size(typeResource.fields())); Iterator<JavaResourcePersistentAttribute> fields = typeResource.fields(); @@ -865,32 +870,32 @@ public class JavaResourcePersistentAttributeTests extends JavaResourceModelTestC } public void testIsPublic() throws Exception { - IType jdtType = createTestTypePublicAttribute(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestTypePublicAttribute(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attribute = typeResource.attributes().next(); assertTrue(attribute.isPublic()); } public void testIsPublicFalse() throws Exception { - IType jdtType = createTestTypePackageAttribute(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestTypePackageAttribute(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attribute = typeResource.attributes().next(); assertFalse(attribute.isPublic()); } public void testIsFinal() throws Exception { - IType jdtType = createTestTypeFinalAttribute(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestTypeFinalAttribute(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attribute = typeResource.attributes().next(); assertTrue(attribute.isFinal()); } public void testIsFinalFalse() throws Exception { - IType jdtType = createTestTypePackageAttribute(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestTypePackageAttribute(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attribute = typeResource.attributes().next(); assertFalse(attribute.isFinal()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java index d45678d60c..ac64ff8f55 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java @@ -12,7 +12,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.internal.resource.java.EmbeddableImpl; import org.eclipse.jpt.core.internal.resource.java.EntityImpl; import org.eclipse.jpt.core.resource.java.AccessType; @@ -58,7 +58,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -73,7 +73,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestInvalidAnnotations() throws Exception { + private ICompilationUnit createTestInvalidAnnotations() throws Exception { this.createAnnotationAndMembers("Foo", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -93,7 +93,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithMemberEmbeddable() throws Exception { + private ICompilationUnit createTestEntityWithMemberEmbeddable() throws Exception { createEntityAnnotation(); createEmbeddableAnnotation(); @@ -117,7 +117,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityDuplicates() throws Exception { + private ICompilationUnit createTestEntityDuplicates() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -133,7 +133,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithEmbeddable() throws Exception { + private ICompilationUnit createTestEntityWithEmbeddable() throws Exception { createEntityAnnotation(); createEmbeddableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -150,7 +150,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityAnnotatedField() throws Exception { + private ICompilationUnit createTestEntityAnnotatedField() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -171,7 +171,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityAnnotatedMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -191,7 +191,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } }); } - private IType createTestEntityAnnotatedFieldAndMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedFieldAndMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -217,7 +217,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityAnnotatedNonPersistableMethod() throws Exception { + private ICompilationUnit createTestEntityAnnotatedNonPersistableMethod() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); @@ -237,7 +237,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityAnnotatedPersistableMethodNonPersistableField() throws Exception { + private ICompilationUnit createTestEntityAnnotatedPersistableMethodNonPersistableField() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Id", ""); this.createAnnotationAndMembers("Column", ""); @@ -265,7 +265,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } }); } - private IType createTestEntityNoPersistableFields() throws Exception { + private ICompilationUnit createTestEntityNoPersistableFields() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -285,7 +285,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } -// private IType createTestEntityLarge(final int i) throws Exception { +// private ICompilationUnit createTestEntityLarge(final int i) throws Exception { // return this.createTestType(new DefaultAnnotationWriter() { // @Override // public Iterator<String> imports() { @@ -308,14 +308,14 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { // this.createAnnotationAndMembers("Entity" +i, "String name();"); // } // -// List<IType> testTypes = new ArrayList<IType>(); +// List<ICompilationUnit> cus = new ArrayList<ICompilationUnit>(); // for (int i = START; i <= END; i++) { -// testTypes.add(createTestEntityLarge(i)); +// cus.add(createTestEntityLarge(i)); // } // long start = System.currentTimeMillis(); // List<JavaPersistentTypeResource> typeResources = new ArrayList<JavaPersistentTypeResource>(); // for (int i = 0; i < END; i++) { -// typeResources.add(buildJavaTypeResource(testTypes.get(i))); +// typeResources.add(buildJavaTypeResource(cus.get(i))); // } // long end = System.currentTimeMillis(); // @@ -331,7 +331,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { - private IType createTestEntityWithTable() throws Exception { + private ICompilationUnit createTestEntityWithTable() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Table", "String name(); String schema();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -348,28 +348,28 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithTableAndIdClass() throws Exception { - createEntityAnnotation(); - this.createAnnotationAndMembers("Table", "String name(); String schema();"); - this.createAnnotationAndMembers("IdClass", "Class value();"); - return this.createTestType(new DefaultAnnotationWriter() { - @Override - public Iterator<String> imports() { - return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE, JPA.ID_CLASS); - } - @Override - public void appendTypeAnnotationTo(StringBuilder sb) { - sb.append("@Entity"); - sb.append(CR); - sb.append("@Table"); - sb.append(CR); - sb.append("@IdClass"); - } - }); - } - +// private ICompilationUnit createTestEntityWithTableAndIdClass() throws Exception { +// createEntityAnnotation(); +// this.createAnnotationAndMembers("Table", "String name(); String schema();"); +// this.createAnnotationAndMembers("IdClass", "Class value();"); +// return this.createTestType(new DefaultAnnotationWriter() { +// @Override +// public Iterator<String> imports() { +// return new ArrayIterator<String>(JPA.ENTITY, JPA.TABLE, JPA.ID_CLASS); +// } +// @Override +// public void appendTypeAnnotationTo(StringBuilder sb) { +// sb.append("@Entity"); +// sb.append(CR); +// sb.append("@Table"); +// sb.append(CR); +// sb.append("@IdClass"); +// } +// }); +// } +// - private IType createTestEntityMultipleTables() throws Exception { + private ICompilationUnit createTestEntityMultipleTables() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("Table", "String name(); String schema();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -388,7 +388,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithSecondaryTable() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTable() throws Exception { createEntityAnnotation(); createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -404,7 +404,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } }); } - private IType createTestEntityWithEmptySecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWithEmptySecondaryTables() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("SecondaryTable", "String name();"); this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();"); @@ -422,7 +422,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithSecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTables() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("SecondaryTable", "String name();"); this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();"); @@ -440,7 +440,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWith2SecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWith2SecondaryTables() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("SecondaryTable", "String name();"); this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();"); @@ -458,7 +458,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithSecondaryTableAndSecondaryTables() throws Exception { + private ICompilationUnit createTestEntityWithSecondaryTableAndSecondaryTables() throws Exception { createEntityAnnotation(); this.createAnnotationAndMembers("SecondaryTable", "String name();"); this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value();"); @@ -478,7 +478,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { }); } - private IType createTestEntityWithMemberTypes() throws Exception { + private ICompilationUnit createTestEntityWithMemberTypes() throws Exception { createEntityAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -504,58 +504,58 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } public void testJavaTypeAnnotations() throws Exception { - IType testType = this.createTestEntityWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(1, typeResource.annotationsSize()); } public void testJavaTypeAnnotation() throws Exception { - IType testType = this.createTestEntityWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertNotNull(typeResource.getAnnotation(JPA.TABLE)); } public void testJavaTypeAnnotationNull() throws Exception { - IType testType = this.createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertNull(typeResource.getAnnotation(JPA.TABLE)); } //This will result in a compilation error, but we assume the first table found public void testDuplicateAnnotations() throws Exception { - IType testType = this.createTestEntityMultipleTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityMultipleTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals("FOO", tableResource.getName()); } public void testRemoveTable() throws Exception { - IType testType = this.createTestEntityWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); typeResource.removeAnnotation(JPA.TABLE); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testRemoveTableName() throws Exception { - IType testType = this.createTestEntityWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation tableResource = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); tableResource.setSchema(null); - assertSourceContains("@Table(name=\"FOO\")"); + assertSourceContains("@Table(name=\"FOO\")", cu); tableResource.setName(null); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); assertNull(typeResource.getAnnotation(JPA.TABLE)); } public void testMultipleTypeMappings() throws Exception { - IType testType = this.createTestEntityWithEmbeddable(); + ICompilationUnit cu = this.createTestEntityWithEmbeddable(); createMappedSuperclassAnnotation(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(2, typeResource.mappingAnnotationsSize()); assertEquals(0, typeResource.annotationsSize()); @@ -564,75 +564,75 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { JavaResourceNode javaTypeMappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(javaTypeMappingAnnotation instanceof EmbeddableAnnotation); - assertSourceContains("@Entity"); - assertSourceContains("@Embeddable"); + assertSourceContains("@Entity", cu); + assertSourceContains("@Embeddable", cu); typeResource.setMappingAnnotation(JPA.MAPPED_SUPERCLASS); assertEquals(1, typeResource.mappingAnnotationsSize()); javaTypeMappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(javaTypeMappingAnnotation instanceof MappedSuperclassAnnotation); - assertSourceDoesNotContain("@Entity"); - assertSourceContains("@MappedSuperclass"); - assertSourceDoesNotContain("@Embeddable"); + assertSourceDoesNotContain("@Entity", cu); + assertSourceContains("@MappedSuperclass", cu); + assertSourceDoesNotContain("@Embeddable", cu); } public void testSetJavaTypeMappingAnnotation() throws Exception { createEntityAnnotation(); - IType testType = createTestType(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestType(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(0, typeResource.mappingAnnotationsSize()); typeResource.setMappingAnnotation(JPA.ENTITY); assertTrue(typeResource.getMappingAnnotation() instanceof EntityAnnotation); - assertSourceContains("@Entity"); + assertSourceContains("@Entity", cu); } public void testSetJavaTypeMappingAnnotation2() throws Exception { - IType testType = createTestEntityWithTable(); + ICompilationUnit cu = createTestEntityWithTable(); createEmbeddableAnnotation(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertTrue(typeResource.getMappingAnnotation() instanceof EntityAnnotation); typeResource.setMappingAnnotation(JPA.EMBEDDABLE); assertTrue(typeResource.getMappingAnnotation() instanceof EmbeddableAnnotation); - assertSourceDoesNotContain("@Entity"); - assertSourceContains("@Table"); + assertSourceDoesNotContain("@Entity", cu); + assertSourceContains("@Table", cu); } public void testAddJavaTypeAnnotation() throws Exception { - IType testType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); typeResource.addAnnotation(JPA.TABLE); - assertSourceContains("@Table"); + assertSourceContains("@Table", cu); } public void testRemoveJavaTypeAnnotation() throws Exception { - IType testType = createTestEntityWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); - assertSourceContains("@Table"); + ICompilationUnit cu = createTestEntityWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + assertSourceContains("@Table", cu); typeResource.removeAnnotation(JPA.TABLE); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } //update source code to change from @Entity to @Embeddable and make sure @Table is not removed public void testChangeTypeMappingInSource() throws Exception { - IType jdtType = createTestEntityWithTable(); - final JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithTable(); + final JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); - testType().edit(new Editor() { + testType(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { ((EntityImpl) typeResource.getMappingAnnotation()).getDeclarationAnnotationAdapter().removeAnnotation(declaration); } }); this.createAnnotationAndMembers("Embeddable", "String name();"); - jdtType.getCompilationUnit().createImport("javax.persistence.Embeddable", null, new NullProgressMonitor()); + cu.createImport("javax.persistence.Embeddable", null, new NullProgressMonitor()); - testType().edit(new Editor() { + this.testType(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { EmbeddableImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); } @@ -641,12 +641,12 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { assertNotNull(typeResource.getAnnotation(JPA.TABLE)); assertNull(typeResource.getMappingAnnotation(JPA.ENTITY)); assertNotNull(typeResource.getMappingAnnotation(JPA.EMBEDDABLE)); - assertSourceContains("@Table"); + assertSourceContains("@Table", cu); } public void testJavaTypeAnnotationsNestable() throws Exception { - IType jdtType = createTestEntityWithSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(1, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES))); @@ -656,22 +656,22 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } public void testJavaTypeAnnotationsNoNestable() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(0, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES))); } public void testJavaTypeAnnotationsContainerNoNestable() throws Exception { - IType jdtType = createTestEntityWithEmptySecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithEmptySecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(0, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES))); } public void testJavaTypeAnnotationsNestableAndContainer() throws Exception { - IType jdtType = createTestEntityWithSecondaryTableAndSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTableAndSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -684,23 +684,23 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { // @Entity -->> @Entity // @SecondaryTable(name="FOO") public void testAddJavaTypeAnnotationNestableContainer() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("FOO"); - assertSourceContains("@SecondaryTable(name=\"FOO\")"); + assertSourceContains("@SecondaryTable(name=\"FOO\")", cu); } // @Entity -->> @Entity // @SecondaryTable(name="FOO") @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")}) public void testAddJavaTypeAnnotationNestableContainer2() throws Exception { - IType jdtType = createTestEntityWithSecondaryTable(); + ICompilationUnit cu = createTestEntityWithSecondaryTable(); createSecondaryTablesAnnotation(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -714,12 +714,12 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { // @Entity // @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")}) public void testAddJavaTypeAnnotationNestableContainer3() throws Exception { - IType jdtType = createTestEntityWithSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"),@SecondaryTable(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -727,12 +727,12 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } public void testAddJavaTypeAnnotationNestableContainer5() throws Exception { - IType jdtType = createTestEntityWithSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})", cu); assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -740,12 +740,12 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } public void testAddJavaTypeAnnotationNestableContainer6() throws Exception { - IType jdtType = createTestEntityWithSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"),@SecondaryTable(name=\"FOO\")})", cu); assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -753,7 +753,7 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTableResource.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"FOO\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"FOO\")})", cu); assertEquals(3, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES))); } @@ -767,15 +767,15 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { // @SecondaryTable(name=\"FOO\") // @SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"BOO\")}) public void testAddJavaTypeAnnotationNestableContainer4() throws Exception { - IType jdtType = createTestEntityWithSecondaryTableAndSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTableAndSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); assertEquals(2, CollectionTools.size(typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES))); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable})", cu); secondaryTableResource.setName("BOO"); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); @@ -790,95 +790,96 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { secondaryTableResource = (SecondaryTableAnnotation) secondaryTableAnnotations.next(); assertEquals("BOO", secondaryTableResource.getName()); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"BOO\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"BOO\")})", cu); } //@Entity //@SecondaryTable(name="FOO") public void testRemoveJavaTypeAnnotationNestableContainer() throws Exception { - IType jdtType = createTestEntityWithSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } //@Entity //@SecondaryTables(@SecondaryTable(name="FOO")) public void testRemoveJavaTypeAnnotationNestableContainer2() throws Exception { - IType jdtType = createTestEntityWithSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceDoesNotContain("@SecondaryTable"); - assertSourceDoesNotContain("@SecondaryTables"); + assertSourceDoesNotContain("@SecondaryTable", cu); + assertSourceDoesNotContain("@SecondaryTables", cu); } public void testRemoveJavaTypeAnnotationIndex() throws Exception { - IType jdtType = createTestEntityWith2SecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWith2SecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); typeResource.removeAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceDoesNotContain("@SecondaryTable(name=\"FOO\""); - assertSourceContains("@SecondaryTable(name=\"BAR\""); - assertSourceDoesNotContain("@SecondaryTables"); + assertSourceDoesNotContain("@SecondaryTable(name=\"FOO\"", cu); + assertSourceContains("@SecondaryTable(name=\"BAR\"", cu); + assertSourceDoesNotContain("@SecondaryTables", cu); } public void testRemoveJavaTypeAnnotationIndex2() throws Exception { - IType jdtType = createTestEntityWith2SecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWith2SecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); newAnnotation.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ", cu); typeResource.removeAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAZ\")})", cu); } public void testMoveJavaTypeAnnotation() throws Exception { - IType jdtType = createTestEntityWith2SecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWith2SecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); newAnnotation.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})", cu); typeResource.move(0, 2, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\")})", cu); } public void testMoveJavaTypeAnnotation2() throws Exception { - IType jdtType = createTestEntityWith2SecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWith2SecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation newAnnotation = (SecondaryTableAnnotation)typeResource.addAnnotation(2, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); newAnnotation.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\"), @SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\")})", cu); typeResource.move(2, 0, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAR\"), @SecondaryTable(name=\"BAZ\"), @SecondaryTable(name=\"FOO\")})", cu); } public void testNestedTypes() throws Exception { - IType jdtType = createTestEntityWithMemberTypes(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityWithMemberTypes(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals("only persistable types should be returned by nestedTypes()", 1, CollectionTools.size(persistentType.nestedTypes())); + @SuppressWarnings("unchecked") List<JavaResourcePersistentType> nestedTypes = (List<JavaResourcePersistentType>) ClassTools.fieldValue(persistentType, "nestedTypes"); - assertEquals(4, CollectionTools.size(nestedTypes)); + assertEquals("enums and interfaces should be ignored", 2, CollectionTools.size(nestedTypes)); } public void testDuplicateEntityAnnotations() throws Exception { - IType jdtType = createTestEntityDuplicates(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityDuplicates(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); EntityAnnotation javaTypeMappingAnnotation = (EntityAnnotation) persistentType.getMappingAnnotation(JPA.ENTITY); assertEquals("FirstEntity", javaTypeMappingAnnotation.getName()); @@ -892,62 +893,62 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { public void testAttributes() throws Exception { - + // TODO } public void testFields() throws Exception { - + // TODO } public void testProperties() throws Exception { - + // TODO } public void testGetAccessNoAttributesAnnotated() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertNull(persistentType.getAccess()); } public void testGetAccessFieldsAnnotated() throws Exception { - IType jdtType = createTestEntityAnnotatedField(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedField(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals(AccessType.FIELD, persistentType.getAccess()); } public void testGetAccessMethodsAnnotated() throws Exception { - IType jdtType = createTestEntityAnnotatedMethod(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedMethod(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals(AccessType.PROPERTY, persistentType.getAccess()); } public void testGetAccessFieldsAndMethodsAnnotated() throws Exception { - IType jdtType = createTestEntityAnnotatedFieldAndMethod(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedFieldAndMethod(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals(AccessType.FIELD, persistentType.getAccess()); } public void testGetAccessNonPersistableMethodAnnotated() throws Exception { - IType jdtType = createTestEntityAnnotatedNonPersistableMethod(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedNonPersistableMethod(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertNull(persistentType.getAccess()); } public void testGetAccessPersistableMethodAndNonPersistableFieldAnnotated() throws Exception { - IType jdtType = createTestEntityAnnotatedPersistableMethodNonPersistableField(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityAnnotatedPersistableMethodNonPersistableField(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals(AccessType.PROPERTY, persistentType.getAccess()); } public void testGetAccessNoPersistableFieldsAnnotated() throws Exception { - IType jdtType = createTestEntityNoPersistableFields(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntityNoPersistableFields(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals(AccessType.PROPERTY, persistentType.getAccess()); } @@ -958,8 +959,8 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { //3. What about a superclass that is a class file in a jar?? //4. public void testGetSuperclassQualifiedName() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertEquals("java.lang.Object", persistentType.getSuperClassQualifiedName()); @@ -967,15 +968,15 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { //more detailed tests in JPTToolsTests public void testIsPersistable() throws Exception { - IType jdtType = createTestEntity(); - JavaResourcePersistentType persistentType = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestEntity(); + JavaResourcePersistentType persistentType = buildJavaTypeResource(cu); assertTrue(persistentType.isPersistable()); } public void testAnnotatedMemberType() throws Exception { - IType testType = this.createTestEntityWithMemberEmbeddable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestEntityWithMemberEmbeddable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertNotNull(typeResource.getMappingAnnotation(JPA.ENTITY)); assertNull(typeResource.getMappingAnnotation(JPA.EMBEDDABLE)); @@ -985,8 +986,8 @@ public class JavaResourcePersistentTypeTests extends JavaResourceModelTestCase { } public void testInvalidAnnotations() throws Exception { - IType testType = this.createTestInvalidAnnotations(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestInvalidAnnotations(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); assertEquals(0, typeResource.mappingAnnotationsSize()); assertEquals(0, typeResource.annotationsSize()); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java index 719063b65d..1f4a193f60 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -40,7 +40,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { "String table() default \"\"; "); } - private IType createTestJoinColumn() throws Exception { + private ICompilationUnit createTestJoinColumn() throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -54,7 +54,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithName() throws Exception { + private ICompilationUnit createTestJoinColumnWithName() throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithTable() throws Exception { + private ICompilationUnit createTestJoinColumnWithTable() throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithReferencedColumnName() throws Exception { + private ICompilationUnit createTestJoinColumnWithReferencedColumnName() throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -96,7 +96,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestJoinColumnWithColumnDefinition() throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -110,7 +110,7 @@ public class JoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception { + private ICompilationUnit createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception { createJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -125,8 +125,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); assertNotNull(column); @@ -134,8 +134,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); assertNotNull(column); @@ -150,8 +150,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -161,12 +161,12 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@JoinColumn(name=\"Foo\")"); + assertSourceContains("@JoinColumn(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -175,20 +175,20 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetTable() throws Exception { - IType testType = this.createTestJoinColumnWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); assertEquals(COLUMN_TABLE, column.getTable()); } public void testSetTable() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -198,24 +198,24 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setTable("Foo"); assertEquals("Foo", column.getTable()); - assertSourceContains("@JoinColumn(table=\"Foo\")"); + assertSourceContains("@JoinColumn(table=\"Foo\")", cu); column.setTable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetReferencedColumnName() throws Exception { - IType testType = this.createTestJoinColumnWithReferencedColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithReferencedColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName()); } public void testSetReferencedColumnName() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -225,24 +225,24 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setReferencedColumnName("Foo"); assertEquals("Foo", column.getReferencedColumnName()); - assertSourceContains("@JoinColumn(referencedColumnName=\"Foo\")"); + assertSourceContains("@JoinColumn(referencedColumnName=\"Foo\")", cu); column.setReferencedColumnName(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestJoinColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -252,16 +252,16 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@JoinColumn(columnDefinition=\"Foo\")"); + assertSourceContains("@JoinColumn(columnDefinition=\"Foo\")", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetUnique() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("unique"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("unique"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -269,8 +269,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testSetUnique() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -280,15 +280,15 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setUnique(false); assertFalse(column.getUnique()); - assertSourceContains("@JoinColumn(unique=false)"); + assertSourceContains("@JoinColumn(unique=false)", cu); column.setUnique(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetNullable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("nullable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("nullable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -296,8 +296,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testSetNullable() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -307,15 +307,15 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setNullable(false); assertFalse(column.getNullable()); - assertSourceContains("@JoinColumn(nullable=false)"); + assertSourceContains("@JoinColumn(nullable=false)", cu); column.setNullable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetInsertable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("insertable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("insertable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -323,8 +323,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testSetInsertable() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -334,15 +334,15 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setInsertable(false); assertFalse(column.getInsertable()); - assertSourceContains("@JoinColumn(insertable=false)"); + assertSourceContains("@JoinColumn(insertable=false)", cu); column.setInsertable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetUpdatable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("updatable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("updatable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -350,8 +350,8 @@ public class JoinColumnTests extends JavaResourceModelTestCase { } public void testSetUpdatable() throws Exception { - IType testType = this.createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.getAnnotation(JPA.JOIN_COLUMN); @@ -361,9 +361,9 @@ public class JoinColumnTests extends JavaResourceModelTestCase { column.setUpdatable(false); assertFalse(column.getUpdatable()); - assertSourceContains("@JoinColumn(updatable=false)"); + assertSourceContains("@JoinColumn(updatable=false)", cu); column.setUpdatable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java index bed670dde7..e7c734357b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinColumnsTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -48,7 +48,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { "JoinColumn[] value();"); } - private IType createTestJoinColumns() throws Exception { + private ICompilationUnit createTestJoinColumns() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -62,7 +62,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithName() throws Exception { + private ICompilationUnit createTestJoinColumnWithName() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -76,7 +76,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithTable() throws Exception { + private ICompilationUnit createTestJoinColumnWithTable() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -90,7 +90,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithReferencedColumnName() throws Exception { + private ICompilationUnit createTestJoinColumnWithReferencedColumnName() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -104,7 +104,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestJoinColumnWithColumnDefinition() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -118,7 +118,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception { + private ICompilationUnit createTestJoinColumnWithBooleanElement(final String booleanElement) throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -132,7 +132,7 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinColumn() throws Exception { + private ICompilationUnit createTestJoinColumn() throws Exception { createJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -147,8 +147,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); assertNotNull(column); @@ -156,8 +156,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); assertNotNull(column); @@ -171,8 +171,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -182,12 +182,12 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@JoinColumns(@JoinColumn(name=\"Foo\"))"); + assertSourceContains("@JoinColumns(@JoinColumn(name=\"Foo\"))", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -196,20 +196,20 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetTable() throws Exception { - IType testType = this.createTestJoinColumnWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); assertEquals(COLUMN_TABLE, column.getTable()); } public void testSetTable() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -219,24 +219,24 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setTable("Foo"); assertEquals("Foo", column.getTable()); - assertSourceContains("@JoinColumns(@JoinColumn(table=\"Foo\"))"); + assertSourceContains("@JoinColumns(@JoinColumn(table=\"Foo\"))", cu); column.setTable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetReferencedColumnName() throws Exception { - IType testType = this.createTestJoinColumnWithReferencedColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithReferencedColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName()); } public void testSetReferencedColumnName() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -246,24 +246,24 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setReferencedColumnName("Foo"); assertEquals("Foo", column.getReferencedColumnName()); - assertSourceContains("@JoinColumns(@JoinColumn(referencedColumnName=\"Foo\"))"); + assertSourceContains("@JoinColumns(@JoinColumn(referencedColumnName=\"Foo\"))", cu); column.setReferencedColumnName(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestJoinColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -273,16 +273,16 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@JoinColumns(@JoinColumn(columnDefinition=\"Foo\"))"); + assertSourceContains("@JoinColumns(@JoinColumn(columnDefinition=\"Foo\"))", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetUnique() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("unique"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("unique"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -290,8 +290,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testSetUnique() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -301,15 +301,15 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setUnique(false); assertFalse(column.getUnique()); - assertSourceContains("@JoinColumns(@JoinColumn(unique=false))"); + assertSourceContains("@JoinColumns(@JoinColumn(unique=false))", cu); column.setUnique(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetNullable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("nullable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("nullable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -317,8 +317,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testSetNullable() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -328,15 +328,15 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setNullable(false); assertFalse(column.getNullable()); - assertSourceContains("@JoinColumns(@JoinColumn(nullable=false))"); + assertSourceContains("@JoinColumns(@JoinColumn(nullable=false))", cu); column.setNullable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetInsertable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("insertable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("insertable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -344,8 +344,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testSetInsertable() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -355,15 +355,15 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setInsertable(false); assertFalse(column.getInsertable()); - assertSourceContains("@JoinColumns(@JoinColumn(insertable=false))"); + assertSourceContains("@JoinColumns(@JoinColumn(insertable=false))", cu); column.setInsertable(null); - assertSourceDoesNotContain("@JoinColumn"); + assertSourceDoesNotContain("@JoinColumn", cu); } public void testGetUpdatable() throws Exception { - IType testType = this.createTestJoinColumnWithBooleanElement("updatable"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumnWithBooleanElement("updatable"); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -371,8 +371,8 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testSetUpdatable() throws Exception { - IType testType = this.createTestJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation column = (JoinColumnAnnotation) attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS).next(); @@ -382,22 +382,22 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { column.setUpdatable(false); assertFalse(column.getUpdatable()); - assertSourceContains("@JoinColumns(@JoinColumn(updatable=false))"); + assertSourceContains("@JoinColumns(@JoinColumn(updatable=false))", cu); column.setUpdatable(null); - assertSourceDoesNotContain("@JoinColumn"); - assertSourceDoesNotContain("@JoinColumns"); + assertSourceDoesNotContain("@JoinColumn", cu); + assertSourceDoesNotContain("@JoinColumns", cu); } public void testAddJoinColumnCopyExisting() throws Exception { - IType jdtType = createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})", cu); assertNull(attributeResource.getAnnotation(JPA.JOIN_COLUMN)); assertNotNull(attributeResource.getAnnotation(JPA.JOIN_COLUMNS)); @@ -405,17 +405,17 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { } public void testAddJoinColumnToBeginningOfList() throws Exception { - IType jdtType = createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})", cu); joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("BAZ"); - assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAZ\"),@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"), @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAZ\"),@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"), @JoinColumn(name=\"FOO\")})", cu); Iterator<JavaResourceNode> joinColumns = attributeResource.annotations(JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); assertEquals("BAZ", ((JoinColumnAnnotation) joinColumns.next()).getName()); @@ -429,16 +429,16 @@ public class JoinColumnsTests extends JavaResourceModelTestCase { public void testRemoveJoinColumnCopyExisting() throws Exception { - IType jdtType = createTestJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinColumns({@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\"),@JoinColumn(name=\"FOO\")})", cu); attributeResource.removeAnnotation(1, JPA.JOIN_COLUMN, JPA.JOIN_COLUMNS); - assertSourceContains("@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\")"); + assertSourceContains("@JoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", table = \"TABLE\", unique = false, nullable = false, insertable = false, updatable = false, referencedColumnName = \"REF_NAME\")", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java index 9a0f97a5d8..6f7b41f8c1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JoinTableTests.java @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -51,7 +51,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { this.createAnnotationAndMembers("JoinTable", "String name() default \"\"; String catalog() default \"\"; String schema() default \"\";JoinColumn[] joinColumns() default {}; JoinColumn[] inverseJoinColumns() default {}; UniqueConstraint[] uniqueConstraints() default {};"); } - private IType createTestJoinTable() throws Exception { + private ICompilationUnit createTestJoinTable() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -65,7 +65,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithName() throws Exception { + private ICompilationUnit createTestJoinTableWithName() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -79,7 +79,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithSchema() throws Exception { + private ICompilationUnit createTestJoinTableWithSchema() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -94,7 +94,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithCatalog() throws Exception { + private ICompilationUnit createTestJoinTableWithCatalog() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -108,7 +108,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithUniqueConstraints() throws Exception { + private ICompilationUnit createTestJoinTableWithUniqueConstraints() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -122,7 +122,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithJoinColumns() throws Exception { + private ICompilationUnit createTestJoinTableWithJoinColumns() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -136,7 +136,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { }); } - private IType createTestJoinTableWithInverseJoinColumns() throws Exception { + private ICompilationUnit createTestJoinTableWithInverseJoinColumns() throws Exception { createJoinTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -151,8 +151,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestJoinTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -161,8 +161,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -173,8 +173,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -184,12 +184,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setName("Foo"); assertEquals("Foo", table.getName()); - assertSourceContains("@JoinTable(name=\"Foo\")"); + assertSourceContains("@JoinTable(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestJoinTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -198,12 +198,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setName(null); assertNull(table.getName()); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testGetCatalog() throws Exception { - IType testType = this.createTestJoinTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -212,8 +212,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testSetCatalog() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -223,12 +223,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setCatalog("Foo"); assertEquals("Foo", table.getCatalog()); - assertSourceContains("@JoinTable(catalog=\"Foo\")"); + assertSourceContains("@JoinTable(catalog=\"Foo\")", cu); } public void testSetCatalogNull() throws Exception { - IType testType = this.createTestJoinTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -237,12 +237,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setCatalog(null); assertNull(table.getCatalog()); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testGetSchema() throws Exception { - IType testType = this.createTestJoinTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -251,8 +251,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testSetSchema() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -262,12 +262,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setSchema("Foo"); assertEquals("Foo", table.getSchema()); - assertSourceContains("@JoinTable(schema=\"Foo\")"); + assertSourceContains("@JoinTable(schema=\"Foo\")", cu); } public void testSetSchemaNull() throws Exception { - IType testType = this.createTestJoinTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -276,12 +276,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.setSchema(null); assertNull(table.getSchema()); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testUniqueConstraints() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -290,8 +290,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testUniqueConstraints2() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -304,8 +304,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testUniqueConstraints3() throws Exception { - IType testType = this.createTestJoinTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -314,8 +314,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testAddUniqueConstraint() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -328,12 +328,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next()); assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize()); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})", cu); } public void testRemoveUniqueConstraint() throws Exception { - IType testType = this.createTestJoinTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -346,45 +346,45 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("BAR", table.uniqueConstraintAt(0).columnNames().next()); assertEquals("BAZ", table.uniqueConstraintAt(1).columnNames().next()); assertEquals(2, table.uniqueConstraintsSize()); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); table.removeUniqueConstraint(0); assertEquals("BAZ", table.uniqueConstraintAt(0).columnNames().next()); assertEquals(1, table.uniqueConstraintsSize()); - assertSourceContains("@JoinTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))"); + assertSourceContains("@JoinTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))", cu); table.removeUniqueConstraint(0); assertEquals(0, table.uniqueConstraintsSize()); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testMoveUniqueConstraint() throws Exception { - IType testType = this.createTestJoinTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); table.moveUniqueConstraint(2, 0); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})", cu); } public void testMoveUniqueConstraint2() throws Exception { - IType testType = this.createTestJoinTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); table.moveUniqueConstraint(0, 2); - assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})"); + assertSourceContains("@JoinTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})", cu); } public void testJoinColumns() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -393,8 +393,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testJoinColumns2() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -407,8 +407,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testJoinColumns3() throws Exception { - IType testType = this.createTestJoinTableWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -417,8 +417,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testAddJoinColumn() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -430,12 +430,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("BAR", table.joinColumnAt(0).getName()); assertEquals("FOO", table.joinColumnAt(1).getName()); assertNull(table.joinColumnAt(2).getName()); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})", cu); } public void testRemoveJoinColumn() throws Exception { - IType testType = this.createTestJoinTableWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -450,22 +450,22 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.joinColumnAt(0).getName()); assertNull(table.joinColumnAt(1).getName()); assertEquals(2, table.joinColumnsSize()); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn})", cu); table.removeJoinColumn(0); assertNull(table.joinColumnAt(0).getName()); assertEquals(1, table.joinColumnsSize()); - assertSourceContains("@JoinTable(joinColumns=@JoinColumn)"); + assertSourceContains("@JoinTable(joinColumns=@JoinColumn)", cu); table.removeJoinColumn(0); assertEquals(0, table.joinColumnsSize()); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testMoveJoinColumn() throws Exception { - IType testType = this.createTestJoinTableWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -479,19 +479,19 @@ public class JoinTableTests extends JavaResourceModelTestCase { joinColumn.setTable("TABLE"); table.addJoinColumn(0).setName("FOO"); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})", cu); table.moveJoinColumn(2, 0); assertEquals("BAR", table.joinColumnAt(0).getName()); assertNull(table.joinColumnAt(1).getName()); assertEquals("FOO", table.joinColumnAt(2).getName()); assertEquals(3, table.joinColumnsSize()); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn, @JoinColumn(name=\"FOO\")})", cu); } public void testMoveJoinColumn2() throws Exception { - IType testType = this.createTestJoinTableWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -507,7 +507,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { table.addJoinColumn(0).setName("FOO"); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\"), @JoinColumn})", cu); table.moveJoinColumn(0, 2); @@ -515,17 +515,16 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.joinColumnAt(1).getName()); assertEquals("BAR", table.joinColumnAt(2).getName()); assertEquals(3, table.joinColumnsSize()); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn, @JoinColumn(name=\"FOO\"), @JoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", unique = false, nullable = false, insertable = false, updatable = false, columnDefinition = \"COLUMN_DEF\", table = \"TABLE\")})", cu); } public void testSetJoinColumnName() throws Exception { - IType testType = this.createTestJoinTableWithJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); - ListIterator<JoinColumnAnnotation> iterator = table.joinColumns(); assertEquals(2, table.joinColumnsSize()); JoinColumnAnnotation joinColumn = table.joinColumns().next(); @@ -535,12 +534,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})"); + assertSourceContains("@JoinTable(joinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})", cu); } public void testInverseJoinColumns() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -549,8 +548,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testInverseJoinColumns2() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -563,8 +562,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testInverseJoinColumns3() throws Exception { - IType testType = this.createTestJoinTableWithInverseJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithInverseJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -573,8 +572,8 @@ public class JoinTableTests extends JavaResourceModelTestCase { } public void testAddInverseJoinColumn() throws Exception { - IType testType = this.createTestJoinTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -586,12 +585,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("BAR", table.inverseJoinColumnAt(0).getName()); assertEquals("FOO", table.inverseJoinColumnAt(1).getName()); assertNull(table.inverseJoinColumnAt(2).getName()); - assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})"); + assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"),@JoinColumn(name=\"FOO\"), @JoinColumn})", cu); } public void testRemoveInverseJoinColumn() throws Exception { - IType testType = this.createTestJoinTableWithInverseJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithInverseJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -604,25 +603,25 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertFalse(inverseJoinColumns.hasNext()); table.removeInverseJoinColumn(1); - assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})", cu); inverseJoinColumns = table.inverseJoinColumns(); assertEquals("BAR", inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); assertFalse(inverseJoinColumns.hasNext()); table.removeInverseJoinColumn(0); - assertSourceContains("@JoinTable(inverseJoinColumns=@JoinColumn(name=\"FOO\"))"); + assertSourceContains("@JoinTable(inverseJoinColumns=@JoinColumn(name=\"FOO\"))", cu); inverseJoinColumns = table.inverseJoinColumns(); assertEquals("FOO", inverseJoinColumns.next().getName()); assertFalse(inverseJoinColumns.hasNext()); table.removeInverseJoinColumn(0); - assertSourceDoesNotContain("@JoinTable"); + assertSourceDoesNotContain("@JoinTable", cu); } public void testMoveInverseJoinColumn() throws Exception { - IType testType = this.createTestJoinTableWithInverseJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithInverseJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -639,12 +638,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertNull(inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); - assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn, @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"BAR\"), @JoinColumn, @JoinColumn(name=\"FOO\")})", cu); } public void testMoveInverseJoinColumn2() throws Exception { - IType testType = this.createTestJoinTableWithInverseJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithInverseJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -661,12 +660,12 @@ public class JoinTableTests extends JavaResourceModelTestCase { assertEquals("BAR", inverseJoinColumns.next().getName()); assertEquals("FOO", inverseJoinColumns.next().getName()); - assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn, @JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})"); + assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn, @JoinColumn(name=\"BAR\"), @JoinColumn(name=\"FOO\")})", cu); } public void testSetInverseJoinColumnName() throws Exception { - IType testType = this.createTestJoinTableWithInverseJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestJoinTableWithInverseJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JoinTableAnnotation table = (JoinTableAnnotation) attributeResource.getAnnotation(JPA.JOIN_TABLE); @@ -680,7 +679,7 @@ public class JoinTableTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})"); + assertSourceContains("@JoinTable(inverseJoinColumns={@JoinColumn(name=\"foo\"), @JoinColumn})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java index 47a2633dd6..955fd27e8e 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JpaCompilationUnitTests.java @@ -13,7 +13,7 @@ import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.JpaFile; import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.resource.java.EntityAnnotation; @@ -37,15 +37,10 @@ public class JpaCompilationUnitTests extends AnnotationTestCase { } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("javax.persistence", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } - private ICompilationUnit createTestCompilationUnit() throws Exception { - IType type = createTestEntity(); - return type.getCompilationUnit(); - } - - private IType createTestEntity() throws Exception { + private ICompilationUnit createTestEntity() throws Exception { this.createAnnotationAndMembers("Entity", "String name();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -64,11 +59,11 @@ public class JpaCompilationUnitTests extends AnnotationTestCase { JpaProject jpaProject = ((TestJpaProject) this.javaProject).getJpaProject(); JpaFile jpaFile = jpaProject.getJpaFile((IFile) testCompilationUnit.getResource()); JavaResourceModel javaResourceModel = (JavaResourceModel) jpaFile.getResourceModel(); - return javaResourceModel.getResource(); + return javaResourceModel.getJpaCompilationUnit(); } public void testGetPersistentType() throws Exception { - ICompilationUnit compilationUnit = this.createTestCompilationUnit(); + ICompilationUnit compilationUnit = this.createTestEntity(); JpaCompilationUnit jpaCompilationUnit = getJpaCompilationUnitResource(compilationUnit); assertTrue(jpaCompilationUnit.getPersistentType().getMappingAnnotation() instanceof EntityAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java index 097c7f45f1..da2298d6aa 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/LobTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -23,7 +23,7 @@ public class LobTests extends JavaResourceModelTestCase { super(name); } - private IType createTestLob() throws Exception { + private ICompilationUnit createTestLob() throws Exception { this.createAnnotationAndMembers("Lob", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -38,8 +38,8 @@ public class LobTests extends JavaResourceModelTestCase { } public void testLob() throws Exception { - IType testType = this.createTestLob(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestLob(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); LobAnnotation lob = (LobAnnotation) attributeResource.getAnnotation(JPA.LOB); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java index b287e54e63..fd6b1a3c2a 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { super(name); } - private IType createTestManyToMany() throws Exception { + private ICompilationUnit createTestManyToMany() throws Exception { this.createAnnotationAndMembers("ManyToMany", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithFetch() throws Exception { + private ICompilationUnit createTestManyToManyWithFetch() throws Exception { this.createAnnotationAndMembers("ManyToMany", "FetchType fetch() default FetchType.LAZY;"); this.createEnumAndMembers("FetchType", "EAGER, LAZY"); return this.createTestType(new DefaultAnnotationWriter() { @@ -54,7 +54,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithTargetEntity() throws Exception { + private ICompilationUnit createTestManyToManyWithTargetEntity() throws Exception { this.createAnnotationAndMembers("ManyToMany", "Class targetEntity() default void.class; "); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithMappedBy() throws Exception { + private ICompilationUnit createTestManyToManyWithMappedBy() throws Exception { this.createAnnotationAndMembers("ManyToMany", "String mappedBy() default\"\";"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -83,7 +83,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithCascade() throws Exception { + private ICompilationUnit createTestManyToManyWithCascade() throws Exception { this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -98,7 +98,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithMultipleCascade() throws Exception { + private ICompilationUnit createTestManyToManyWithMultipleCascade() throws Exception { this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -113,7 +113,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToManyWithDuplicateCascade() throws Exception { + private ICompilationUnit createTestManyToManyWithDuplicateCascade() throws Exception { this.createAnnotationAndMembers("ManyToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -129,8 +129,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testManyToMany() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -138,8 +138,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testGetFetch() throws Exception { - IType testType = this.createTestManyToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -147,8 +147,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testSetFetch() throws Exception { - IType testType = this.createTestManyToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -157,12 +157,12 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setFetch(FetchType.LAZY); assertEquals(FetchType.LAZY, manyToMany.getFetch()); - assertSourceContains("@ManyToMany(fetch=LAZY)"); + assertSourceContains("@ManyToMany(fetch=LAZY)", cu); } public void testSetFetchNull() throws Exception { - IType testType = this.createTestManyToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -171,13 +171,13 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setFetch(null); assertNull(manyToMany.getFetch()); - assertSourceContains("@ManyToMany"); - assertSourceDoesNotContain("fetch"); + assertSourceContains("@ManyToMany", cu); + assertSourceDoesNotContain("fetch", cu); } public void testGetTargetEntity() throws Exception { - IType testType = this.createTestManyToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -185,8 +185,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testSetTargetEntity() throws Exception { - IType testType = this.createTestManyToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -194,12 +194,12 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setTargetEntity("Foo"); - assertSourceContains("@ManyToMany(targetEntity=Foo.class)"); + assertSourceContains("@ManyToMany(targetEntity=Foo.class)", cu); } public void testSetTargetEntityNull() throws Exception { - IType testType = this.createTestManyToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -207,14 +207,14 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setTargetEntity(null); - assertSourceContains("@ManyToMany"); - assertSourceDoesNotContain("targetEntity"); + assertSourceContains("@ManyToMany", cu); + assertSourceDoesNotContain("targetEntity", cu); } public void testGetFullyQualifiedTargetEntity() throws Exception { - IType testType = this.createTestManyToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -222,7 +222,7 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setTargetEntity("Foo"); - assertSourceContains("@ManyToMany(targetEntity=Foo.class)"); + assertSourceContains("@ManyToMany(targetEntity=Foo.class)", cu); assertEquals("Foo", manyToMany.getTargetEntity()); @@ -230,8 +230,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testGetMappedBy() throws Exception { - IType testType = this.createTestManyToManyWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -239,8 +239,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testGetMappedByNull() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -248,8 +248,8 @@ public class ManyToManyTests extends JavaResourceModelTestCase { } public void testSetMappedBy() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -257,12 +257,12 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setMappedBy("bar"); assertEquals("bar", manyToMany.getMappedBy()); - assertSourceContains("@ManyToMany(mappedBy=\"bar\")"); + assertSourceContains("@ManyToMany(mappedBy=\"bar\")", cu); } public void testSetMappedByNull() throws Exception { - IType testType = this.createTestManyToManyWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -271,83 +271,83 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setMappedBy(null); assertNull(manyToMany.getMappedBy()); - assertSourceContains("@ManyToMany"); - assertSourceDoesNotContain("mappedBy"); + assertSourceContains("@ManyToMany", cu); + assertSourceDoesNotContain("mappedBy", cu); } public void testSetCascadeAll() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); assertFalse(manyToMany.isCascadeAll()); manyToMany.setCascadeAll(true); - assertSourceContains("@ManyToMany(cascade=ALL)"); + assertSourceContains("@ManyToMany(cascade=ALL)", cu); assertTrue(manyToMany.isCascadeAll()); } public void testSetCascadeMerge() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); assertFalse(manyToMany.isCascadeMerge()); manyToMany.setCascadeMerge(true); - assertSourceContains("@ManyToMany(cascade=MERGE)"); + assertSourceContains("@ManyToMany(cascade=MERGE)", cu); assertTrue(manyToMany.isCascadeMerge()); } public void testSetCascadePersist() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); assertFalse(manyToMany.isCascadePersist()); manyToMany.setCascadePersist(true); - assertSourceContains("@ManyToMany(cascade=PERSIST)"); + assertSourceContains("@ManyToMany(cascade=PERSIST)", cu); assertTrue(manyToMany.isCascadePersist()); } public void testSetCascadeRemove() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); assertFalse(manyToMany.isCascadeRemove()); manyToMany.setCascadeRemove(true); - assertSourceContains("@ManyToMany(cascade=REMOVE)"); + assertSourceContains("@ManyToMany(cascade=REMOVE)", cu); assertTrue(manyToMany.isCascadeRemove()); } public void testSetCascadeRefresh() throws Exception { - IType testType = this.createTestManyToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); assertFalse(manyToMany.isCascadeRefresh()); manyToMany.setCascadeRefresh(true); - assertSourceContains("@ManyToMany(cascade=REFRESH)"); + assertSourceContains("@ManyToMany(cascade=REFRESH)", cu); assertTrue(manyToMany.isCascadeRefresh()); } public void testCascadeMoreThanOnce() throws Exception { - IType testType = this.createTestManyToManyWithCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -356,23 +356,23 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setCascadeAll(true); assertTrue(manyToMany.isCascadeAll()); //a second CascadeType.All should not have been added - assertSourceContains("@ManyToMany(cascade=CascadeType.ALL)"); + assertSourceContains("@ManyToMany(cascade=CascadeType.ALL)", cu); manyToMany.setCascadeAll(false); assertFalse(manyToMany.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); //test setting cascadeAll to false again, should just do nothing manyToMany.setCascadeAll(false); assertFalse(manyToMany.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testDuplicateCascade() throws Exception { - IType testType = this.createTestManyToManyWithDuplicateCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithDuplicateCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -385,12 +385,12 @@ public class ManyToManyTests extends JavaResourceModelTestCase { manyToMany.setCascadeMerge(false); assertFalse(manyToMany.isCascadeMerge()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testMultipleCascade() throws Exception { - IType testType = this.createTestManyToManyWithMultipleCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToManyWithMultipleCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); @@ -398,9 +398,9 @@ public class ManyToManyTests extends JavaResourceModelTestCase { assertTrue(manyToMany.isCascadeRemove()); manyToMany.setCascadeMerge(false); - assertSourceContains("@ManyToMany(cascade=REMOVE)"); + assertSourceContains("@ManyToMany(cascade=REMOVE)", cu); manyToMany.setCascadeRemove(false); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java index 4e6d80ad7b..5355950212 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { super(name); } - private IType createTestManyToOne() throws Exception { + private ICompilationUnit createTestManyToOne() throws Exception { this.createAnnotationAndMembers("ManyToOne", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithFetch() throws Exception { + private ICompilationUnit createTestManyToOneWithFetch() throws Exception { this.createAnnotationAndMembers("ManyToOne", "FetchType fetch() default FetchType.LAZY;"); this.createEnumAndMembers("FetchType", "EAGER, LAZY"); return this.createTestType(new DefaultAnnotationWriter() { @@ -54,7 +54,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithTargetEntity() throws Exception { + private ICompilationUnit createTestManyToOneWithTargetEntity() throws Exception { this.createAnnotationAndMembers("ManyToOne", "Class targetEntity() default void.class;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithOptional() throws Exception { + private ICompilationUnit createTestManyToOneWithOptional() throws Exception { this.createAnnotationAndMembers("ManyToOne", "boolean optional() default true;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithCascade() throws Exception { + private ICompilationUnit createTestManyToOneWithCascade() throws Exception { this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -97,7 +97,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithMultipleCascade() throws Exception { + private ICompilationUnit createTestManyToOneWithMultipleCascade() throws Exception { this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -112,7 +112,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestManyToOneWithDuplicateCascade() throws Exception { + private ICompilationUnit createTestManyToOneWithDuplicateCascade() throws Exception { this.createAnnotationAndMembers("ManyToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -128,8 +128,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testManyToOne() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -137,8 +137,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testGetFetch() throws Exception { - IType testType = this.createTestManyToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -146,8 +146,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testSetFetch() throws Exception { - IType testType = this.createTestManyToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -156,12 +156,12 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setFetch(FetchType.LAZY); assertEquals(FetchType.LAZY, manyToOne.getFetch()); - assertSourceContains("@ManyToOne(fetch=LAZY)"); + assertSourceContains("@ManyToOne(fetch=LAZY)", cu); } public void testSetFetchNull() throws Exception { - IType testType = this.createTestManyToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -170,14 +170,14 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setFetch(null); assertNull(manyToOne.getFetch()); - assertSourceContains("@ManyToOne"); - assertSourceDoesNotContain("fetch"); + assertSourceContains("@ManyToOne", cu); + assertSourceDoesNotContain("fetch", cu); } public void testGetTargetEntity() throws Exception { - IType testType = this.createTestManyToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -185,8 +185,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testSetTargetEntity() throws Exception { - IType testType = this.createTestManyToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -194,12 +194,12 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setTargetEntity("Foo"); - assertSourceContains("@ManyToOne(targetEntity=Foo.class)"); + assertSourceContains("@ManyToOne(targetEntity=Foo.class)", cu); } public void testSetTargetEntityNull() throws Exception { - IType testType = this.createTestManyToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -207,14 +207,14 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setTargetEntity(null); - assertSourceContains("@ManyToOne"); - assertSourceDoesNotContain("targetEntity"); + assertSourceContains("@ManyToOne", cu); + assertSourceDoesNotContain("targetEntity", cu); } public void testGetFullyQualifiedTargetEntity() throws Exception { - IType testType = this.createTestManyToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -222,7 +222,7 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setTargetEntity("Foo"); - assertSourceContains("@ManyToOne(targetEntity=Foo.class)"); + assertSourceContains("@ManyToOne(targetEntity=Foo.class)", cu); assertEquals("Foo", manyToOne.getTargetEntity()); @@ -230,8 +230,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testGetOptional() throws Exception { - IType testType = this.createTestManyToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -239,8 +239,8 @@ public class ManyToOneTests extends JavaResourceModelTestCase { } public void testSetOptional() throws Exception { - IType testType = this.createTestManyToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -249,12 +249,12 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setOptional(Boolean.FALSE); assertEquals(Boolean.FALSE, manyToOne.getOptional()); - assertSourceContains("@ManyToOne(optional=false)"); + assertSourceContains("@ManyToOne(optional=false)", cu); } public void testSetOptionalNull() throws Exception { - IType testType = this.createTestManyToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -263,83 +263,83 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setOptional(null); assertNull(manyToOne.getOptional()); - assertSourceContains("@ManyToOne"); - assertSourceDoesNotContain("optional"); + assertSourceContains("@ManyToOne", cu); + assertSourceDoesNotContain("optional", cu); } public void testSetCascadeAll() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); assertFalse(manyToOne.isCascadeAll()); manyToOne.setCascadeAll(true); - assertSourceContains("@ManyToOne(cascade=ALL)"); + assertSourceContains("@ManyToOne(cascade=ALL)", cu); assertTrue(manyToOne.isCascadeAll()); } public void testSetCascadeMerge() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); assertFalse(manyToOne.isCascadeMerge()); manyToOne.setCascadeMerge(true); - assertSourceContains("@ManyToOne(cascade=MERGE)"); + assertSourceContains("@ManyToOne(cascade=MERGE)", cu); assertTrue(manyToOne.isCascadeMerge()); } public void testSetCascadePersist() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); assertFalse(manyToOne.isCascadePersist()); manyToOne.setCascadePersist(true); - assertSourceContains("@ManyToOne(cascade=PERSIST)"); + assertSourceContains("@ManyToOne(cascade=PERSIST)", cu); assertTrue(manyToOne.isCascadePersist()); } public void testSetCascadeRemove() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); assertFalse(manyToOne.isCascadeRemove()); manyToOne.setCascadeRemove(true); - assertSourceContains("@ManyToOne(cascade=REMOVE)"); + assertSourceContains("@ManyToOne(cascade=REMOVE)", cu); assertTrue(manyToOne.isCascadeRemove()); } public void testSetCascadeRefresh() throws Exception { - IType testType = this.createTestManyToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); assertFalse(manyToOne.isCascadeRefresh()); manyToOne.setCascadeRefresh(true); - assertSourceContains("@ManyToOne(cascade=REFRESH)"); + assertSourceContains("@ManyToOne(cascade=REFRESH)", cu); assertTrue(manyToOne.isCascadeRefresh()); } public void testCascadeMoreThanOnce() throws Exception { - IType testType = this.createTestManyToOneWithCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -348,23 +348,23 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setCascadeAll(true); assertTrue(manyToOne.isCascadeAll()); //a second CascadeType.All should not have been added - assertSourceContains("@ManyToOne(cascade=CascadeType.ALL)"); + assertSourceContains("@ManyToOne(cascade=CascadeType.ALL)", cu); manyToOne.setCascadeAll(false); assertFalse(manyToOne.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); //test setting cascadeAll to false again, should just do nothing manyToOne.setCascadeAll(false); assertFalse(manyToOne.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testDuplicateCascade() throws Exception { - IType testType = this.createTestManyToOneWithDuplicateCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithDuplicateCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -377,12 +377,12 @@ public class ManyToOneTests extends JavaResourceModelTestCase { manyToOne.setCascadeMerge(false); assertFalse(manyToOne.isCascadeMerge()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testMultipleCascade() throws Exception { - IType testType = this.createTestManyToOneWithMultipleCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestManyToOneWithMultipleCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); @@ -390,9 +390,9 @@ public class ManyToOneTests extends JavaResourceModelTestCase { assertTrue(manyToOne.isCascadeRemove()); manyToOne.setCascadeMerge(false); - assertSourceContains("@ManyToOne(cascade=REMOVE)"); + assertSourceContains("@ManyToOne(cascade=REMOVE)", cu); manyToOne.setCascadeRemove(false); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java index 56f72c2efc..3c8c893276 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MapKeyTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -23,7 +23,7 @@ public class MapKeyTests extends JavaResourceModelTestCase { super(name); } - private IType createTestMapKey() throws Exception { + private ICompilationUnit createTestMapKey() throws Exception { this.createAnnotationAndMembers("MapKey", "String name() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -37,7 +37,7 @@ public class MapKeyTests extends JavaResourceModelTestCase { }); } - private IType createTestMapKeyWithName() throws Exception { + private ICompilationUnit createTestMapKeyWithName() throws Exception { this.createAnnotationAndMembers("MapKey", "String name() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -52,8 +52,8 @@ public class MapKeyTests extends JavaResourceModelTestCase { } public void testMapKey() throws Exception { - IType testType = this.createTestMapKey(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMapKey(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY); @@ -61,8 +61,8 @@ public class MapKeyTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestMapKeyWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMapKeyWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY); @@ -70,20 +70,20 @@ public class MapKeyTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestMapKey(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMapKey(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(JPA.MAP_KEY); mapKey.setName("foo"); - - assertSourceContains("@MapKey(name=\"foo\")"); + + assertSourceContains("@MapKey(name=\"foo\")", cu); mapKey.setName(null); - assertSourceContains("@MapKey"); - assertSourceDoesNotContain("@MapKey(name=\"foo\")"); + assertSourceContains("@MapKey", cu); + assertSourceDoesNotContain("@MapKey(name=\"foo\")", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java index 9718cf90e6..4fa66cf2cc 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/MappedSuperclassTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.EntityAnnotation; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -24,7 +24,7 @@ public class MappedSuperclassTests extends JavaResourceModelTestCase { super(name); } - private IType createTestMappedSuperclass() throws Exception { + private ICompilationUnit createTestMappedSuperclass() throws Exception { this.createAnnotationAndMembers("MappedSuperclass", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -38,7 +38,7 @@ public class MappedSuperclassTests extends JavaResourceModelTestCase { }); } - private IType createTestMappedSuperclassAndEntity() throws Exception { + private ICompilationUnit createTestMappedSuperclassAndEntity() throws Exception { this.createAnnotationAndMembers("MappedSuperclass", ""); this.createAnnotationAndMembers("Entity", ""); return this.createTestType(new DefaultAnnotationWriter() { @@ -55,16 +55,16 @@ public class MappedSuperclassTests extends JavaResourceModelTestCase { } public void testMappedSuperclass() throws Exception { - IType testType = this.createTestMappedSuperclass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMappedSuperclass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(mappingAnnotation instanceof MappedSuperclassAnnotation); } public void testMappedSuperclassAndEntity() throws Exception { - IType testType = this.createTestMappedSuperclassAndEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestMappedSuperclassAndEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourceNode mappingAnnotation = typeResource.getMappingAnnotation(); assertTrue(mappingAnnotation instanceof EntityAnnotation); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java index f466cb28f8..0afd0c7bf1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -48,7 +48,7 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { "String value();"); } - private IType createTestNamedNativeQueries() throws Exception { + private ICompilationUnit createTestNamedNativeQueries() throws Exception { createNamedNativeQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -62,20 +62,20 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedNativeQueryWithName() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithName() throws Exception { return createTestNamedNativeQueryWithStringElement("name", QUERY_NAME); } - private IType createTestNamedNativeQueryWithQuery() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithQuery() throws Exception { return createTestNamedNativeQueryWithStringElement("query", QUERY_QUERY); } - private IType createTestNamedNativeQueryWithResultSetMapping() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithResultSetMapping() throws Exception { return createTestNamedNativeQueryWithStringElement("resultSetMapping", QUERY_RESULT_SET_MAPPING); } - private IType createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception { createNamedNativeQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -89,7 +89,7 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedNativeQueryWithResultClass() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithResultClass() throws Exception { createNamedNativeQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -102,7 +102,7 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } }); } - private IType createTestNamedNativeQueryWithQueryHints() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithQueryHints() throws Exception { createNamedNativeQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -116,7 +116,7 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedNativeQuery() throws Exception { + private ICompilationUnit createTestNamedNativeQuery() throws Exception { createNamedNativeQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -131,8 +131,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testNamedNativeQuery() throws Exception { - IType testType = this.createTestNamedNativeQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -140,8 +140,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -149,8 +149,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -159,17 +159,17 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { namedQuery.setName("foo"); assertEquals("foo", namedQuery.getName()); - assertSourceContains("@NamedNativeQuery(name=\"foo\")"); + assertSourceContains("@NamedNativeQuery(name=\"foo\")", cu); namedQuery.setName(null); assertNull(namedQuery.getName()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetQuery() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -177,8 +177,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testSetQuery() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -187,17 +187,17 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { namedQuery.setQuery("foo"); assertEquals("foo", namedQuery.getQuery()); - assertSourceContains("@NamedNativeQuery(query=\"foo\")"); + assertSourceContains("@NamedNativeQuery(query=\"foo\")", cu); namedQuery.setQuery(null); assertNull(namedQuery.getQuery()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetResultClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -205,8 +205,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testSetResultClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -215,17 +215,17 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { namedQuery.setResultClass("foo"); assertEquals("foo", namedQuery.getResultClass()); - assertSourceContains("@NamedNativeQuery(resultClass=foo.class)"); + assertSourceContains("@NamedNativeQuery(resultClass=foo.class)", cu); namedQuery.setResultClass(null); assertNull(namedQuery.getResultClass()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetFullyQualifiedClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -235,12 +235,12 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { namedQuery.setResultClass(TYPE_NAME); assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass()); - assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)"); + assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)", cu); } public void testGetResultSetMapping() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -248,8 +248,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testSetResultSetMapping() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -258,17 +258,17 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { namedQuery.setResultSetMapping("foo"); assertEquals("foo", namedQuery.getResultSetMapping()); - assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")"); + assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")", cu); namedQuery.setResultSetMapping(null); assertNull(namedQuery.getResultSetMapping()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testHints() throws Exception { - IType testType = this.createTestNamedNativeQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -277,8 +277,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testHints2() throws Exception { - IType testType = this.createTestNamedNativeQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -290,8 +290,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testHints3() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -300,8 +300,8 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testAddHint() throws Exception { - IType testType = this.createTestNamedNativeQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -313,12 +313,12 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals("FOO", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})"); + assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})", cu); } public void testRemoveHint() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -333,22 +333,22 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertEquals(2, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))"); + assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))", cu); namedQuery.removeHint(0); assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals(1, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))"); + assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))", cu); namedQuery.removeHint(0); assertEquals(0, namedQuery.hintsSize()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testMoveHint() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -366,12 +366,12 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { assertNull(namedQuery.hintAt(1).getName()); assertEquals("BAZ", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))"); + assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))", cu); } public void testMoveHint2() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -389,16 +389,16 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(1).getName()); assertEquals("BAR", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))"); + assertSourceContains("@NamedNativeQueries(@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))", cu); } public void testAddNamedNativeQueryCopyExisting() throws Exception { - IType jdtType = createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})"); + assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY)); assertNotNull(typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERIES)); @@ -406,16 +406,16 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testAddNamedNativeQueryToBeginningOfList() throws Exception { - IType jdtType = createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})"); + assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})", cu); namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); namedQuery.setName("BAZ"); - assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"BAZ\"),@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"), @NamedNativeQuery(name=\"BAR\")})"); + assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"BAZ\"),@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"), @NamedNativeQuery(name=\"BAR\")})", cu); Iterator<JavaResourceNode> namedQueries = typeResource.annotations(JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); assertEquals("BAZ", ((NamedNativeQueryAnnotation) namedQueries.next()).getName()); @@ -428,14 +428,14 @@ public class NamedNativeQueriesTests extends JavaResourceModelTestCase { } public void testRemoveNamedNativeQueryCopyExisting() throws Exception { - IType jdtType = createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})"); + assertSourceContains("@NamedNativeQueries({@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\"),@NamedNativeQuery(name=\"BAR\")})", cu); typeResource.removeAnnotation(1, JPA.NAMED_NATIVE_QUERY, JPA.NAMED_NATIVE_QUERIES); - assertSourceContains("@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\")"); + assertSourceContains("@NamedNativeQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"), resultClass = Foo.class, resultSetMapping = \"mapping\")", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java index 1a60f1dbe0..00529df8d2 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; @@ -39,7 +39,7 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { "String value();"); } - private IType createTestNamedNativeQuery() throws Exception { + private ICompilationUnit createTestNamedNativeQuery() throws Exception { createNamedNativeQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -53,20 +53,20 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedNativeQueryWithName() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithName() throws Exception { return createTestNamedNativeQueryWithStringElement("name", QUERY_NAME); } - private IType createTestNamedNativeQueryWithQuery() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithQuery() throws Exception { return createTestNamedNativeQueryWithStringElement("query", QUERY_QUERY); } - private IType createTestNamedNativeQueryWithResultSetMapping() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithResultSetMapping() throws Exception { return createTestNamedNativeQueryWithStringElement("resultSetMapping", QUERY_RESULT_SET_MAPPING); } - private IType createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithStringElement(final String elementName, final String value) throws Exception { createNamedNativeQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -80,7 +80,7 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedNativeQueryWithResultClass() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithResultClass() throws Exception { createNamedNativeQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -93,7 +93,7 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { } }); } - private IType createTestNamedNativeQueryWithQueryHints() throws Exception { + private ICompilationUnit createTestNamedNativeQueryWithQueryHints() throws Exception { createNamedNativeQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -108,24 +108,24 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { } public void testNamedNativeQuery() throws Exception { - IType testType = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertNotNull(namedQuery); } public void testGetName() throws Exception { - IType testType = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); } public void testSetName() throws Exception { - IType testType = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); @@ -133,25 +133,25 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { namedQuery.setName("foo"); assertEquals("foo", namedQuery.getName()); - assertSourceContains("@NamedNativeQuery(name=\"foo\")"); + assertSourceContains("@NamedNativeQuery(name=\"foo\")", cu); namedQuery.setName(null); assertNull(namedQuery.getName()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetQuery() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); } public void testSetQuery() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); @@ -159,25 +159,25 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { namedQuery.setQuery("foo"); assertEquals("foo", namedQuery.getQuery()); - assertSourceContains("@NamedNativeQuery(query=\"foo\")"); + assertSourceContains("@NamedNativeQuery(query=\"foo\")", cu); namedQuery.setQuery(null); assertNull(namedQuery.getQuery()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetResultClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass()); } public void testSetResultClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass()); @@ -185,17 +185,17 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { namedQuery.setResultClass("foo"); assertEquals("foo", namedQuery.getResultClass()); - assertSourceContains("@NamedNativeQuery(resultClass=foo.class)"); + assertSourceContains("@NamedNativeQuery(resultClass=foo.class)", cu); namedQuery.setResultClass(null); assertNull(namedQuery.getResultClass()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testGetFullyQualifiedClass() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertNotNull(namedQuery.getResultClass()); @@ -204,20 +204,20 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { namedQuery.setResultClass(TYPE_NAME); assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass()); - assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)"); + assertSourceContains("@NamedNativeQuery(resultClass=" + TYPE_NAME + ".class)", cu); } public void testGetResultSetMapping() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping()); } public void testSetResultSetMapping() throws Exception { - IType testType = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping()); @@ -225,17 +225,17 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { namedQuery.setResultSetMapping("foo"); assertEquals("foo", namedQuery.getResultSetMapping()); - assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")"); + assertSourceContains("@NamedNativeQuery(resultSetMapping=\"foo\")", cu); namedQuery.setResultSetMapping(null); assertNull(namedQuery.getResultSetMapping()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testHints() throws Exception { - IType testType = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); @@ -243,8 +243,8 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { } public void testHints2() throws Exception { - IType testType = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); @@ -255,8 +255,8 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { } public void testHints3() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); @@ -265,8 +265,8 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { public void testAddHint() throws Exception { - IType testType = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); @@ -277,12 +277,12 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals("FOO", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})"); + assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})", cu); } public void testRemoveHint() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("BAZ"); @@ -296,22 +296,22 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertEquals(2, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})"); + assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})", cu); namedQuery.removeHint(0); assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals(1, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))"); + assertSourceContains("@NamedNativeQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))", cu); namedQuery.removeHint(0); assertEquals(0, namedQuery.hintsSize()); - assertSourceDoesNotContain("@NamedNativeQuery"); + assertSourceDoesNotContain("@NamedNativeQuery", cu); } public void testMoveHint() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); @@ -328,12 +328,12 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { assertNull(namedQuery.hintAt(1).getName()); assertEquals("BAZ", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})"); + assertSourceContains("@NamedNativeQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})", cu); } public void testMoveHint2() throws Exception { - IType testType = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("BAZ"); @@ -349,7 +349,7 @@ public class NamedNativeQueryTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(1).getName()); assertEquals("BAR", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})"); + assertSourceContains("@NamedNativeQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java index 621a25551e..77208998b3 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueriesTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -46,7 +46,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { "String value();"); } - private IType createTestNamedQueries() throws Exception { + private ICompilationUnit createTestNamedQueries() throws Exception { createNamedQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -60,15 +60,15 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedQueryWithName() throws Exception { + private ICompilationUnit createTestNamedQueryWithName() throws Exception { return createTestNamedQueryWithStringElement("name", QUERY_NAME); } - private IType createTestNamedQueryWithQuery() throws Exception { + private ICompilationUnit createTestNamedQueryWithQuery() throws Exception { return createTestNamedQueryWithStringElement("query", QUERY_QUERY); } - private IType createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception { createNamedQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedQueryWithQueryHints() throws Exception { + private ICompilationUnit createTestNamedQueryWithQueryHints() throws Exception { createNamedQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -97,7 +97,7 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } - private IType createTestNamedQuery() throws Exception { + private ICompilationUnit createTestNamedQuery() throws Exception { createNamedQueriesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -112,8 +112,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testNamedQuery() throws Exception { - IType testType = this.createTestNamedQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -121,8 +121,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestNamedQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -130,8 +130,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestNamedQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -140,17 +140,17 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { namedQuery.setName("foo"); assertEquals("foo", namedQuery.getName()); - assertSourceContains("@NamedQuery(name=\"foo\")"); + assertSourceContains("@NamedQuery(name=\"foo\")", cu); namedQuery.setName(null); assertNull(namedQuery.getName()); - assertSourceDoesNotContain("@NamedQuery"); + assertSourceDoesNotContain("@NamedQuery", cu); } public void testGetQuery() throws Exception { - IType testType = this.createTestNamedQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -158,8 +158,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testSetQuery() throws Exception { - IType testType = this.createTestNamedQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -168,17 +168,17 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { namedQuery.setQuery("foo"); assertEquals("foo", namedQuery.getQuery()); - assertSourceContains("@NamedQuery(query=\"foo\")"); + assertSourceContains("@NamedQuery(query=\"foo\")", cu); namedQuery.setQuery(null); assertNull(namedQuery.getQuery()); - assertSourceDoesNotContain("@NamedQuery"); + assertSourceDoesNotContain("@NamedQuery", cu); } public void testHints() throws Exception { - IType testType = this.createTestNamedQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -187,8 +187,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testHints2() throws Exception { - IType testType = this.createTestNamedQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -200,8 +200,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testHints3() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -210,8 +210,8 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testAddHint() throws Exception { - IType testType = this.createTestNamedQueries(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueries(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -224,12 +224,12 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { assertEquals("FOO", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})"); + assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})", cu); } public void testRemoveHint() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -244,21 +244,21 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertEquals(2, namedQuery.hintsSize()); - assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))"); + assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))", cu); namedQuery.removeHint(0); assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals(1, namedQuery.hintsSize()); - assertSourceContains("@NamedQueries(@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))"); + assertSourceContains("@NamedQueries(@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\")))", cu); namedQuery.removeHint(0); assertEquals(0, namedQuery.hintsSize()); - assertSourceDoesNotContain("@NamedQueries"); + assertSourceDoesNotContain("@NamedQueries", cu); } public void testMoveHint() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -275,12 +275,12 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { assertNull(namedQuery.hintAt(1).getName()); assertEquals("BAZ", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))"); + assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")}))", cu); } public void testMoveHint2() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueriesAnnotation namedQueries = (NamedQueriesAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERIES); NamedQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); @@ -297,16 +297,16 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(1).getName()); assertEquals("BAR", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))"); + assertSourceContains("@NamedQueries(@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")}))", cu); } public void testAddNamedQueryCopyExisting() throws Exception { - IType jdtType = createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})"); + assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.NAMED_QUERY)); assertNotNull(typeResource.getAnnotation(JPA.NAMED_QUERIES)); @@ -314,17 +314,17 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testAddNamedQueryToBeginningOfList() throws Exception { - IType jdtType = createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})"); + assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})", cu); namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(0, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); namedQuery.setName("BAZ"); - assertSourceContains("@NamedQueries({@NamedQuery(name=\"BAZ\"),@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")), @NamedQuery(name=\"BAR\")})"); + assertSourceContains("@NamedQueries({@NamedQuery(name=\"BAZ\"),@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")), @NamedQuery(name=\"BAR\")})", cu); Iterator<JavaResourceNode> namedQueries = typeResource.annotations(JPA.NAMED_QUERY, JPA.NAMED_QUERIES); assertEquals("BAZ", ((NamedQueryAnnotation) namedQueries.next()).getName()); @@ -337,15 +337,15 @@ public class NamedQueriesTests extends JavaResourceModelTestCase { } public void testRemoveNamedQueryCopyExisting() throws Exception { - IType jdtType = createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.addAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); namedQuery.setName("BAR"); - assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})"); + assertSourceContains("@NamedQueries({@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\")),@NamedQuery(name=\"BAR\")})", cu); typeResource.removeAnnotation(1, JPA.NAMED_QUERY, JPA.NAMED_QUERIES); - assertSourceContains("@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"))"); + assertSourceContains("@NamedQuery(name=\"foo\", query = \"bar\", hints = @QueryHint(name=\"BAR\", value = \"FOO\"))", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java index 54c3050175..51fd90e940 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedQueryTests.java @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; @@ -39,7 +39,7 @@ public class NamedQueryTests extends JavaResourceModelTestCase { "String value();"); } - private IType createTestNamedQuery() throws Exception { + private ICompilationUnit createTestNamedQuery() throws Exception { createNamedQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -53,15 +53,15 @@ public class NamedQueryTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedQueryWithName() throws Exception { + private ICompilationUnit createTestNamedQueryWithName() throws Exception { return createTestNamedQueryWithStringElement("name", QUERY_NAME); } - private IType createTestNamedQueryWithQuery() throws Exception { + private ICompilationUnit createTestNamedQueryWithQuery() throws Exception { return createTestNamedQueryWithStringElement("query", QUERY_QUERY); } - private IType createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestNamedQueryWithStringElement(final String elementName, final String value) throws Exception { createNamedQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -75,7 +75,7 @@ public class NamedQueryTests extends JavaResourceModelTestCase { }); } - private IType createTestNamedQueryWithQueryHints() throws Exception { + private ICompilationUnit createTestNamedQueryWithQueryHints() throws Exception { createNamedQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -90,24 +90,24 @@ public class NamedQueryTests extends JavaResourceModelTestCase { } public void testNamedQuery() throws Exception { - IType testType = this.createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); assertNotNull(namedQuery); } public void testGetName() throws Exception { - IType testType = this.createTestNamedQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); } public void testSetName() throws Exception { - IType testType = this.createTestNamedQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); @@ -115,25 +115,25 @@ public class NamedQueryTests extends JavaResourceModelTestCase { namedQuery.setName("foo"); assertEquals("foo", namedQuery.getName()); - assertSourceContains("@NamedQuery(name=\"foo\")"); + assertSourceContains("@NamedQuery(name=\"foo\")", cu); namedQuery.setName(null); assertNull(namedQuery.getName()); - assertSourceDoesNotContain("@NamedQuery"); + assertSourceDoesNotContain("@NamedQuery", cu); } public void testGetQuery() throws Exception { - IType testType = this.createTestNamedQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); } public void testSetQuery() throws Exception { - IType testType = this.createTestNamedQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); @@ -141,17 +141,17 @@ public class NamedQueryTests extends JavaResourceModelTestCase { namedQuery.setQuery("foo"); assertEquals("foo", namedQuery.getQuery()); - assertSourceContains("@NamedQuery(query=\"foo\")"); + assertSourceContains("@NamedQuery(query=\"foo\")", cu); namedQuery.setQuery(null); assertNull(namedQuery.getQuery()); - assertSourceDoesNotContain("@NamedQuery"); + assertSourceDoesNotContain("@NamedQuery", cu); } public void testHints() throws Exception { - IType testType = this.createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); @@ -159,8 +159,8 @@ public class NamedQueryTests extends JavaResourceModelTestCase { } public void testHints2() throws Exception { - IType testType = this.createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); @@ -171,8 +171,8 @@ public class NamedQueryTests extends JavaResourceModelTestCase { } public void testHints3() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); @@ -184,8 +184,8 @@ public class NamedQueryTests extends JavaResourceModelTestCase { } public void testAddHint() throws Exception { - IType testType = this.createTestNamedQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQuery(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); @@ -197,12 +197,12 @@ public class NamedQueryTests extends JavaResourceModelTestCase { assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals("FOO", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})"); + assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\"),@QueryHint(name=\"FOO\"), @QueryHint})", cu); } public void testRemoveHint() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); namedQuery.addHint(0).setName("BAZ"); @@ -216,21 +216,21 @@ public class NamedQueryTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertEquals(2, namedQuery.hintsSize()); - assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})"); + assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})", cu); namedQuery.removeHint(0); assertEquals("BAR", namedQuery.hintAt(0).getName()); assertEquals(1, namedQuery.hintsSize()); - assertSourceContains("@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))"); + assertSourceContains("@NamedQuery(hints=@QueryHint(name=\"BAR\", value=\"FOO\"))", cu); namedQuery.removeHint(0); assertEquals(0, namedQuery.hintsSize()); - assertSourceDoesNotContain("@NamedQuery"); + assertSourceDoesNotContain("@NamedQuery", cu); } public void testMoveHint() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); namedQuery.addHint(0).setName("BAZ"); @@ -246,12 +246,12 @@ public class NamedQueryTests extends JavaResourceModelTestCase { assertNull(namedQuery.hintAt(1).getName()); assertEquals("BAZ", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})"); + assertSourceContains("@NamedQuery(hints={@QueryHint(name=\"BAR\", value=\"FOO\"), @QueryHint, @QueryHint(name=\"BAZ\")})", cu); } public void testMoveHint2() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); namedQuery.addHint(0).setName("BAZ"); @@ -267,7 +267,7 @@ public class NamedQueryTests extends JavaResourceModelTestCase { assertEquals("BAZ", namedQuery.hintAt(1).getName()); assertEquals("BAR", namedQuery.hintAt(2).getName()); assertEquals(3, namedQuery.hintsSize()); - assertSourceContains("@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})"); + assertSourceContains("@NamedQuery(hints={@QueryHint, @QueryHint(name=\"BAZ\"), @QueryHint(name=\"BAR\", value=\"FOO\")})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java index 50a0ff4257..eda0b0e0e6 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { super(name); } - private IType createTestOneToMany() throws Exception { + private ICompilationUnit createTestOneToMany() throws Exception { this.createAnnotationAndMembers("OneToMany", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithFetch() throws Exception { + private ICompilationUnit createTestOneToManyWithFetch() throws Exception { this.createAnnotationAndMembers("OneToMany", "FetchType fetch() default FetchType.LAZY;"); this.createEnumAndMembers("FetchType", "EAGER, LAZY"); return this.createTestType(new DefaultAnnotationWriter() { @@ -54,7 +54,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithTargetEntity() throws Exception { + private ICompilationUnit createTestOneToManyWithTargetEntity() throws Exception { this.createAnnotationAndMembers("OneToMany", "Class targetEntity() default void.class;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithMappedBy() throws Exception { + private ICompilationUnit createTestOneToManyWithMappedBy() throws Exception { this.createAnnotationAndMembers("OneToMany", "String mappedBy() default\"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithCascade() throws Exception { + private ICompilationUnit createTestOneToManyWithCascade() throws Exception { this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -97,7 +97,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithMultipleCascade() throws Exception { + private ICompilationUnit createTestOneToManyWithMultipleCascade() throws Exception { this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -112,7 +112,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToManyWithDuplicateCascade() throws Exception { + private ICompilationUnit createTestOneToManyWithDuplicateCascade() throws Exception { this.createAnnotationAndMembers("OneToMany", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -128,8 +128,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testOneToMany() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -137,8 +137,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testGetFetch() throws Exception { - IType testType = this.createTestOneToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -146,8 +146,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testSetFetch() throws Exception { - IType testType = this.createTestOneToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -156,12 +156,12 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setFetch(FetchType.LAZY); assertEquals(FetchType.LAZY, oneToMany.getFetch()); - assertSourceContains("@OneToMany(fetch=LAZY)"); + assertSourceContains("@OneToMany(fetch=LAZY)", cu); } public void testSetFetchNull() throws Exception { - IType testType = this.createTestOneToManyWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -170,14 +170,14 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setFetch(null); assertNull(oneToMany.getFetch()); - assertSourceContains("@OneToMany"); - assertSourceDoesNotContain("fetch"); + assertSourceContains("@OneToMany", cu); + assertSourceDoesNotContain("fetch", cu); } public void testGetTargetEntity() throws Exception { - IType testType = this.createTestOneToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -185,8 +185,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testSetTargetEntity() throws Exception { - IType testType = this.createTestOneToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -194,12 +194,12 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setTargetEntity("Foo"); - assertSourceContains("@OneToMany(targetEntity=Foo.class)"); + assertSourceContains("@OneToMany(targetEntity=Foo.class)", cu); } public void testSetTargetEntityNull() throws Exception { - IType testType = this.createTestOneToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -207,14 +207,14 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setTargetEntity(null); - assertSourceContains("@OneToMany"); - assertSourceDoesNotContain("targetEntity"); + assertSourceContains("@OneToMany", cu); + assertSourceDoesNotContain("targetEntity", cu); } public void testGetFullyQualifiedTargetEntity() throws Exception { - IType testType = this.createTestOneToManyWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -222,7 +222,7 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setTargetEntity("Foo"); - assertSourceContains("@OneToMany(targetEntity=Foo.class)"); + assertSourceContains("@OneToMany(targetEntity=Foo.class)", cu); assertEquals("Foo", oneToMany.getTargetEntity()); @@ -230,8 +230,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testGetMappedBy() throws Exception { - IType testType = this.createTestOneToManyWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -240,8 +240,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { public void testGetMappedByNull() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -249,8 +249,8 @@ public class OneToManyTests extends JavaResourceModelTestCase { } public void testSetMappedBy() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -258,12 +258,12 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setMappedBy("bar"); assertEquals("bar", oneToMany.getMappedBy()); - assertSourceContains("@OneToMany(mappedBy=\"bar\")"); + assertSourceContains("@OneToMany(mappedBy=\"bar\")", cu); } public void testSetMappedByNull() throws Exception { - IType testType = this.createTestOneToManyWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -272,83 +272,83 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setMappedBy(null); assertNull(oneToMany.getMappedBy()); - assertSourceContains("@OneToMany"); - assertSourceDoesNotContain("mappedBy"); + assertSourceContains("@OneToMany", cu); + assertSourceDoesNotContain("mappedBy", cu); } public void testSetCascadeAll() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); assertFalse(oneToMany.isCascadeAll()); oneToMany.setCascadeAll(true); - assertSourceContains("@OneToMany(cascade=ALL)"); + assertSourceContains("@OneToMany(cascade=ALL)", cu); assertTrue(oneToMany.isCascadeAll()); } public void testSetCascadeMerge() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); assertFalse(oneToMany.isCascadeMerge()); oneToMany.setCascadeMerge(true); - assertSourceContains("@OneToMany(cascade=MERGE)"); + assertSourceContains("@OneToMany(cascade=MERGE)", cu); assertTrue(oneToMany.isCascadeMerge()); } public void testSetCascadePersist() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); assertFalse(oneToMany.isCascadePersist()); oneToMany.setCascadePersist(true); - assertSourceContains("@OneToMany(cascade=PERSIST)"); + assertSourceContains("@OneToMany(cascade=PERSIST)", cu); assertTrue(oneToMany.isCascadePersist()); } public void testSetCascadeRemove() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); assertFalse(oneToMany.isCascadeRemove()); oneToMany.setCascadeRemove(true); - assertSourceContains("@OneToMany(cascade=REMOVE)"); + assertSourceContains("@OneToMany(cascade=REMOVE)", cu); assertTrue(oneToMany.isCascadeRemove()); } public void testSetCascadeRefresh() throws Exception { - IType testType = this.createTestOneToMany(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToMany(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); assertFalse(oneToMany.isCascadeRefresh()); oneToMany.setCascadeRefresh(true); - assertSourceContains("@OneToMany(cascade=REFRESH)"); + assertSourceContains("@OneToMany(cascade=REFRESH)", cu); assertTrue(oneToMany.isCascadeRefresh()); } public void testCascadeMoreThanOnce() throws Exception { - IType testType = this.createTestOneToManyWithCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -357,23 +357,23 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setCascadeAll(true); assertTrue(oneToMany.isCascadeAll()); //a second CascadeType.All should not have been added - assertSourceContains("@OneToMany(cascade=CascadeType.ALL)"); + assertSourceContains("@OneToMany(cascade=CascadeType.ALL)", cu); oneToMany.setCascadeAll(false); assertFalse(oneToMany.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); //test setting cascadeAll to false again, should just do nothing oneToMany.setCascadeAll(false); assertFalse(oneToMany.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testDuplicateCascade() throws Exception { - IType testType = this.createTestOneToManyWithDuplicateCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithDuplicateCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -386,12 +386,12 @@ public class OneToManyTests extends JavaResourceModelTestCase { oneToMany.setCascadeMerge(false); assertFalse(oneToMany.isCascadeMerge()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testMultipleCascade() throws Exception { - IType testType = this.createTestOneToManyWithMultipleCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToManyWithMultipleCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); @@ -399,10 +399,10 @@ public class OneToManyTests extends JavaResourceModelTestCase { assertTrue(oneToMany.isCascadeRemove()); oneToMany.setCascadeMerge(false); - assertSourceContains("@OneToMany(cascade=REMOVE)"); + assertSourceContains("@OneToMany(cascade=REMOVE)", cu); oneToMany.setCascadeRemove(false); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java index a8314b2bcf..dd0e044629 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.FetchType; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { super(name); } - private IType createTestOneToOne() throws Exception { + private ICompilationUnit createTestOneToOne() throws Exception { this.createAnnotationAndMembers("OneToOne", "FetchType fetch() default FetchType.LAZY; CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithFetch() throws Exception { + private ICompilationUnit createTestOneToOneWithFetch() throws Exception { this.createAnnotationAndMembers("OneToOne", "FetchType fetch() default FetchType.LAZY;"); this.createEnumAndMembers("FetchType", "EAGER, LAZY"); return this.createTestType(new DefaultAnnotationWriter() { @@ -54,7 +54,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithTargetEntity() throws Exception { + private ICompilationUnit createTestOneToOneWithTargetEntity() throws Exception { this.createAnnotationAndMembers("OneToOne", "Class targetEntity() default void.class;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithOptional() throws Exception { + private ICompilationUnit createTestOneToOneWithOptional() throws Exception { this.createAnnotationAndMembers("OneToOne", "boolean optional() default true;"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithMappedBy() throws Exception { + private ICompilationUnit createTestOneToOneWithMappedBy() throws Exception { this.createAnnotationAndMembers("OneToOne", "String mappedBy() default\"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -96,7 +96,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithCascade() throws Exception { + private ICompilationUnit createTestOneToOneWithCascade() throws Exception { this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -111,7 +111,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithMultipleCascade() throws Exception { + private ICompilationUnit createTestOneToOneWithMultipleCascade() throws Exception { this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -126,7 +126,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { }); } - private IType createTestOneToOneWithDuplicateCascade() throws Exception { + private ICompilationUnit createTestOneToOneWithDuplicateCascade() throws Exception { this.createAnnotationAndMembers("OneToOne", "CascadeType[] cascade() default = {};"); this.createEnumAndMembers("CascadeType", "ALL, PERSIST, MERGE, REMOVE, REFRESH"); return this.createTestType(new DefaultAnnotationWriter() { @@ -142,8 +142,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testOneToOne() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -151,8 +151,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testGetFetch() throws Exception { - IType testType = this.createTestOneToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -160,8 +160,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testSetFetch() throws Exception { - IType testType = this.createTestOneToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -170,12 +170,12 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setFetch(FetchType.LAZY); assertEquals(FetchType.LAZY, oneToOne.getFetch()); - assertSourceContains("@OneToOne(fetch=LAZY)"); + assertSourceContains("@OneToOne(fetch=LAZY)", cu); } public void testSetFetchNull() throws Exception { - IType testType = this.createTestOneToOneWithFetch(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithFetch(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -184,14 +184,14 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setFetch(null); assertNull(oneToOne.getFetch()); - assertSourceContains("@OneToOne"); - assertSourceDoesNotContain("fetch"); + assertSourceContains("@OneToOne", cu); + assertSourceDoesNotContain("fetch", cu); } public void testGetTargetEntity() throws Exception { - IType testType = this.createTestOneToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -199,8 +199,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testSetTargetEntity() throws Exception { - IType testType = this.createTestOneToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -208,12 +208,12 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setTargetEntity("Foo"); - assertSourceContains("@OneToOne(targetEntity=Foo.class)"); + assertSourceContains("@OneToOne(targetEntity=Foo.class)", cu); } public void testSetTargetEntityNull() throws Exception { - IType testType = this.createTestOneToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -221,14 +221,14 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setTargetEntity(null); - assertSourceContains("@OneToOne"); - assertSourceDoesNotContain("targetEntity"); + assertSourceContains("@OneToOne", cu); + assertSourceDoesNotContain("targetEntity", cu); } public void testGetFullyQualifiedTargetEntity() throws Exception { - IType testType = this.createTestOneToOneWithTargetEntity(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithTargetEntity(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -236,7 +236,7 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setTargetEntity("Foo"); - assertSourceContains("@OneToOne(targetEntity=Foo.class)"); + assertSourceContains("@OneToOne(targetEntity=Foo.class)", cu); assertEquals("Foo", oneToOne.getTargetEntity()); @@ -244,8 +244,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testGetOptional() throws Exception { - IType testType = this.createTestOneToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -253,8 +253,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testSetOptional() throws Exception { - IType testType = this.createTestOneToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -263,12 +263,12 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setOptional(Boolean.FALSE); assertEquals(Boolean.FALSE, oneToOne.getOptional()); - assertSourceContains("@OneToOne(optional=false)"); + assertSourceContains("@OneToOne(optional=false)", cu); } public void testSetOptionalNull() throws Exception { - IType testType = this.createTestOneToOneWithOptional(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithOptional(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -277,13 +277,13 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setOptional(null); assertNull(oneToOne.getOptional()); - assertSourceContains("@OneToOne"); - assertSourceDoesNotContain("optional"); + assertSourceContains("@OneToOne", cu); + assertSourceDoesNotContain("optional", cu); } public void testGetMappedBy() throws Exception { - IType testType = this.createTestOneToOneWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -291,8 +291,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testGetMappedByNull() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -300,8 +300,8 @@ public class OneToOneTests extends JavaResourceModelTestCase { } public void testSetMappedBy() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -309,12 +309,12 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setMappedBy("bar"); assertEquals("bar", oneToOne.getMappedBy()); - assertSourceContains("@OneToOne(mappedBy=\"bar\")"); + assertSourceContains("@OneToOne(mappedBy=\"bar\")", cu); } public void testSetMappedByNull() throws Exception { - IType testType = this.createTestOneToOneWithMappedBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithMappedBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -323,83 +323,83 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setMappedBy(null); assertNull(oneToOne.getMappedBy()); - assertSourceContains("@OneToOne"); - assertSourceDoesNotContain("mappedBy"); + assertSourceContains("@OneToOne", cu); + assertSourceDoesNotContain("mappedBy", cu); } public void testSetCascadeAll() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); assertFalse(oneToOne.isCascadeAll()); oneToOne.setCascadeAll(true); - assertSourceContains("@OneToOne(cascade=ALL)"); + assertSourceContains("@OneToOne(cascade=ALL)", cu); assertTrue(oneToOne.isCascadeAll()); } public void testSetCascadeMerge() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); assertFalse(oneToOne.isCascadeMerge()); oneToOne.setCascadeMerge(true); - assertSourceContains("@OneToOne(cascade=MERGE)"); + assertSourceContains("@OneToOne(cascade=MERGE)", cu); assertTrue(oneToOne.isCascadeMerge()); } public void testSetCascadePersist() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); assertFalse(oneToOne.isCascadePersist()); oneToOne.setCascadePersist(true); - assertSourceContains("@OneToOne(cascade=PERSIST)"); + assertSourceContains("@OneToOne(cascade=PERSIST)", cu); assertTrue(oneToOne.isCascadePersist()); } public void testSetCascadeRemove() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); assertFalse(oneToOne.isCascadeRemove()); oneToOne.setCascadeRemove(true); - assertSourceContains("@OneToOne(cascade=REMOVE)"); + assertSourceContains("@OneToOne(cascade=REMOVE)", cu); assertTrue(oneToOne.isCascadeRemove()); } public void testSetCascadeRefresh() throws Exception { - IType testType = this.createTestOneToOne(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOne(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); assertFalse(oneToOne.isCascadeRefresh()); oneToOne.setCascadeRefresh(true); - assertSourceContains("@OneToOne(cascade=REFRESH)"); + assertSourceContains("@OneToOne(cascade=REFRESH)", cu); assertTrue(oneToOne.isCascadeRefresh()); } public void testCascadeMoreThanOnce() throws Exception { - IType testType = this.createTestOneToOneWithCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -408,23 +408,23 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setCascadeAll(true); assertTrue(oneToOne.isCascadeAll()); //a second CascadeType.All should not have been added - assertSourceContains("@OneToOne(cascade=CascadeType.ALL)"); + assertSourceContains("@OneToOne(cascade=CascadeType.ALL)", cu); oneToOne.setCascadeAll(false); assertFalse(oneToOne.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); //test setting cascadeAll to false again, should just do nothing oneToOne.setCascadeAll(false); assertFalse(oneToOne.isCascadeAll()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testDuplicateCascade() throws Exception { - IType testType = this.createTestOneToOneWithDuplicateCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithDuplicateCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -437,12 +437,12 @@ public class OneToOneTests extends JavaResourceModelTestCase { oneToOne.setCascadeMerge(false); assertFalse(oneToOne.isCascadeMerge()); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } public void testMultipleCascade() throws Exception { - IType testType = this.createTestOneToOneWithMultipleCascade(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOneToOneWithMultipleCascade(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); @@ -450,10 +450,10 @@ public class OneToOneTests extends JavaResourceModelTestCase { assertTrue(oneToOne.isCascadeRemove()); oneToOne.setCascadeMerge(false); - assertSourceContains("@OneToOne(cascade=REMOVE)"); + assertSourceContains("@OneToOne(cascade=REMOVE)", cu); oneToOne.setCascadeRemove(false); - assertSourceDoesNotContain("cascade"); + assertSourceDoesNotContain("cascade", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java index de632cd990..e0c6799995 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OrderByTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -23,7 +23,7 @@ public class OrderByTests extends JavaResourceModelTestCase { super(name); } - private IType createTestOrderBy() throws Exception { + private ICompilationUnit createTestOrderBy() throws Exception { this.createAnnotationAndMembers("OrderBy", "String value() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -37,7 +37,7 @@ public class OrderByTests extends JavaResourceModelTestCase { }); } - private IType createTestOrderByWithValue() throws Exception { + private ICompilationUnit createTestOrderByWithValue() throws Exception { this.createAnnotationAndMembers("OrderBy", "String value() default \"\";"); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -52,8 +52,8 @@ public class OrderByTests extends JavaResourceModelTestCase { } public void testOrderBy() throws Exception { - IType testType = this.createTestOrderBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOrderBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY); @@ -61,8 +61,8 @@ public class OrderByTests extends JavaResourceModelTestCase { } public void testGetValue() throws Exception { - IType testType = this.createTestOrderByWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOrderByWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY); @@ -70,19 +70,19 @@ public class OrderByTests extends JavaResourceModelTestCase { } public void testSetValue() throws Exception { - IType testType = this.createTestOrderBy(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestOrderBy(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OrderByAnnotation orderBy = (OrderByAnnotation) attributeResource.getAnnotation(JPA.ORDER_BY); orderBy.setValue("foo"); - assertSourceContains("@OrderBy(\"foo\")"); + assertSourceContains("@OrderBy(\"foo\")", cu); orderBy.setValue(null); - assertSourceContains("@OrderBy"); + assertSourceContains("@OrderBy", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java index 2028b86516..40819510d0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -34,7 +34,7 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { "String columnDefinition() default \"\"; "); } - private IType createTestPrimaryKeyJoinColumn() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumn() throws Exception { createPrimaryKeyJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -48,7 +48,7 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithName() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithName() throws Exception { createPrimaryKeyJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -62,7 +62,7 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception { createPrimaryKeyJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -76,7 +76,7 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception { createPrimaryKeyJoinColumnAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -91,8 +91,8 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); assertNotNull(column); @@ -100,8 +100,8 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); assertNotNull(column); @@ -110,8 +110,8 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); @@ -121,12 +121,12 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@PrimaryKeyJoinColumn(name=\"Foo\")"); + assertSourceContains("@PrimaryKeyJoinColumn(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); @@ -135,22 +135,22 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } public void testGetReferencedColumnName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName()); } public void testSetReferencedColumnName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); @@ -160,24 +160,24 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { column.setReferencedColumnName("Foo"); assertEquals("Foo", column.getReferencedColumnName()); - assertSourceContains("@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\")"); + assertSourceContains("@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\")", cu); column.setReferencedColumnName(null); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); @@ -187,11 +187,11 @@ public class PrimaryKeyJoinColumnTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@PrimaryKeyJoinColumn(columnDefinition=\"Foo\")"); + assertSourceContains("@PrimaryKeyJoinColumn(columnDefinition=\"Foo\")", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java index ffd8d50e9a..a0a2d00e71 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/PrimaryKeyJoinColumnsTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -42,7 +42,7 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { "PrimaryKeyJoinColumn[] value();"); } - private IType createTestPrimaryKeyJoinColumns() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumns() throws Exception { createPrimaryKeyJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -56,7 +56,7 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithName() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithName() throws Exception { createPrimaryKeyJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -70,7 +70,7 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithReferencedColumnName() throws Exception { createPrimaryKeyJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -84,7 +84,7 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumnWithColumnDefinition() throws Exception { createPrimaryKeyJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -98,7 +98,7 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { }); } - private IType createTestPrimaryKeyJoinColumn() throws Exception { + private ICompilationUnit createTestPrimaryKeyJoinColumn() throws Exception { createPrimaryKeyJoinColumnsAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -113,8 +113,8 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); assertNotNull(column); @@ -122,8 +122,8 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); assertNotNull(column); @@ -133,8 +133,8 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); @@ -144,12 +144,12 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { column.setName("Foo"); assertEquals("Foo", column.getName()); - assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(name=\"Foo\"))"); + assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(name=\"Foo\"))", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); @@ -158,20 +158,20 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { column.setName(null); assertNull(column.getName()); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } public void testGetReferencedColumnName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithReferencedColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); assertEquals(COLUMN_REFERENCED_COLUMN_NAME, column.getReferencedColumnName()); } public void testSetReferencedColumnName() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); @@ -181,24 +181,24 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { column.setReferencedColumnName("Foo"); assertEquals("Foo", column.getReferencedColumnName()); - assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\"))"); + assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(referencedColumnName=\"Foo\"))", cu); column.setReferencedColumnName(null); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } public void testGetColumnDefinition() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumnWithColumnDefinition(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumnWithColumnDefinition(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); assertEquals(COLUMN_COLUMN_DEFINITION, column.getColumnDefinition()); } public void testSetColumnDefinition() throws Exception { - IType testType = this.createTestPrimaryKeyJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestPrimaryKeyJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation column = (PrimaryKeyJoinColumnAnnotation) attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS).next(); @@ -208,39 +208,39 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { column.setColumnDefinition("Foo"); assertEquals("Foo", column.getColumnDefinition()); - assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(columnDefinition=\"Foo\"))"); + assertSourceContains("@PrimaryKeyJoinColumns(@PrimaryKeyJoinColumn(columnDefinition=\"Foo\"))", cu); column.setColumnDefinition(null); - assertSourceDoesNotContain("@PrimaryKeyJoinColumn"); + assertSourceDoesNotContain("@PrimaryKeyJoinColumn", cu); } public void testAddPrimaryKeyJoinColumnCopyExisting() throws Exception { - IType jdtType = createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})", cu); assertNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); assertNotNull(attributeResource.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMNS)); assertEquals(2, CollectionTools.size(attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS))); } public void testAddPrimaryKeyJoinColumnToBeginningOfList() throws Exception { - IType jdtType = createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})", cu); joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(0, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("BAZ"); - assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAZ\"),@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"), @PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAZ\"),@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"), @PrimaryKeyJoinColumn(name=\"FOO\")})", cu); Iterator<JavaResourceNode> pkJoinColumns = attributeResource.annotations(JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); assertEquals("BAZ", ((PrimaryKeyJoinColumnAnnotation) pkJoinColumns.next()).getName()); @@ -253,16 +253,16 @@ public class PrimaryKeyJoinColumnsTests extends JavaResourceModelTestCase { } public void testRemovePrimaryKeyJoinColumnCopyExisting() throws Exception { - IType jdtType = createTestPrimaryKeyJoinColumn(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestPrimaryKeyJoinColumn(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); PrimaryKeyJoinColumnAnnotation joinColumn = (PrimaryKeyJoinColumnAnnotation) attributeResource.addAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); joinColumn.setName("FOO"); - assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@PrimaryKeyJoinColumns({@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\"),@PrimaryKeyJoinColumn(name=\"FOO\")})", cu); attributeResource.removeAnnotation(1, JPA.PRIMARY_KEY_JOIN_COLUMN, JPA.PRIMARY_KEY_JOIN_COLUMNS); - assertSourceContains("@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\")"); + assertSourceContains("@PrimaryKeyJoinColumn(name=\"BAR\", columnDefinition = \"COLUMN_DEF\", referencedColumnName = \"REF_NAME\")", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java index 7814d2806a..65d72116c9 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/QueryHintTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; @@ -38,7 +38,7 @@ public class QueryHintTests extends JavaResourceModelTestCase { "String value();"); } - private IType createTestNamedQueryWithQueryHints() throws Exception { + private ICompilationUnit createTestNamedQueryWithQueryHints() throws Exception { createNamedQueryAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -53,8 +53,8 @@ public class QueryHintTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); QueryHintAnnotation queryHint = namedQuery.hints().next(); @@ -62,8 +62,8 @@ public class QueryHintTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestNamedQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestNamedQueryWithQueryHints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); NamedQueryAnnotation namedQuery = (NamedQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_QUERY); QueryHintAnnotation queryHint = namedQuery.hints().next(); @@ -72,6 +72,6 @@ public class QueryHintTests extends JavaResourceModelTestCase { queryHint.setName("foo"); assertEquals("foo", queryHint.getName()); - assertSourceContains("@QueryHint(name=\"foo\", value=\"" + QUERY_HINT_VALUE + "\")"); + assertSourceContains("@QueryHint(name=\"foo\", value=\"" + QUERY_HINT_VALUE + "\")", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java index b3b0d7ec11..9128356b53 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTableTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; @@ -46,7 +46,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { "UniqueConstraint[] uniqueConstraints() default {};"); } - private IType createTestSecondaryTable() throws Exception { + private ICompilationUnit createTestSecondaryTable() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -60,7 +60,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTableWithName() throws Exception { + private ICompilationUnit createTestSecondaryTableWithName() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -74,7 +74,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTableWithSchema() throws Exception { + private ICompilationUnit createTestSecondaryTableWithSchema() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -87,7 +87,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } }); } - private IType createTestSecondaryTableWithCatalog() throws Exception { + private ICompilationUnit createTestSecondaryTableWithCatalog() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -102,7 +102,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } - private IType createTestSecondaryTableWithUniqueConstraints() throws Exception { + private ICompilationUnit createTestSecondaryTableWithUniqueConstraints() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -116,7 +116,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTableWithPkJoinColumns() throws Exception { + private ICompilationUnit createTestSecondaryTableWithPkJoinColumns() throws Exception { createSecondaryTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -131,8 +131,8 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestSecondaryTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -140,8 +140,8 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -151,8 +151,8 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -161,12 +161,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setName("Foo"); assertEquals("Foo", table.getName()); - assertSourceContains("@SecondaryTable(name=\"Foo\")"); + assertSourceContains("@SecondaryTable(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestSecondaryTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(TABLE_NAME, table.getName()); @@ -174,12 +174,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setName(null); assertNull(table.getName()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testGetCatalog() throws Exception { - IType testType = this.createTestSecondaryTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -187,8 +187,8 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testSetCatalog() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -197,12 +197,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setCatalog("Foo"); assertEquals("Foo", table.getCatalog()); - assertSourceContains("@SecondaryTable(catalog=\"Foo\")"); + assertSourceContains("@SecondaryTable(catalog=\"Foo\")", cu); } public void testSetCatalogNull() throws Exception { - IType testType = this.createTestSecondaryTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(CATALOG_NAME, table.getCatalog()); @@ -210,12 +210,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setCatalog(null); assertNull(table.getCatalog()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testGetSchema() throws Exception { - IType testType = this.createTestSecondaryTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -223,8 +223,8 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testSetSchema() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNotNull(table); @@ -233,12 +233,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setSchema("Foo"); assertEquals("Foo", table.getSchema()); - assertSourceContains("@SecondaryTable(schema=\"Foo\")"); + assertSourceContains("@SecondaryTable(schema=\"Foo\")", cu); } public void testSetSchemaNull() throws Exception { - IType testType = this.createTestSecondaryTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(SCHEMA_NAME, table.getSchema()); @@ -246,21 +246,21 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { table.setSchema(null); assertNull(table.getSchema()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testUniqueConstraints() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(0, table.uniqueConstraintsSize()); } public void testUniqueConstraints2() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.addUniqueConstraint(0); @@ -270,16 +270,16 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testUniqueConstraints3() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(3, table.uniqueConstraintsSize()); } public void testAddUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.addUniqueConstraint(0).addColumnName("FOO"); @@ -290,12 +290,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next()); assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize()); - assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})"); + assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})", cu); } public void testRemoveUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.removeUniqueConstraint(1); @@ -303,23 +303,23 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { assertEquals("BAR", uniqueConstraints.next().columnNames().next()); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); - assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); table.removeUniqueConstraint(0); uniqueConstraints = table.uniqueConstraints(); assertEquals("BAZ", uniqueConstraints.next().columnNames().next()); assertFalse(uniqueConstraints.hasNext()); - assertSourceContains("@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))"); + assertSourceContains("@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))", cu); table.removeUniqueConstraint(0); uniqueConstraints = table.uniqueConstraints(); assertFalse(uniqueConstraints.hasNext()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testMoveUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next()); @@ -332,12 +332,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { assertEquals("BAZ", secondaryTable.uniqueConstraintAt(1).columnNames().next()); assertEquals("BAR", secondaryTable.uniqueConstraintAt(2).columnNames().next()); assertEquals(3, secondaryTable.uniqueConstraintsSize()); - assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})"); + assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})", cu); } public void testMoveUniqueConstraint2() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next()); @@ -350,21 +350,21 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { assertEquals("BAR", secondaryTable.uniqueConstraintAt(1).columnNames().next()); assertEquals("FOO", secondaryTable.uniqueConstraintAt(2).columnNames().next()); assertEquals(3, secondaryTable.uniqueConstraintsSize()); - assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})"); + assertSourceContains("@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})", cu); } public void testPkJoinColumns() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(0, table.pkJoinColumnsSize()); } public void testPkJoinColumns2() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.addPkJoinColumn(0); @@ -374,16 +374,16 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { } public void testPkJoinColumns3() throws Exception { - IType testType = this.createTestSecondaryTableWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(3, table.pkJoinColumnsSize()); } public void testAddPkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); @@ -396,39 +396,39 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.pkJoinColumnAt(2).getName()); assertEquals(3, table.pkJoinColumnsSize()); - assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn, @PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn, @PrimaryKeyJoinColumn(name=\"FOO\")})", cu); } public void testRemovePkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTableWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); table.removePkJoinColumn(1); - assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})", cu); table.removePkJoinColumn(0); - assertSourceContains("@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\"))"); + assertSourceContains("@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\"))", cu); table.removePkJoinColumn(0); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testMovePkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTableWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0); joinColumn.setReferencedColumnName("REF_NAME"); joinColumn.setColumnDefinition("COLUMN_DEF"); table.movePkJoinColumn(2, 0); - assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")})"); + assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")})", cu); } public void testMovePkJoinColumn2() throws Exception { - IType testType = this.createTestSecondaryTableWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); @@ -436,12 +436,12 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { joinColumn.setReferencedColumnName("REF_NAME"); joinColumn.setColumnDefinition("COLUMN_DEF"); table.movePkJoinColumn(0, 2); - assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")})"); + assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")})", cu); } public void testSetPkJoinColumnName() throws Exception { - IType testType = this.createTestSecondaryTableWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertEquals(3, table.pkJoinColumnsSize()); @@ -453,7 +453,7 @@ public class SecondaryTableTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})"); + assertSourceContains("@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java index e312d5664f..807daefd6e 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -54,7 +54,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { this.createAnnotationAndMembers("SecondaryTables", "SecondaryTable[] value()"); } - private IType createTestSecondaryTables() throws Exception { + private ICompilationUnit createTestSecondaryTables() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -68,7 +68,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTableWithName() throws Exception { + private ICompilationUnit createTestSecondaryTableWithName() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -82,7 +82,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTableWithSchema() throws Exception { + private ICompilationUnit createTestSecondaryTableWithSchema() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -95,7 +95,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } }); } - private IType createTestSecondaryTableWithCatalog() throws Exception { + private ICompilationUnit createTestSecondaryTableWithCatalog() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -110,7 +110,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } - private IType createTestSecondaryTableWithUniqueConstraints() throws Exception { + private ICompilationUnit createTestSecondaryTableWithUniqueConstraints() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -124,7 +124,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTable() throws Exception { + private ICompilationUnit createTestSecondaryTable() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -140,7 +140,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { }); } - private IType createTestSecondaryTablesWithPkJoinColumns() throws Exception { + private ICompilationUnit createTestSecondaryTablesWithPkJoinColumns() throws Exception { createSecondaryTablesAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -155,8 +155,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestSecondaryTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLE); assertNull(table); @@ -168,8 +168,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -179,8 +179,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -190,12 +190,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setName("Foo"); assertEquals("Foo", secondaryTable.getName()); - assertSourceContains("@SecondaryTables(@SecondaryTable(name=\"Foo\"))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(name=\"Foo\"))", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestSecondaryTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -204,12 +204,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setName(null); assertNull(secondaryTable.getName()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testGetCatalog() throws Exception { - IType testType = this.createTestSecondaryTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -217,8 +217,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testSetCatalog() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -227,12 +227,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setCatalog("Foo"); assertEquals("Foo", secondaryTable.getCatalog()); - assertSourceContains("@SecondaryTables(@SecondaryTable(catalog=\"Foo\"))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(catalog=\"Foo\"))", cu); } public void testSetCatalogNull() throws Exception { - IType testType = this.createTestSecondaryTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -241,12 +241,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setCatalog(null); assertNull(secondaryTable.getCatalog()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testGetSchema() throws Exception { - IType testType = this.createTestSecondaryTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -255,8 +255,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testSetSchema() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -265,12 +265,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setSchema("Foo"); assertEquals("Foo", secondaryTable.getSchema()); - assertSourceContains("@SecondaryTables(@SecondaryTable(schema=\"Foo\"))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(schema=\"Foo\"))", cu); } public void testSetSchemaNull() throws Exception { - IType testType = this.createTestSecondaryTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -279,13 +279,13 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { secondaryTable.setSchema(null); assertNull(secondaryTable.getSchema()); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testUniqueConstraints() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -293,8 +293,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testUniqueConstraints2() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -305,8 +305,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testUniqueConstraints3() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -314,8 +314,8 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testAddUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); @@ -327,29 +327,29 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next()); assertEquals(0, secondaryTable.uniqueConstraintAt(2).columnNamesSize()); - assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint}))", cu); } public void testRemoveUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); secondaryTable.removeUniqueConstraint(2); - assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})})"); + assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})})", cu); secondaryTable.removeUniqueConstraint(0); - assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAR\"}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints=@UniqueConstraint(columnNames={\"BAR\"}))", cu); secondaryTable.removeUniqueConstraint(0); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testMoveUniqueConstraint() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); @@ -362,12 +362,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { assertEquals("BAR", secondaryTable.uniqueConstraintAt(0).columnNames().next()); assertFalse(secondaryTable.uniqueConstraintAt(1).columnNames().hasNext()); assertEquals("FOO", secondaryTable.uniqueConstraintAt(2).columnNames().next()); - assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\")}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\")}))", cu); } public void testMoveUniqueConstraint2() throws Exception { - IType testType = this.createTestSecondaryTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getAnnotation(JPA.SECONDARY_TABLES); SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); @@ -380,19 +380,19 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { assertFalse(secondaryTable.uniqueConstraintAt(0).columnNames().hasNext()); assertEquals("FOO", secondaryTable.uniqueConstraintAt(1).columnNames().next()); assertEquals("BAR", secondaryTable.uniqueConstraintAt(2).columnNames().next()); - assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(uniqueConstraints={@UniqueConstraint, @UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint(columnNames={\"BAR\"})}))", cu); } // @Entity -->> @Entity // @SecondaryTable(name="FOO") @SecondaryTables({@SecondaryTable(name="FOO"), @SecondaryTable(name="BAR")}) public void testAddSecondaryTableCopyExisting() throws Exception { - IType jdtType = createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})", cu); assertNull(typeResource.getAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getAnnotation(JPA.SECONDARY_TABLES)); @@ -400,16 +400,16 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testAddSecondaryTable() throws Exception { - IType jdtType = createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})", cu); secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")), @SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"BAZ\"),@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")), @SecondaryTable(name=\"BAR\")})", cu); Iterator<JavaResourceNode> secondaryTables = typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTables.next()).getName()); @@ -422,29 +422,29 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testRemoveSecondaryTableCopyExisting() throws Exception { - IType jdtType = createTestSecondaryTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(jdtType); + ICompilationUnit cu = createTestSecondaryTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})"); + assertSourceContains("@SecondaryTables({@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\")),@SecondaryTable(name=\"BAR\")})", cu); typeResource.removeAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\"))"); + assertSourceContains("@SecondaryTable(name=\"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames=\"BAR\"))", cu); } public void testPkJoinColumns() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); assertEquals(0, table.pkJoinColumnsSize()); } public void testPkJoinColumns2() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); table.addPkJoinColumn(0); @@ -454,54 +454,54 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { } public void testPkJoinColumns3() throws Exception { - IType testType = this.createTestSecondaryTablesWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTablesWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); assertEquals(3, table.pkJoinColumnsSize()); } public void testAddPkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTables(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTables(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); table.addPkJoinColumn(0).setName("FOO"); table.addPkJoinColumn(1); table.addPkJoinColumn(0).setName("BAR"); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"),@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn}))", cu); } public void testRemovePkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTablesWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTablesWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); table.removePkJoinColumn(1); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAR\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))", cu); table.removePkJoinColumn(0); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\")))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns=@PrimaryKeyJoinColumn(name=\"BAZ\")))", cu); table.removePkJoinColumn(0); - assertSourceDoesNotContain("@SecondaryTable"); + assertSourceDoesNotContain("@SecondaryTable", cu); } public void testMovePkJoinColumn() throws Exception { - IType testType = this.createTestSecondaryTablesWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTablesWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); PrimaryKeyJoinColumnAnnotation joinColumn = table.pkJoinColumnAt(0); joinColumn.setReferencedColumnName("REF_NAME"); joinColumn.setColumnDefinition("COLUMN_DEF"); table.movePkJoinColumn(2, 0); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\")}))", cu); } public void testMovePkJoinColumn2() throws Exception { - IType testType = this.createTestSecondaryTablesWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTablesWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); @@ -509,12 +509,12 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { joinColumn.setReferencedColumnName("REF_NAME"); joinColumn.setColumnDefinition("COLUMN_DEF"); table.movePkJoinColumn(0, 2); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"BAZ\"), @PrimaryKeyJoinColumn(name=\"BAR\", referencedColumnName = \"REF_NAME\", columnDefinition = \"COLUMN_DEF\"), @PrimaryKeyJoinColumn(name=\"FOO\")}))", cu); } public void testSetPkJoinColumnName() throws Exception { - IType testType = this.createTestSecondaryTablesWithPkJoinColumns(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSecondaryTablesWithPkJoinColumns(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTableAnnotation table = (SecondaryTableAnnotation) typeResource.annotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES).next(); assertEquals(3, table.pkJoinColumnsSize()); @@ -526,7 +526,7 @@ public class SecondaryTablesTests extends JavaResourceModelTestCase { joinColumn.setName("foo"); assertEquals("foo", joinColumn.getName()); - assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))"); + assertSourceContains("@SecondaryTables(@SecondaryTable(pkJoinColumns={@PrimaryKeyJoinColumn(name=\"foo\"), @PrimaryKeyJoinColumn(name=\"FOO\"), @PrimaryKeyJoinColumn(name=\"BAZ\")}))", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java index a38abc0603..e209c4cd53 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SequenceGeneratorTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -35,7 +35,7 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { "int allocationSize() default 50"); } - private IType createTestSequenceGeneratorOnField() throws Exception { + private ICompilationUnit createTestSequenceGeneratorOnField() throws Exception { createSequenceGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -49,7 +49,7 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestSequenceGeneratorOnType() throws Exception { + private ICompilationUnit createTestSequenceGeneratorOnType() throws Exception { createSequenceGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -63,15 +63,15 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestSequenceGeneratorWithName() throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithName() throws Exception { return createTestSequenceGeneratorWithStringElement("name", GENERATOR_NAME); } - private IType createTestSequenceGeneratorWithSequenceName() throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithSequenceName() throws Exception { return createTestSequenceGeneratorWithStringElement("sequenceName", GENERATOR_SEQUENCE_NAME); } - private IType createTestSequenceGeneratorWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithStringElement(final String elementName, final String value) throws Exception { createSequenceGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -85,15 +85,15 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestSequenceGeneratorWithAllocationSize() throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithAllocationSize() throws Exception { return createTestSequenceGeneratorWithIntElement("allocationSize", GENERATOR_ALLOCATION_SIZE); } - private IType createTestSequenceGeneratorWithInitialValue() throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithInitialValue() throws Exception { return createTestSequenceGeneratorWithIntElement("initialValue", GENERATOR_INITIAL_VALUE); } - private IType createTestSequenceGeneratorWithIntElement(final String elementName, final int value) throws Exception { + private ICompilationUnit createTestSequenceGeneratorWithIntElement(final String elementName, final int value) throws Exception { createSequenceGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -108,8 +108,8 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSequenceGeneratorOnField() throws Exception { - IType testType = this.createTestSequenceGeneratorOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -117,16 +117,16 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSequenceGeneratorOnType() throws Exception { - IType testType = this.createTestSequenceGeneratorOnType(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorOnType(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) typeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); assertNotNull(sequenceGenerator); } public void testGetName() throws Exception { - IType testType = this.createTestSequenceGeneratorWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -134,8 +134,8 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestSequenceGeneratorWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -144,17 +144,17 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { sequenceGenerator.setName("foo"); assertEquals("foo", sequenceGenerator.getName()); - assertSourceContains("@SequenceGenerator(name=\"foo\")"); + assertSourceContains("@SequenceGenerator(name=\"foo\")", cu); sequenceGenerator.setName(null); assertNull(sequenceGenerator.getName()); - assertSourceDoesNotContain("@SequenceGenerator"); + assertSourceDoesNotContain("@SequenceGenerator", cu); } public void testGetSequenceName() throws Exception { - IType testType = this.createTestSequenceGeneratorWithSequenceName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithSequenceName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -162,8 +162,8 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSetSequenceName() throws Exception { - IType testType = this.createTestSequenceGeneratorWithSequenceName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithSequenceName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -172,17 +172,17 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { sequenceGenerator.setSequenceName("foo"); assertEquals("foo", sequenceGenerator.getSequenceName()); - assertSourceContains("@SequenceGenerator(sequenceName=\"foo\")"); + assertSourceContains("@SequenceGenerator(sequenceName=\"foo\")", cu); sequenceGenerator.setSequenceName(null); assertNull(sequenceGenerator.getSequenceName()); - assertSourceDoesNotContain("@SequenceGenerator"); + assertSourceDoesNotContain("@SequenceGenerator", cu); } public void testGetAllocationSize() throws Exception { - IType testType = this.createTestSequenceGeneratorWithAllocationSize(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithAllocationSize(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -190,8 +190,8 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSetAllocationSize() throws Exception { - IType testType = this.createTestSequenceGeneratorWithAllocationSize(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithAllocationSize(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -200,19 +200,19 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { sequenceGenerator.setAllocationSize(Integer.valueOf(500)); assertEquals(Integer.valueOf(500), sequenceGenerator.getAllocationSize()); - assertSourceContains("@SequenceGenerator(allocationSize=500)"); + assertSourceContains("@SequenceGenerator(allocationSize=500)", cu); sequenceGenerator.setAllocationSize(null); - assertSourceDoesNotContain("@SequenceGenerator"); + assertSourceDoesNotContain("@SequenceGenerator", cu); sequenceGenerator.setAllocationSize(Integer.valueOf(0)); - assertSourceContains("@SequenceGenerator(allocationSize=0)"); + assertSourceContains("@SequenceGenerator(allocationSize=0)", cu); } public void testGetInitialValue() throws Exception { - IType testType = this.createTestSequenceGeneratorWithInitialValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithInitialValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -220,8 +220,8 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { } public void testSetInitialValue() throws Exception { - IType testType = this.createTestSequenceGeneratorWithInitialValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestSequenceGeneratorWithInitialValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); SequenceGeneratorAnnotation sequenceGenerator = (SequenceGeneratorAnnotation) attributeResource.getAnnotation(JPA.SEQUENCE_GENERATOR); @@ -230,13 +230,13 @@ public class SequenceGeneratorTests extends JavaResourceModelTestCase { sequenceGenerator.setInitialValue(Integer.valueOf(500)); assertEquals(Integer.valueOf(500), sequenceGenerator.getInitialValue()); - assertSourceContains("@SequenceGenerator(initialValue=500)"); + assertSourceContains("@SequenceGenerator(initialValue=500)", cu); sequenceGenerator.setInitialValue(null); - assertSourceDoesNotContain("@SequenceGenerator"); + assertSourceDoesNotContain("@SequenceGenerator", cu); sequenceGenerator.setInitialValue(Integer.valueOf(0)); - assertSourceContains("@SequenceGenerator(initialValue=0)"); + assertSourceContains("@SequenceGenerator(initialValue=0)", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java index 625057b216..b12c6387f8 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableGeneratorTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -46,7 +46,7 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { "UniqueConstraint[] uniqueConstraints() default{}"); } - private IType createTestTableGeneratorOnField() throws Exception { + private ICompilationUnit createTestTableGeneratorOnField() throws Exception { createTableGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -60,7 +60,7 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestTableGeneratorOnType() throws Exception { + private ICompilationUnit createTestTableGeneratorOnType() throws Exception { createTableGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -74,34 +74,34 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestTableGeneratorWithName() throws Exception { + private ICompilationUnit createTestTableGeneratorWithName() throws Exception { return createTestTableGeneratorWithStringElement("name", GENERATOR_NAME); } - private IType createTestTableGeneratorWithTable() throws Exception { + private ICompilationUnit createTestTableGeneratorWithTable() throws Exception { return createTestTableGeneratorWithStringElement("table", GENERATOR_TABLE); } - private IType createTestTableGeneratorWithCatalog() throws Exception { + private ICompilationUnit createTestTableGeneratorWithCatalog() throws Exception { return createTestTableGeneratorWithStringElement("catalog", GENERATOR_CATALOG); } - private IType createTestTableGeneratorWithSchema() throws Exception { + private ICompilationUnit createTestTableGeneratorWithSchema() throws Exception { return createTestTableGeneratorWithStringElement("schema", GENERATOR_SCHEMA); } - private IType createTestTableGeneratorWithPkColumnName() throws Exception { + private ICompilationUnit createTestTableGeneratorWithPkColumnName() throws Exception { return createTestTableGeneratorWithStringElement("pkColumnName", GENERATOR_PK_COLUMN_NAME); } - private IType createTestTableGeneratorWithValueColumnName() throws Exception { + private ICompilationUnit createTestTableGeneratorWithValueColumnName() throws Exception { return createTestTableGeneratorWithStringElement("valueColumnName", GENERATOR_VALUE_COLUMN_NAME); } - private IType createTestTableGeneratorWithPkColumnValue() throws Exception { + private ICompilationUnit createTestTableGeneratorWithPkColumnValue() throws Exception { return createTestTableGeneratorWithStringElement("pkColumnValue", GENERATOR_PK_COLUMN_VALUE); } - private IType createTestTableGeneratorWithStringElement(final String elementName, final String value) throws Exception { + private ICompilationUnit createTestTableGeneratorWithStringElement(final String elementName, final String value) throws Exception { createTableGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -115,15 +115,15 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestTableGeneratorWithAllocationSize() throws Exception { + private ICompilationUnit createTestTableGeneratorWithAllocationSize() throws Exception { return createTestTableGeneratorWithIntElement("allocationSize", GENERATOR_ALLOCATION_SIZE); } - private IType createTestTableGeneratorWithInitialValue() throws Exception { + private ICompilationUnit createTestTableGeneratorWithInitialValue() throws Exception { return createTestTableGeneratorWithIntElement("initialValue", GENERATOR_INITIAL_VALUE); } - private IType createTestTableGeneratorWithIntElement(final String elementName, final int value) throws Exception { + private ICompilationUnit createTestTableGeneratorWithIntElement(final String elementName, final int value) throws Exception { createTableGeneratorAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -137,7 +137,7 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { }); } - private IType createTestTableGeneratorWithUniqueConstraints() throws Exception { + private ICompilationUnit createTestTableGeneratorWithUniqueConstraints() throws Exception { createTableGeneratorAnnotation(); this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();"); return this.createTestType(new DefaultAnnotationWriter() { @@ -153,8 +153,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testTableGeneratorOnField() throws Exception { - IType testType = this.createTestTableGeneratorOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -162,16 +162,16 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testTableGeneratorOnType() throws Exception { - IType testType = this.createTestTableGeneratorOnType(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorOnType(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) typeResource.getAnnotation(JPA.TABLE_GENERATOR); assertNotNull(tableGenerator); } public void testGetName() throws Exception { - IType testType = this.createTestTableGeneratorWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -179,8 +179,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestTableGeneratorWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -189,17 +189,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setName("foo"); assertEquals("foo", tableGenerator.getName()); - assertSourceContains("@TableGenerator(name=\"foo\")"); + assertSourceContains("@TableGenerator(name=\"foo\")", cu); tableGenerator.setName(null); assertNull(tableGenerator.getName()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetTable() throws Exception { - IType testType = this.createTestTableGeneratorWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -207,8 +207,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetTable() throws Exception { - IType testType = this.createTestTableGeneratorWithTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -217,17 +217,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setTable("foo"); assertEquals("foo", tableGenerator.getTable()); - assertSourceContains("@TableGenerator(table=\"foo\")"); + assertSourceContains("@TableGenerator(table=\"foo\")", cu); tableGenerator.setTable(null); assertNull(tableGenerator.getTable()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetCatalog() throws Exception { - IType testType = this.createTestTableGeneratorWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -235,8 +235,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetCatalog() throws Exception { - IType testType = this.createTestTableGeneratorWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -245,17 +245,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setCatalog("foo"); assertEquals("foo", tableGenerator.getCatalog()); - assertSourceContains("@TableGenerator(catalog=\"foo\")"); + assertSourceContains("@TableGenerator(catalog=\"foo\")", cu); tableGenerator.setCatalog(null); assertNull(tableGenerator.getCatalog()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetSchema() throws Exception { - IType testType = this.createTestTableGeneratorWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -263,8 +263,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetSchema() throws Exception { - IType testType = this.createTestTableGeneratorWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -273,17 +273,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setSchema("foo"); assertEquals("foo", tableGenerator.getSchema()); - assertSourceContains("@TableGenerator(schema=\"foo\")"); + assertSourceContains("@TableGenerator(schema=\"foo\")", cu); tableGenerator.setSchema(null); assertNull(tableGenerator.getSchema()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetPkColumnName() throws Exception { - IType testType = this.createTestTableGeneratorWithPkColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithPkColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -291,8 +291,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetPkColumnName() throws Exception { - IType testType = this.createTestTableGeneratorWithPkColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithPkColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -301,17 +301,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setPkColumnName("foo"); assertEquals("foo", tableGenerator.getPkColumnName()); - assertSourceContains("@TableGenerator(pkColumnName=\"foo\")"); + assertSourceContains("@TableGenerator(pkColumnName=\"foo\")", cu); tableGenerator.setPkColumnName(null); assertNull(tableGenerator.getPkColumnName()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetValueColumnName() throws Exception { - IType testType = this.createTestTableGeneratorWithValueColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithValueColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -319,8 +319,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetValueColumnName() throws Exception { - IType testType = this.createTestTableGeneratorWithValueColumnName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithValueColumnName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -329,17 +329,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setValueColumnName("foo"); assertEquals("foo", tableGenerator.getValueColumnName()); - assertSourceContains("@TableGenerator(valueColumnName=\"foo\")"); + assertSourceContains("@TableGenerator(valueColumnName=\"foo\")", cu); tableGenerator.setValueColumnName(null); assertNull(tableGenerator.getValueColumnName()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetPkColumnValue() throws Exception { - IType testType = this.createTestTableGeneratorWithPkColumnValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithPkColumnValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -347,8 +347,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetPkColumnValue() throws Exception { - IType testType = this.createTestTableGeneratorWithPkColumnValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithPkColumnValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -357,17 +357,17 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setPkColumnValue("foo"); assertEquals("foo", tableGenerator.getPkColumnValue()); - assertSourceContains("@TableGenerator(pkColumnValue=\"foo\")"); + assertSourceContains("@TableGenerator(pkColumnValue=\"foo\")", cu); tableGenerator.setPkColumnValue(null); assertNull(tableGenerator.getPkColumnValue()); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testGetAllocationSize() throws Exception { - IType testType = this.createTestTableGeneratorWithAllocationSize(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithAllocationSize(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -375,8 +375,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetAllocationSize() throws Exception { - IType testType = this.createTestTableGeneratorWithAllocationSize(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithAllocationSize(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -385,19 +385,19 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setAllocationSize(Integer.valueOf(500)); assertEquals(Integer.valueOf(500), tableGenerator.getAllocationSize()); - assertSourceContains("@TableGenerator(allocationSize=500)"); + assertSourceContains("@TableGenerator(allocationSize=500)", cu); tableGenerator.setAllocationSize(null); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); tableGenerator.setAllocationSize(Integer.valueOf(0)); - assertSourceContains("@TableGenerator(allocationSize=0)"); + assertSourceContains("@TableGenerator(allocationSize=0)", cu); } public void testGetInitialValue() throws Exception { - IType testType = this.createTestTableGeneratorWithInitialValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithInitialValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -405,8 +405,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testSetInitialValue() throws Exception { - IType testType = this.createTestTableGeneratorWithInitialValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithInitialValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -415,19 +415,19 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { tableGenerator.setInitialValue(Integer.valueOf(500)); assertEquals(Integer.valueOf(500), tableGenerator.getInitialValue()); - assertSourceContains("@TableGenerator(initialValue=500)"); + assertSourceContains("@TableGenerator(initialValue=500)", cu); tableGenerator.setInitialValue(null); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); tableGenerator.setInitialValue(Integer.valueOf(0)); - assertSourceContains("@TableGenerator(initialValue=0)"); + assertSourceContains("@TableGenerator(initialValue=0)", cu); } public void testUniqueConstraints() throws Exception { - IType testType = this.createTestTableGeneratorOnField(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorOnField(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -436,9 +436,9 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testUniqueConstraints2() throws Exception { - IType testType = this.createTestTableGeneratorOnField(); + ICompilationUnit cu = this.createTestTableGeneratorOnField(); this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -450,8 +450,8 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testUniqueConstraints3() throws Exception { - IType testType = this.createTestTableGeneratorWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -460,9 +460,9 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { } public void testAddUniqueConstraint() throws Exception { - IType testType = this.createTestTableGeneratorOnField(); + ICompilationUnit cu = this.createTestTableGeneratorOnField(); this.createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();"); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); @@ -476,46 +476,46 @@ public class TableGeneratorTests extends JavaResourceModelTestCase { assertEquals(0, tableGenerator.uniqueConstraintAt(2).columnNamesSize()); assertEquals(3, tableGenerator.uniqueConstraintsSize()); - assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})"); + assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})", cu); } public void testRemoveUniqueConstraint() throws Exception { - IType testType = this.createTestTableGeneratorWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.removeUniqueConstraint(1); - assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); tableGenerator.removeUniqueConstraint(0); - assertSourceContains("@TableGenerator(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))"); + assertSourceContains("@TableGenerator(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))", cu); tableGenerator.removeUniqueConstraint(0); - assertSourceDoesNotContain("@TableGenerator"); + assertSourceDoesNotContain("@TableGenerator", cu); } public void testMoveUniqueConstraint() throws Exception { - IType testType = this.createTestTableGeneratorWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.moveUniqueConstraint(2, 0); - assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})"); + assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})", cu); } public void testMoveUniqueConstraint2() throws Exception { - IType testType = this.createTestTableGeneratorWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableGeneratorWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TableGeneratorAnnotation tableGenerator = (TableGeneratorAnnotation) attributeResource.getAnnotation(JPA.TABLE_GENERATOR); tableGenerator.moveUniqueConstraint(0, 2); - assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})"); + assertSourceContains("@TableGenerator(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java index 8b46d248d1..5495c4dbe6 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TableTests.java @@ -11,7 +11,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; import java.util.ListIterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.TableAnnotation; @@ -36,7 +36,7 @@ public class TableTests extends JavaResourceModelTestCase { createAnnotationAndMembers("UniqueConstraint", "String[] columnNames();"); } - private IType createTestTable() throws Exception { + private ICompilationUnit createTestTable() throws Exception { createTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -50,7 +50,7 @@ public class TableTests extends JavaResourceModelTestCase { }); } - private IType createTestTableWithName() throws Exception { + private ICompilationUnit createTestTableWithName() throws Exception { createTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -64,7 +64,7 @@ public class TableTests extends JavaResourceModelTestCase { }); } - private IType createTestTableWithSchema() throws Exception { + private ICompilationUnit createTestTableWithSchema() throws Exception { createTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -78,7 +78,7 @@ public class TableTests extends JavaResourceModelTestCase { }); } - private IType createTestTableWithCatalog() throws Exception { + private ICompilationUnit createTestTableWithCatalog() throws Exception { createTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -92,7 +92,7 @@ public class TableTests extends JavaResourceModelTestCase { }); } - private IType createTestTableWithUniqueConstraints() throws Exception { + private ICompilationUnit createTestTableWithUniqueConstraints() throws Exception { createTableAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -107,8 +107,8 @@ public class TableTests extends JavaResourceModelTestCase { } public void testGetName() throws Exception { - IType testType = this.createTestTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -116,8 +116,8 @@ public class TableTests extends JavaResourceModelTestCase { } public void testGetNull() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -127,8 +127,8 @@ public class TableTests extends JavaResourceModelTestCase { } public void testSetName() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -137,12 +137,12 @@ public class TableTests extends JavaResourceModelTestCase { table.setName("Foo"); assertEquals("Foo", table.getName()); - assertSourceContains("@Table(name=\"Foo\")"); + assertSourceContains("@Table(name=\"Foo\")", cu); } public void testSetNameNull() throws Exception { - IType testType = this.createTestTableWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithName(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals(TABLE_NAME, table.getName()); @@ -150,12 +150,12 @@ public class TableTests extends JavaResourceModelTestCase { table.setName(null); assertNull(table.getName()); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testGetCatalog() throws Exception { - IType testType = this.createTestTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -163,8 +163,8 @@ public class TableTests extends JavaResourceModelTestCase { } public void testSetCatalog() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -173,12 +173,12 @@ public class TableTests extends JavaResourceModelTestCase { table.setCatalog("Foo"); assertEquals("Foo", table.getCatalog()); - assertSourceContains("@Table(catalog=\"Foo\")"); + assertSourceContains("@Table(catalog=\"Foo\")", cu); } public void testSetCatalogNull() throws Exception { - IType testType = this.createTestTableWithCatalog(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithCatalog(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals(CATALOG_NAME, table.getCatalog()); @@ -186,12 +186,12 @@ public class TableTests extends JavaResourceModelTestCase { table.setCatalog(null); assertNull(table.getCatalog()); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testGetSchema() throws Exception { - IType testType = this.createTestTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -199,8 +199,8 @@ public class TableTests extends JavaResourceModelTestCase { } public void testSetSchema() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertNotNull(table); @@ -209,12 +209,12 @@ public class TableTests extends JavaResourceModelTestCase { table.setSchema("Foo"); assertEquals("Foo", table.getSchema()); - assertSourceContains("@Table(schema=\"Foo\")"); + assertSourceContains("@Table(schema=\"Foo\")", cu); } public void testSetSchemaNull() throws Exception { - IType testType = this.createTestTableWithSchema(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithSchema(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals(SCHEMA_NAME, table.getSchema()); @@ -222,20 +222,20 @@ public class TableTests extends JavaResourceModelTestCase { table.setSchema(null); assertNull(table.getSchema()); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testUniqueConstraints() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals(0, table.uniqueConstraintsSize()); } public void testUniqueConstraints2() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.addUniqueConstraint(0); @@ -245,16 +245,16 @@ public class TableTests extends JavaResourceModelTestCase { } public void testUniqueConstraints3() throws Exception { - IType testType = this.createTestTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); assertEquals(3, table.uniqueConstraintsSize()); } public void testAddUniqueConstraint() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.addUniqueConstraint(0).addColumnName("FOO"); @@ -265,12 +265,12 @@ public class TableTests extends JavaResourceModelTestCase { assertEquals("FOO", table.uniqueConstraintAt(1).columnNames().next()); assertEquals(0, table.uniqueConstraintAt(2).columnNamesSize()); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"FOO\"), @UniqueConstraint})", cu); } public void testAddUniqueConstraint2() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.addUniqueConstraint(0).addColumnName("FOO"); @@ -278,7 +278,7 @@ public class TableTests extends JavaResourceModelTestCase { table.addUniqueConstraint(1).addColumnName("BAR"); table.uniqueConstraintAt(1).addColumnName("BAZ"); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint,@UniqueConstraint(columnNames={ \"BAR\", \"BAZ\" }), @UniqueConstraint(columnNames=\"FOO\")})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint,@UniqueConstraint(columnNames={ \"BAR\", \"BAZ\" }), @UniqueConstraint(columnNames=\"FOO\")})", cu); assertEquals("FOO", table.uniqueConstraintAt(2).columnNames().next()); ListIterator<String> columnNames = table.uniqueConstraintAt(1).columnNames(); @@ -286,74 +286,74 @@ public class TableTests extends JavaResourceModelTestCase { assertEquals("BAZ", columnNames.next()); } public void testRemoveUniqueConstraint() throws Exception { - IType testType = this.createTestTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.removeUniqueConstraint(1); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"BAZ\"})})", cu); table.removeUniqueConstraint(0); - assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))"); + assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames={\"BAZ\"}))", cu); table.removeUniqueConstraint(0); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testRemoveUniqueConstraint2() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.addUniqueConstraint(0).addColumnName("FOO"); table.addUniqueConstraint(1).addColumnName("BAR"); table.addUniqueConstraint(2).addColumnName("BAZ"); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})", cu); table.removeUniqueConstraint(0); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"BAZ\")})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"BAR\"),@UniqueConstraint(columnNames=\"BAZ\")})", cu); table.removeUniqueConstraint(0); - assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"BAZ\"))"); + assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"BAZ\"))", cu); table.removeUniqueConstraint(0); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testRemoveUniqueConstraint3() throws Exception { - IType testType = this.createTestTable(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTable(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.addUniqueConstraint(0).addColumnName("FOO"); table.addUniqueConstraint(1).addColumnName("BAR"); table.addUniqueConstraint(2).addColumnName("BAZ"); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\"), @UniqueConstraint(columnNames=\"BAZ\")})", cu); table.removeUniqueConstraint(2); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\")})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames=\"FOO\"),@UniqueConstraint(columnNames=\"BAR\")})", cu); table.removeUniqueConstraint(1); - assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"FOO\"))"); + assertSourceContains("@Table(uniqueConstraints=@UniqueConstraint(columnNames=\"FOO\"))", cu); table.removeUniqueConstraint(0); - assertSourceDoesNotContain("@Table"); + assertSourceDoesNotContain("@Table", cu); } public void testMoveUniqueConstraint() throws Exception { - IType testType = this.createTestTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.moveUniqueConstraint(2, 0); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"FOO\"}), @UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"})})", cu); } public void testMoveUniqueConstraint2() throws Exception { - IType testType = this.createTestTableWithUniqueConstraints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTableWithUniqueConstraints(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); TableAnnotation table = (TableAnnotation) typeResource.getAnnotation(JPA.TABLE); table.moveUniqueConstraint(0, 2); - assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})"); + assertSourceContains("@Table(uniqueConstraints={@UniqueConstraint(columnNames={\"BAZ\"}), @UniqueConstraint(columnNames={\"BAR\"}), @UniqueConstraint(columnNames={\"FOO\"})})", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java index c73896325d..9aca8780ac 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TemporalTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -24,7 +24,7 @@ public class TemporalTests extends JavaResourceModelTestCase { super(name); } - private IType createTestTemporal() throws Exception { + private ICompilationUnit createTestTemporal() throws Exception { this.createAnnotationAndMembers("Temporal", "TemporalType value();"); this.createEnumAndMembers("TemporalType", "DATE, TIME, TIMESTAMP"); return this.createTestType(new DefaultAnnotationWriter() { @@ -39,7 +39,7 @@ public class TemporalTests extends JavaResourceModelTestCase { }); } - private IType createTestTemporalWithValue() throws Exception { + private ICompilationUnit createTestTemporalWithValue() throws Exception { this.createAnnotationAndMembers("Temporal", "TemporalType value();"); this.createEnumAndMembers("TemporalType", "DATE, TIME, TIMESTAMP"); return this.createTestType(new DefaultAnnotationWriter() { @@ -55,8 +55,8 @@ public class TemporalTests extends JavaResourceModelTestCase { } public void testTemporal() throws Exception { - IType testType = this.createTestTemporal(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTemporal(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL); @@ -64,8 +64,8 @@ public class TemporalTests extends JavaResourceModelTestCase { } public void testGetValue() throws Exception { - IType testType = this.createTestTemporalWithValue(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTemporalWithValue(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL); @@ -73,19 +73,19 @@ public class TemporalTests extends JavaResourceModelTestCase { } public void testSetValue() throws Exception { - IType testType = this.createTestTemporal(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTemporal(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(JPA.TEMPORAL); temporal.setValue(TemporalType.TIME); - assertSourceContains("@Temporal(TIME)"); + assertSourceContains("@Temporal(TIME)", cu); temporal.setValue(null); - assertSourceDoesNotContain("@Temporal"); + assertSourceDoesNotContain("@Temporal", cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java index 7671927317..89c7db53d4 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/TransientTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class TransientTests extends JavaResourceModelTestCase { super(name); } - private IType createTestTransient() throws Exception { + private ICompilationUnit createTestTransient() throws Exception { this.createAnnotationAndMembers("Transient", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -39,8 +39,8 @@ public class TransientTests extends JavaResourceModelTestCase { } public void testTransient() throws Exception { - IType testType = this.createTestTransient(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestTransient(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java index 8f35d097a9..eef64e99f0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/VersionTests.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.tests.internal.resource.java; import java.util.Iterator; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -24,7 +24,7 @@ public class VersionTests extends JavaResourceModelTestCase { super(name); } - private IType createTestVersion() throws Exception { + private ICompilationUnit createTestVersion() throws Exception { this.createAnnotationAndMembers("Version", ""); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -39,8 +39,8 @@ public class VersionTests extends JavaResourceModelTestCase { } public void testVersion() throws Exception { - IType testType = this.createTestVersion(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(testType); + ICompilationUnit cu = this.createTestVersion(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); JavaResourceNode mappingAnnotation = attributeResource.getMappingAnnotation(); diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java index f22c6b3aa6..1b8d7a57a1 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/AnnotationTestCase.java @@ -12,14 +12,15 @@ package org.eclipse.jpt.core.tests.internal.utility.jdt; import java.io.File; import java.util.Iterator; import java.util.List; -import junit.framework.TestCase; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.Annotation; +import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.MemberValuePair; import org.eclipse.jdt.core.dom.NormalAnnotation; @@ -29,16 +30,18 @@ import org.eclipse.jdt.core.dom.SingleMemberAnnotation; import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute; import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute; +import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; import org.eclipse.jpt.core.internal.utility.jdt.JDTType; import org.eclipse.jpt.core.tests.internal.ProjectUtility; import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject; import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter; -import org.eclipse.jpt.utility.CommandExecutor; -import org.eclipse.jpt.utility.CommandExecutorProvider; +import org.eclipse.jpt.core.utility.jdt.Type; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; import org.eclipse.jpt.utility.tests.internal.TestTools; +import junit.framework.TestCase; + /** * Provide an easy(?) way to build an annotated source file. * The type must be created by calling one of the #createType() methods @@ -48,16 +51,16 @@ import org.eclipse.jpt.utility.tests.internal.TestTools; public abstract class AnnotationTestCase extends TestCase { protected TestJavaProject javaProject; - protected static final String CR = System.getProperty("line.separator"); - protected static final String SEP = File.separator; - protected static final String PROJECT_NAME = "AnnotationTestProject"; - protected static final String PACKAGE_NAME = "test"; - protected static final String TYPE_NAME = "AnnotationTestType"; - protected static final String FULLY_QUALIFIED_TYPE_NAME = PACKAGE_NAME + "." + TYPE_NAME; - protected static final String FILE_NAME = TYPE_NAME + ".java"; - protected static final IPath FILE_PATH = new Path("src" + SEP + PACKAGE_NAME + SEP + FILE_NAME); + public static final String CR = System.getProperty("line.separator"); + public static final String SEP = File.separator; + public static final String PROJECT_NAME = "AnnotationTestProject"; + public static final String PACKAGE_NAME = "test"; + public static final String TYPE_NAME = "AnnotationTestType"; + public static final String FULLY_QUALIFIED_TYPE_NAME = PACKAGE_NAME + "." + TYPE_NAME; + public static final String FILE_NAME = TYPE_NAME + ".java"; + public static final IPath FILE_PATH = new Path("src" + SEP + PACKAGE_NAME + SEP + FILE_NAME); - protected static final String[] EMPTY_STRING_ARRAY = new String[0]; + public static final String[] EMPTY_STRING_ARRAY = new String[0]; // ********** TestCase behavior ********** @@ -93,9 +96,9 @@ public abstract class AnnotationTestCase extends TestCase { super.tearDown(); } - protected void dumpSource() throws Exception { + protected void dumpSource(ICompilationUnit cu) throws Exception { System.out.println("*** " + this.getName() + " ****"); - System.out.println(this.source()); + System.out.println(this.getSource(cu)); System.out.println(); } @@ -105,14 +108,14 @@ public abstract class AnnotationTestCase extends TestCase { /** * create an un-annotated type */ - protected IType createTestType() throws CoreException { + protected ICompilationUnit createTestType() throws CoreException { return this.createTestType(new DefaultAnnotationWriter()); } /** * shortcut for simply adding an annotation to the 'id' field */ - protected IType createTestType(final String annotationImport, final String idFieldAnnotation) throws CoreException { + protected ICompilationUnit createTestType(final String annotationImport, final String idFieldAnnotation) throws CoreException { return this.createTestType(new DefaultAnnotationWriter() { @Override public Iterator<String> imports() { @@ -131,17 +134,17 @@ public abstract class AnnotationTestCase extends TestCase { /** * shortcut for simply adding a fully-qualified annotation to the 'id' field */ - protected IType createTestType(final String idFieldAnnotation) throws CoreException { + protected ICompilationUnit createTestType(final String idFieldAnnotation) throws CoreException { return this.createTestType(null, idFieldAnnotation); } - protected IType createTestType(AnnotationWriter annotationWriter) throws CoreException { - return this.javaProject.createType(PACKAGE_NAME, FILE_NAME, this.createSourceWriter(annotationWriter)); + protected ICompilationUnit createTestType(AnnotationWriter annotationWriter) throws CoreException { + return this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, this.createSourceWriter(annotationWriter)); } - protected IType createTestType(String packageName, String fileName, String typeName, AnnotationWriter annotationWriter) throws CoreException { - return this.javaProject.createType(packageName, fileName, this.createSourceWriter(annotationWriter, typeName)); + protected ICompilationUnit createTestType(String packageName, String fileName, String typeName, AnnotationWriter annotationWriter) throws CoreException { + return this.javaProject.createCompilationUnit(packageName, fileName, this.createSourceWriter(annotationWriter, typeName)); } protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter) { @@ -218,74 +221,84 @@ public abstract class AnnotationTestCase extends TestCase { protected TestJavaProject getJavaProject() { return this.javaProject; } - - protected IType jdtType() throws JavaModelException { - return this.javaProject.findType(FULLY_QUALIFIED_TYPE_NAME); + + protected JDTType testType(ICompilationUnit cu) { + return this.buildType(TYPE_NAME, cu); + } + + protected JDTType buildType(String name, ICompilationUnit cu) { + return this.buildType(name, 1, cu); + } + + protected JDTType buildType(String name, int occurrence, ICompilationUnit cu) { + return this.buildType(null, name, 1, cu); } - protected JDTType testType() throws JavaModelException { - return this.buildType(this.jdtType()); + protected JDTType buildType(Type declaringType, String name, int occurrence, ICompilationUnit cu) { + return new JDTType(declaringType, name, occurrence, cu); } - protected JDTType buildType(IType jdtType) { - return new JDTType(jdtType, this.modifySharedDocumentCommandExecutorProvider()); + protected JDTFieldAttribute idField(ICompilationUnit cu) { + return this.buildField("id", cu); } - protected JDTFieldAttribute idField() throws JavaModelException { - return this.fieldNamed("id"); + protected JDTFieldAttribute nameField(ICompilationUnit cu) { + return this.buildField("name", cu); } - protected JDTFieldAttribute nameField() throws JavaModelException { - return this.fieldNamed("name"); + protected JDTFieldAttribute buildField(String name, ICompilationUnit cu) { + return this.buildField(name, 1, cu); } - protected JDTFieldAttribute fieldNamed(String fieldName) throws JavaModelException { - return new JDTFieldAttribute(this.jdtType().getField(fieldName), this.modifySharedDocumentCommandExecutorProvider()); + protected JDTFieldAttribute buildField(String name, int occurrence, ICompilationUnit cu) { + return this.buildField(this.testType(cu), name, occurrence, cu); } - protected JDTMethodAttribute idGetMethod() throws JavaModelException { - return this.methodNamed("getId"); + protected JDTFieldAttribute buildField(Type declaringType, String name, int occurrence, ICompilationUnit cu) { + return new JDTFieldAttribute(declaringType, name, occurrence, cu); + } + + protected JDTMethodAttribute idGetMethod(ICompilationUnit cu) { + return this.buildMethod("getId", cu); } - protected JDTMethodAttribute idSetMethod() throws JavaModelException { - return this.method("setId", new String[] {"I"}); + protected JDTMethodAttribute idSetMethod(ICompilationUnit cu) { + return this.buildMethod("setId", new String[] {"int"}, cu); } - protected JDTMethodAttribute nameGetMethod() throws JavaModelException { - return this.methodNamed("getName"); + protected JDTMethodAttribute nameGetMethod(ICompilationUnit cu) { + return this.buildMethod("getName", cu); } - protected JDTMethodAttribute methodNamed(String methodName) throws JavaModelException { - return this.method(methodName, EMPTY_STRING_ARRAY); + protected JDTMethodAttribute buildMethod(String name, ICompilationUnit cu) { + return this.buildMethod(name, EMPTY_STRING_ARRAY, cu); } - protected JDTMethodAttribute method(String methodName, String[] parameterTypeSignatures) throws JavaModelException { - return new JDTMethodAttribute(this.jdtType().getMethod(methodName, parameterTypeSignatures), this.modifySharedDocumentCommandExecutorProvider()); + protected JDTMethodAttribute buildMethod(String name, String[] parameterTypeNames, ICompilationUnit cu) { + return this.buildMethod(name, parameterTypeNames, 1, cu); } - protected String source() throws JavaModelException { - return this.jdtType().getOpenable().getBuffer().getContents(); + protected JDTMethodAttribute buildMethod(String name, String[] parameterTypeNames, int occurrence, ICompilationUnit cu) { + return new JDTMethodAttribute(this.testType(cu), name, parameterTypeNames, occurrence, cu); } - /** - * the tests will be run "headless" so use the default "shared document modifier" - */ - protected CommandExecutorProvider modifySharedDocumentCommandExecutorProvider() { - return MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER; + protected JDTMethodAttribute buildMethod(Type declaringType, String name, String[] parameterTypeNames, int occurrence, ICompilationUnit cu) { + return new JDTMethodAttribute(declaringType, name, parameterTypeNames, occurrence, cu); + } + + protected String getSource(ICompilationUnit cu) throws JavaModelException { + return cu.getBuffer().getContents(); + } + + protected CompilationUnit buildASTRoot(ICompilationUnit cu) { + return JDTTools.buildASTRoot(cu); } - protected static final CommandExecutorProvider MODIFY_SHARED_DOCUMENT_COMMAND_EXECUTOR_PROVIDER = - new CommandExecutorProvider() { - public CommandExecutor getCommandExecutor() { - return CommandExecutor.Default.instance(); - } - }; - // ********** test validation ********** - protected void assertSourceContains(String s) throws JavaModelException { - String source = this.source(); + protected void assertSourceContains(String s, ICompilationUnit cu) throws JavaModelException { + String source = this.getSource(cu); boolean found = source.indexOf(s) > -1; if ( ! found) { String msg = "source does not contain the expected string: " + s + " (see System console)"; @@ -297,8 +310,8 @@ public abstract class AnnotationTestCase extends TestCase { } } - protected void assertSourceDoesNotContain(String s) throws JavaModelException { - String source = this.source(); + protected void assertSourceDoesNotContain(String s, ICompilationUnit cu) throws JavaModelException { + String source = this.getSource(cu); int pos = source.indexOf(s); if (pos != -1) { String msg = "unexpected string in source (position: " + pos + "): " + s + " (see System console)"; @@ -338,7 +351,7 @@ public abstract class AnnotationTestCase extends TestCase { /** * check for null member value pair */ - protected Expression valueInternal(MemberValuePair pair) { + protected Expression value_(MemberValuePair pair) { return (pair == null) ? null : pair.getValue(); } @@ -348,7 +361,7 @@ public abstract class AnnotationTestCase extends TestCase { * Return null if the annotation has no such element. */ protected Expression annotationElementValue(NormalAnnotation annotation, String elementName) { - return this.valueInternal(this.memberValuePair(annotation, elementName)); + return this.value_(this.memberValuePair(annotation, elementName)); } /** diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java index 6ec7a4037e..10947d9ae4 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java @@ -9,11 +9,13 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.MemberValuePair; import org.eclipse.jdt.core.dom.NormalAnnotation; import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jpt.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; @@ -28,17 +30,17 @@ public class CombinationIndexedDeclarationAnnotationAdapterTests extends Annotat } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } public void testAnnotation1() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isNormalAnnotation()); @@ -47,22 +49,22 @@ public class CombinationIndexedDeclarationAnnotationAdapterTests extends Annotat public void testAnnotation2() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotation3() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isNormalAnnotation()); @@ -71,22 +73,22 @@ public class CombinationIndexedDeclarationAnnotationAdapterTests extends Annotat public void testAnnotation4() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotation5() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isNormalAnnotation()); @@ -97,22 +99,22 @@ public class CombinationIndexedDeclarationAnnotationAdapterTests extends Annotat public void testAnnotation6() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotation7() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isNormalAnnotation()); @@ -123,606 +125,606 @@ public class CombinationIndexedDeclarationAnnotationAdapterTests extends Annotat public void testAnnotation8() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); } public void testRemoveAnnotation1() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); + this.assertSourceDoesNotContain("JoinColumn", cu); } public void testRemoveAnnotation2() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("JoinColumn"); + this.assertSourceDoesNotContain("JoinColumns", cu); + this.assertSourceDoesNotContain("JoinColumn", cu); } public void testRemoveAnnotation3() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("ADDRESS_ID2"); - this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")"); + this.assertSourceDoesNotContain("JoinColumns", cu); + this.assertSourceDoesNotContain("ADDRESS_ID2", cu); + this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")", cu); } public void testRemoveAnnotation4() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("ADDRESS_ID2"); - this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")"); + this.assertSourceDoesNotContain("JoinColumns", cu); + this.assertSourceDoesNotContain("ADDRESS_ID2", cu); + this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")", cu); } public void testRemoveAnnotation5() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "String comment(); JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(comment=\"test\",columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(comment=\"test\",columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceContains("@annot.JoinColumns(comment=\"test\",columns=@annot.JoinColumn(name=\"ADDRESS_ID1\"))"); + this.assertSourceContains("@annot.JoinColumns(comment=\"test\",columns=@annot.JoinColumn(name=\"ADDRESS_ID1\"))", cu); } public void testRemoveAnnotation6() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(null)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(null)"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.removeAnnotation(); - this.assertSourceContains("@annot.JoinColumns(null)"); + this.assertSourceContains("@annot.JoinColumns(null)", cu); } public void testRemoveAnnotation12() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID0\")"; DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("JoinColumns", cu); } public void testRemoveAnnotation13() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({null, @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); - this.assertSourceContains("@annot.JoinColumn"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null, @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + this.assertSourceContains("@annot.JoinColumn", cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); + this.assertSourceDoesNotContain("JoinColumn", cu); } public void testRemoveAnnotation14() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), null})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), null})"); String expected = "@JoinColumn(name=\"ADDRESS_ID0\")"; DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation15() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})"; DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation16() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"; DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 3); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation17() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({null, null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); - this.assertSourceContains("@annot.JoinColumn"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null, null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + this.assertSourceContains("@annot.JoinColumn", cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); + this.assertSourceDoesNotContain("JoinColumn", cu); } public void testNewMarkerAnnotation1() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType(); - this.assertSourceDoesNotContain("JoinColumn"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("JoinColumn", cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); + this.assertSourceContains("JoinColumn", cu); + this.assertSourceDoesNotContain("JoinColumns", cu); } public void testNewMarkerAnnotation2() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn"); + this.assertSourceDoesNotContain("JoinColumns", cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn,@JoinColumn})"); + this.assertSourceContains("@JoinColumns(columns={@JoinColumn,@JoinColumn})", cu); } public void testNewMarkerAnnotation3() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn," + CR + " @JoinColumn})"); + this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn," + CR + " @JoinColumn})", cu); } public void testNewMarkerAnnotation4() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(77)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(77)"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("77"); + this.assertSourceContains("JoinColumn", cu); + this.assertSourceDoesNotContain("JoinColumns", cu); + this.assertSourceDoesNotContain("77", cu); } public void testNewMarkerAnnotation5() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns=@JoinColumn)"); - this.assertSourceDoesNotContain("77"); + this.assertSourceContains("@annot.JoinColumns(columns=@JoinColumn)", cu); + this.assertSourceDoesNotContain("77", cu); } public void testNewMarkerAnnotation6() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})"); + this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})", cu); } public void testNewMarkerAnnotation7() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(77)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(77)"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn(77),@JoinColumn})"); + this.assertSourceContains("@JoinColumns(columns={@JoinColumn(77),@JoinColumn})", cu); } public void testNewMarkerAnnotation8() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(77),@annot.JoinColumn(88)})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(77),@annot.JoinColumn(88)})"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})"); + this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})", cu); } public void testNewMarkerAnnotation9() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),@JoinColumn})"); + this.assertSourceContains("@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),@JoinColumn})", cu); } public void testNewMarkerAnnotation23() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); String expected = "@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),null,@JoinColumn})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation24() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); String expected1 = "@JoinColumns({"; String expected2 = "@JoinColumn(text=\"blah\", num=42),null,"; String expected3 = "@JoinColumn" + CR + " })"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); - this.assertSourceDoesNotContain(expected3); + this.assertSourceDoesNotContain(expected1, cu); + this.assertSourceDoesNotContain(expected2, cu); + this.assertSourceDoesNotContain(expected3, cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - this.assertSourceContains(expected3); + this.assertSourceContains(expected1, cu); + this.assertSourceContains(expected2, cu); + this.assertSourceContains(expected3, cu); } public void testNewMarkerAnnotation25() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected1 = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split String expected2 = "@JoinColumn})"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); + this.assertSourceDoesNotContain(expected1, cu); + this.assertSourceDoesNotContain(expected2, cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 4); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); + this.assertSourceContains(expected1, cu); + this.assertSourceContains(expected2, cu); } public void testNewMarkerAnnotation26() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected1 = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split String expected2 = "@JoinColumn})"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); + this.assertSourceDoesNotContain(expected1, cu); + this.assertSourceDoesNotContain(expected2, cu); DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 4); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); + this.assertSourceContains(expected1, cu); + this.assertSourceContains(expected2, cu); } public void testMoveAnnotation1() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); String expected = "@JoinColumns(columns={null,@JoinColumn(name=\"ADDRESS_ID0\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(1); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation2() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID1\")"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("JoinColumns", cu); } public void testMoveAnnotation2a() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID1\")"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 1); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("JoinColumns", cu); } public void testMoveAnnotation3() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation4() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID4\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID4\")})"); String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation5() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation6() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID0\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation7() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation8() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})"); String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation9() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})"; - this.createTestType(expected); // the source should be unchanged + ICompilationUnit cu = this.createTestType(expected); // the source should be unchanged IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation10() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID0\")"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(1); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("@annot.JoinColumns", cu); } public void testMoveAnnotation10a() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID0\")"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "value", 2); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(1); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("@annot.JoinColumns", cu); } public void testMoveAnnotation11() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceDoesNotContain("JoinColumn"); + this.assertSourceDoesNotContain("JoinColumn", cu); } public void testMoveAnnotation12() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); String expected = "@JoinColumn(name=\"ADDRESS_ID2\")"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); + this.assertSourceContains(expected, cu); + this.assertSourceDoesNotContain("@annot.JoinColumns", cu); } public void testMoveAnnotation13() throws Exception { this.createAnnotationAndMembers("JoinColumn", "String name();"); this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); + ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})"); String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})"; IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), cidaa); + Annotation annotation = iaa.getAnnotation(JDTTools.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java index 3fa9437aed..f644cabc17 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/JDTToolsTests.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute; @@ -24,23 +25,23 @@ public class JDTToolsTests extends AnnotationTestCase { } private void createEnumAndMembers(String enumName, String enumBody) throws Exception { - this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); + this.javaProject.createCompilationUnit("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } public void testResolveEnum1() throws Exception { this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)"); + ICompilationUnit cu = this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - JDTFieldAttribute field = this.idField(); + JDTFieldAttribute field = this.idField(cu); - String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot()))); + String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu)))); assertEquals("enums.TestEnum.BAZ", actual); } @@ -48,12 +49,12 @@ public class JDTToolsTests extends AnnotationTestCase { this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)"); + ICompilationUnit cu = this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - JDTFieldAttribute field = this.idField(); + JDTFieldAttribute field = this.idField(cu); - String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot()))); + String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu)))); assertEquals("enums.TestEnum.BAZ", actual); } @@ -61,12 +62,12 @@ public class JDTToolsTests extends AnnotationTestCase { this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)"); + ICompilationUnit cu = this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - JDTFieldAttribute field = this.idField(); + JDTFieldAttribute field = this.idField(cu); - String actual = JDTTools.resolveEnum((Name)daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot()))); + String actual = JDTTools.resolveEnum((Name)daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu)))); assertEquals("enums.TestEnum.BAZ", actual); } @@ -74,12 +75,12 @@ public class JDTToolsTests extends AnnotationTestCase { this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)"); + ICompilationUnit cu = this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - JDTFieldAttribute field = this.idField(); + JDTFieldAttribute field = this.idField(cu); - String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.idField().getAstRoot()))); + String actual = JDTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu)))); assertEquals("enums.TestEnum.BAZ", actual); } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java index 86c3da71ec..0f25f9bbb7 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.core.tests.internal.utility.jdt; import java.util.Arrays; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; @@ -39,46 +40,46 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } private void createEnum(String enumName, String enumBody) throws Exception { - this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); + this.javaProject.createCompilationUnit("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); } public void testValue1() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=\"xxx\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"xxx\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("xxx", aea.getValue()); } public void testValue2() throws Exception { this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=48)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=48)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, "bar", NumberIntegerExpressionConverter.instance()); - AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea); + AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(cu), daea); assertEquals(Integer.valueOf(48), aea.getValue()); } public void testValue3() throws Exception { this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar='c')"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar='c')"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", CharacterStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("c", aea.getValue()); } public void testValue4() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=false)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=false)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, "bar", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } @@ -86,39 +87,39 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Baz", "boolean fred();"); this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } public void testValue6() throws Exception { this.createAnnotationAndMembers("Foo", "boolean value();"); - this.createTestType("@annot.Foo(false)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(false)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } public void testValueNull1() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueNull2() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } @@ -126,169 +127,169 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Baz", "String fred();"); this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa3, "fred"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueStringConcatenation() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=\"xxx\" + \"yyy\" + \"zzz\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"xxx\" + \"yyy\" + \"zzz\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("xxxyyyzzz", aea.getValue()); } public void testValueStringConstant() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); // just a bit hacky: - this.createTestType("private static final String FOO_BAR = \"xxx\"; @annot.Foo(bar=FOO_BAR + \"yyy\" + \"zzz\")"); + ICompilationUnit cu = this.createTestType("private static final String FOO_BAR = \"xxx\"; @annot.Foo(bar=FOO_BAR + \"yyy\" + \"zzz\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("xxxyyyzzz", aea.getValue()); } public void testValueNumberArithmetic() throws Exception { this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=47 - 7 + 2 * 1 / 1)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=47 - 7 + 2 * 1 / 1)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea); + AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(cu), daea); assertEquals(Integer.valueOf(42), aea.getValue()); } public void testValueNumberShift() throws Exception { this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=2 << 2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=2 << 2)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea); + AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(cu), daea); assertEquals(Integer.valueOf(8), aea.getValue()); } public void testValueNumberConstant() throws Exception { this.createAnnotationAndMembers("Foo", "int bar();"); // just a bit hacky: - this.createTestType("private static final int FOO_BAR = 77; @annot.Foo(bar=FOO_BAR)"); + ICompilationUnit cu = this.createTestType("private static final int FOO_BAR = 77; @annot.Foo(bar=FOO_BAR)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea); + AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(cu), daea); assertEquals(Integer.valueOf(77), aea.getValue()); } public void testValueCharacterConstant() throws Exception { this.createAnnotationAndMembers("Foo", "char bar();"); // just a bit hacky: - this.createTestType("private static final char FOO_BAR = 'Q'; @annot.Foo(bar=FOO_BAR)"); + ICompilationUnit cu = this.createTestType("private static final char FOO_BAR = 'Q'; @annot.Foo(bar=FOO_BAR)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("Q", aea.getValue()); } public void testValueCharacterCast() throws Exception { this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar=(char) 0x41)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(char) 0x41)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("A", aea.getValue()); } public void testValueBooleanOperator1() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=7 > 2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=7 > 2)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.TRUE, aea.getValue()); } public void testValueBooleanOperator2() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=7 == 2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=7 == 2)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } public void testValueBooleanOperator3() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=(7 != 2) && false)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(7 != 2) && false)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } public void testValueBooleanOperator4() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=(7 != 2) ? false : true)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(7 != 2) ? false : true)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); } public void testValueInvalidValue1() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=77)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=77)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue2() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=bazzzz)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=bazzzz)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue3() throws Exception { this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=bazzzz)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=bazzzz)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue4() throws Exception { this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar=\"bazzzz\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"bazzzz\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue5() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=\"java.lang.Object\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"java.lang.Object\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue6() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } @@ -299,30 +300,30 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { String value = "\"false\""; String element = "fred=" + value; String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))"; - this.createTestType(annotation); + ICompilationUnit cu = this.createTestType(annotation); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueInvalidValue8() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={true, false})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={true, false})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {null, null}, aea.getValue())); } public void testValueInvalidValue9() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar=77)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=77)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {null}, aea.getValue())); } @@ -331,13 +332,13 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { String value = "\"xxx\""; String element = "bar=" + value; String annotation = "@annot.Foo(" + element + ")"; - this.createTestType(annotation); + ICompilationUnit cu = this.createTestType(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); - TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot())); - assertEquals(this.source().indexOf(value), textRange.getOffset()); + TextRange textRange = new ASTNodeTextRange(aea.getAstNode(this.buildASTRoot(cu))); + assertEquals(this.getSource(cu).indexOf(value), textRange.getOffset()); assertEquals(value.length(), textRange.getLength()); assertEquals(8, textRange.getLineNumber()); } @@ -349,14 +350,14 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { String value = "false"; String element = "fred=" + value; String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))"; - this.createTestType(annotation); + ICompilationUnit cu = this.createTestType(annotation); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); assertEquals(Boolean.FALSE, aea.getValue()); - TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot())); + TextRange textRange = new ASTNodeTextRange(aea.getAstNode(this.buildASTRoot(cu))); assertEquals(value.length(), textRange.getLength()); } @@ -364,54 +365,54 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "String value();"); String element = "\"xxx\""; String annotation = "@annot.Foo(" + element + ")"; - this.createTestType(annotation); + ICompilationUnit cu = this.createTestType(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); - TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot())); - assertEquals(this.source().indexOf(element), textRange.getOffset()); + TextRange textRange = new ASTNodeTextRange(aea.getAstNode(this.buildASTRoot(cu))); + assertEquals(this.getSource(cu).indexOf(element), textRange.getOffset()); assertEquals(element.length(), textRange.getLength()); } public void testASTNode4() throws Exception { this.createAnnotationAndMembers("Foo", "String value();"); String annotation = "@annot.Foo"; - this.createTestType(annotation); + ICompilationUnit cu = this.createTestType(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); - TextRange textRange = new ASTNodeTextRange(aea.getAstNode(idField().getAstRoot())); - assertEquals(this.source().indexOf(annotation), textRange.getOffset()); + TextRange textRange = new ASTNodeTextRange(aea.getAstNode(this.buildASTRoot(cu))); + assertEquals(this.getSource(cu).indexOf(annotation), textRange.getOffset()); assertEquals(annotation.length(), textRange.getLength()); } public void testSetValue1() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue(null); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testSetValue2() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar", false); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@Foo"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@Foo", cu); } public void testSetValue3() throws Exception { @@ -419,18 +420,18 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceDoesNotContain("Foo"); - this.assertSourceDoesNotContain("Bar"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceDoesNotContain("Foo", cu); + this.assertSourceDoesNotContain("Bar", cu); } public void testSetValue3a() throws Exception { @@ -438,28 +439,28 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar", false); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz", false); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(@Bar)"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@annot.Foo(@Bar)", cu); } public void testSetValue4() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("xxx"); - this.assertSourceContains("@Foo(bar=\"xxx\")"); + this.assertSourceContains("@Foo(bar=\"xxx\")", cu); } public void testSetValue5() throws Exception { @@ -467,87 +468,87 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); aea.setValue(Boolean.TRUE); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=true)))"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=true)))", cu); } public void testSetValue6() throws Exception { this.createAnnotationAndMembers("Baz", "boolean fred();"); this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance()); - AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(), daea); + AnnotationElementAdapter<Boolean> aea = new MemberAnnotationElementAdapter<Boolean>(this.idField(cu), daea); aea.setValue(Boolean.TRUE); - this.assertSourceContains("@Foo(@Bar(jimmy=@Baz(fred=true)))"); + this.assertSourceContains("@Foo(@Bar(jimmy=@Baz(fred=true)))", cu); } public void testSetValue7() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("yyy"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(bar=\"yyy\")"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@annot.Foo(bar=\"yyy\")", cu); } public void testSetValue8() throws Exception { this.createAnnotationAndMembers("Foo", "String bar();"); String annotation = "@annot.Foo"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("xxx"); - this.assertSourceContains("@Foo(bar=\"xxx\")"); + this.assertSourceContains("@Foo(bar=\"xxx\")", cu); } public void testSetValue9() throws Exception { this.createAnnotationAndMembers("Foo", "String value(); String bar();"); String annotation = "@annot.Foo(\"zzz\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("xxx"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@Foo(value=\"zzz\", bar=\"xxx\")"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@Foo(value=\"zzz\", bar=\"xxx\")", cu); } public void testSetValue10() throws Exception { this.createAnnotationAndMembers("Foo", "String bar(); String baz();"); String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "baz"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("yyy"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(bar=\"xxx\", baz = \"yyy\")"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@annot.Foo(bar=\"xxx\", baz = \"yyy\")", cu); } public void testSetValue11() throws Exception { @@ -555,157 +556,157 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Bar", "annot.Baz[] jimmy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); String annotation = "@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=2), @annot.Baz(fred=3)}))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "jimmy", 2, "annot.Baz"); DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa3, "fred", NumberIntegerExpressionConverter.instance()); - AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(), daea); + AnnotationElementAdapter<Integer> aea = new MemberAnnotationElementAdapter<Integer>(this.idField(cu), daea); assertEquals(Integer.valueOf(2), aea.getValue()); aea.setValue(Integer.valueOf(48)); - this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=48), @annot.Baz(fred=3)}))"); + this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=48), @annot.Baz(fred=3)}))", cu); } public void testSetValue12() throws Exception { this.createAnnotationAndMembers("Foo", "String value();"); String annotation = "@annot.Foo"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("xxx"); - this.assertSourceContains("@Foo(\"xxx\")"); + this.assertSourceContains("@Foo(\"xxx\")", cu); } public void testSetValue13() throws Exception { this.createAnnotationAndMembers("Foo", "String value();"); String annotation = "@annot.Foo(\"zzz\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType(annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("xxx"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(\"xxx\")"); + this.assertSourceDoesNotContain(annotation, cu); + this.assertSourceContains("@annot.Foo(\"xxx\")", cu); } public void testSimpleTypeLiteral1() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("java.lang.Object", aea.getValue()); } public void testSimpleTypeLiteral2() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("java.lang.Object"); - this.assertSourceContains("@Foo(bar=java.lang.Object.class)"); + this.assertSourceContains("@Foo(bar=java.lang.Object.class)", cu); } public void testSimpleTypeLiteral3() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=int.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=int.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testSimpleTypeLiteral4() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("java.util.Map.Entry", aea.getValue()); } public void testPrimitiveTypeLiteral1() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=int.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=int.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("int", aea.getValue()); } public void testPrimitiveTypeLiteral2() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("int"); - this.assertSourceContains("@Foo(bar=int.class)"); + this.assertSourceContains("@Foo(bar=int.class)", cu); } public void testPrimitiveTypeLiteral3() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testPrimitiveTypeLiteral4() throws Exception { this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=void.class)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=void.class)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("void", aea.getValue()); } public void testValueEnum1() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("enums.TestEnum.XXX", aea.getValue()); } public void testValueEnum2() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)"); + ICompilationUnit cu = this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("enums.TestEnum.XXX", aea.getValue()); } public void testValueEnum3() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertNull(aea.getValue()); } public void testValueEnum4() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)"); + ICompilationUnit cu = this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); assertEquals("enums.TestEnum.XXX", aea.getValue()); } @@ -713,180 +714,180 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); String annotation = "@annot.Foo(bar=XXX)"; - this.createTestType("static enums.TestEnum.XXX", annotation); - this.assertSourceContains(annotation); + ICompilationUnit cu = this.createTestType("static enums.TestEnum.XXX", annotation); + this.assertSourceContains(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue(null); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testSetValueEnum2() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); String annotation = "@Foo(bar=XXX)"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea); + AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(cu), daea); aea.setValue("enums.TestEnum.XXX"); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains(annotation); + this.assertSourceContains("import static enums.TestEnum.XXX;", cu); + this.assertSourceContains(annotation, cu); } public void testValueStringArray() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue())); } public void testValueStringArrayConcatenation() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={\"stri\" + \"ng0\", \"s\" + \"tring1\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={\"stri\" + \"ng0\", \"s\" + \"tring1\"})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue())); } public void testValueStringArrayEmpty() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } public void testValueStringArraySingleElement() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar=\"string0\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"string0\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"string0"}, aea.getValue())); } public void testValueNullStringArray() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo()"); + ICompilationUnit cu = this.createTestType("@annot.Foo()"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } public void testSetValueStringArray() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); String annotation = "@Foo(bar={\"string0\",\"string1\"})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[] {"string0", "string1"}); - this.assertSourceContains(annotation); + this.assertSourceContains(annotation, cu); } public void testSetValueStringArrayEmptyRemove() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); String annotation = "@Foo"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[0]); - this.assertSourceDoesNotContain(annotation); + this.assertSourceDoesNotContain(annotation, cu); } public void testSetValueStringArrayEmpty() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); String annotation = "@Foo(bar={})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); ExpressionConverter<String[]> expressionConverter = new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance(), false); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", expressionConverter); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[0]); - this.assertSourceContains(annotation); + this.assertSourceContains(annotation, cu); } public void testSetValueStringArraySingleElement() throws Exception { this.createAnnotationAndMembers("Foo", "String[] bar();"); String annotation = "@Foo(bar=\"string0\")"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[] {"string0"}); - this.assertSourceContains(annotation); + this.assertSourceContains(annotation, cu); } public void testValueEnumArray() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, aea.getValue())); } public void testValueEnumArrayInvalidEntry() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, 88})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, 88})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", null}, aea.getValue())); } public void testValueEnumArrayEmpty() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar={})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } public void testValueEnumArraySingleElement() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX"}, aea.getValue())); } public void testValueEnumArraySingleElementInvalid() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar=\"\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[] {null}, aea.getValue())); } public void testValueNullEnumArray() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo()"); + ICompilationUnit cu = this.createTestType("@annot.Foo()"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } @@ -894,55 +895,55 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); String annotation = "@Foo(bar={XXX,YYY})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains("import static enums.TestEnum.YYY;"); - this.assertSourceContains(annotation); + this.assertSourceContains("import static enums.TestEnum.XXX;", cu); + this.assertSourceContains("import static enums.TestEnum.YYY;", cu); + this.assertSourceContains(annotation, cu); } public void testSetValueEnumArrayEmptyRemove() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); String annotation = "@Foo"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[0]); - this.assertSourceDoesNotContain(annotation); + this.assertSourceDoesNotContain(annotation, cu); } public void testSetValueEnumArrayEmpty() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); String annotation = "@Foo(bar={})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar", true, false); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[0]); - this.assertSourceContains(annotation); + this.assertSourceContains(annotation, cu); } public void testSetValueEnumArraySingleElement() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); String annotation = "@Foo(bar=XXX)"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain(annotation, cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea); + AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(cu), daea); aea.setValue(new String[] {"enums.TestEnum.XXX"}); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains(annotation); + this.assertSourceContains("import static enums.TestEnum.XXX;", cu); + this.assertSourceContains(annotation, cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java index 59b50e66e4..ff46aa3ab0 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.NormalAnnotation; import org.eclipse.jdt.core.dom.SingleMemberAnnotation; @@ -28,18 +29,18 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } public void testAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar)"); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isMarkerAnnotation()); @@ -49,13 +50,13 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Baz", "String value();"); this.createAnnotationAndMembers("Bar", "annot.Baz yana();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar(yana=@annot.Baz))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar(yana=@annot.Baz))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "nestedAnnotation", "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "yana", "annot.Baz"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa3); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isMarkerAnnotation()); @@ -64,36 +65,36 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testAnnotationNull1() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo()"); + ICompilationUnit cu = this.createTestType("@annot.Foo()"); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull2() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull3() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "String nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=\"annot.Bar\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=\"annot.Bar\")"); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } @@ -101,12 +102,12 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Bar2", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar2)"); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } @@ -114,69 +115,69 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); String na = "@annot.Foo(nestedAnnotation=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation1a() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); String na = "@annot.Foo(nestedAnnotation=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar", false); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("Foo"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains("Foo", cu); } public void testRemoveAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "String nestedAnnotation();"); String na = "@annot.Foo(nestedAnnotation=\"annot.Bar\")"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation4() throws Exception { @@ -184,17 +185,17 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Bar2", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();"); String na = "@annot.Foo(nestedAnnotation=@annot.Bar2)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation5() throws Exception { @@ -202,21 +203,21 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();"); String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar"); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); - this.assertSourceDoesNotContain("Bar"); - this.assertSourceDoesNotContain("Baz"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceDoesNotContain("Foo", cu); + this.assertSourceDoesNotContain("Bar", cu); + this.assertSourceDoesNotContain("Baz", cu); } public void testRemoveAnnotation5a() throws Exception { @@ -224,166 +225,166 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();"); String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar", false); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz", false); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo(nestedAnnotation1=@Bar)"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains("@annot.Foo(nestedAnnotation1=@Bar)", cu); } public void testNewMarkerAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar)"); + this.assertSourceContains("@Foo(nestedAnnotation=@Bar)", cu); } public void testNewMarkerAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(@Bar)"); + this.assertSourceContains("@Foo(@Bar)", cu); } public void testNewMarkerAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotation=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "Object value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewSingleMemberAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration); } }); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar(\"test string literal\"))"); + this.assertSourceContains("@Foo(nestedAnnotation=@Bar(\"test string literal\"))", cu); } void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) { @@ -400,21 +401,21 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - SingleMemberAnnotation annotation = (SingleMemberAnnotation) aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + SingleMemberAnnotation annotation = (SingleMemberAnnotation) aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); - this.idField().edit(new Member.Editor() { + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration); } }); - this.assertSourceContains("@Foo(@Bar(\"test string literal\"))"); + this.assertSourceContains("@Foo(@Bar(\"test string literal\"))", cu); } void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) { @@ -431,15 +432,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotation=@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) { @@ -456,15 +457,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) { @@ -481,15 +482,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) { @@ -506,15 +507,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "Object value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) { @@ -531,15 +532,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String xxx();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) { @@ -556,15 +557,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewSingleMemberAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar value(); String xxx();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) { @@ -581,14 +582,14 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration); } }); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))"); + this.assertSourceContains("@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))", cu); } void editNewNormalAnnotation1(ModifiedDeclaration declaration) { @@ -603,14 +604,14 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration); } }); - this.assertSourceContains("@Foo(@Bar(yyy=\"test string literal\"))"); + this.assertSourceContains("@Foo(@Bar(yyy=\"test string literal\"))", cu); } void editNewNormalAnnotation2(ModifiedDeclaration declaration) { @@ -625,15 +626,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation3(ModifiedDeclaration declaration) { @@ -648,15 +649,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation4(ModifiedDeclaration declaration) { @@ -671,15 +672,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation5(ModifiedDeclaration declaration) { @@ -694,15 +695,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "Object value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation6(ModifiedDeclaration declaration) { @@ -717,15 +718,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(yyy = \"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation7(ModifiedDeclaration declaration) { @@ -740,15 +741,15 @@ public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "String yyy();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar(yyy = \"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation8(ModifiedDeclaration declaration) { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java index 4470720136..50c8a83abd 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -37,18 +38,18 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe } private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); } public void testAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})"); // 0 DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa.getAnnotation(astRoot); assertNotNull(annotation); assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName()); @@ -57,7 +58,7 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe // 1 daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 1, "annot.Bar"); - aa = new MemberAnnotationAdapter(this.idField(), daa); + aa = new MemberAnnotationAdapter(this.idField(cu), daa); annotation = aa.getAnnotation(astRoot); assertNotNull(annotation); assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName()); @@ -68,12 +69,12 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotation("Baz"); this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana=@annot.Baz))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana=@annot.Baz))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa3); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isMarkerAnnotation()); @@ -83,12 +84,12 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotation("Baz"); this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa3); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa.getAnnotation(astRoot); assertNotNull(annotation); assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); @@ -96,7 +97,7 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe // name mismatch daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz"); - aa = new MemberAnnotationAdapter(this.idField(), daa3); + aa = new MemberAnnotationAdapter(this.idField(cu), daa3); annotation = aa.getAnnotation(astRoot); assertNull(annotation); } @@ -104,33 +105,33 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testAnnotationNull1() throws Exception { this.createAnnotation("Bar"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo()"); + ICompilationUnit cu = this.createTestType("@annot.Foo()"); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull2() throws Exception { this.createAnnotation("Bar"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull3() throws Exception { this.createAnnotation("Bar"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"annot.Bar\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"annot.Bar\")"); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } @@ -138,22 +139,22 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotation("NotBar"); this.createAnnotation("Bar"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull5() throws Exception { this.createAnnotationAndMembers("Bar", "String value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})"); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } @@ -162,12 +163,12 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotation("Baz"); this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))"); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa3); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } @@ -176,52 +177,52 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1)})"; String expected = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={\"annot.Bar1\", \"annot.Bar2\", \"annot.Bar3\"})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation4() throws Exception { @@ -229,74 +230,74 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.NotBar(0), @annot.NotBar(1)})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - assertNull(aa.getAnnotation(this.idField().getAstRoot())); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); + assertNull(aa.getAnnotation(this.buildASTRoot(cu))); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation5a() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar", false); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertTrue(aa1.getAnnotation(this.idField().getAstRoot()).isMarkerAnnotation()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); + assertTrue(aa1.getAnnotation(this.buildASTRoot(cu)).isMarkerAnnotation()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains("import annot.Foo;", cu); + this.assertSourceContains("@Foo", cu); } public void testRemoveAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations=\"annot.Bar\")"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation7() throws Exception { @@ -304,61 +305,61 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations=@annot.NotBar)"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.removeAnnotation(); - this.assertSourceContains(na); + this.assertSourceContains(na, cu); } public void testRemoveAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertTrue(aa1.getAnnotation(astRoot).isNormalAnnotation()); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})", cu); } public void testRemoveAnnotation9() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertTrue(aa1.getAnnotation(astRoot).isSingleMemberAnnotation()); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo({@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})"); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains("@annot.Foo({@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})", cu); } public void testRemoveAnnotation10() throws Exception { @@ -366,19 +367,19 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})"; String expected = "@annot.Foo({null, @annot.Bar(1)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 0, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation11() throws Exception { @@ -386,21 +387,21 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})"; String expected = "@annot.Foo(@annot.Bar(0))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation12() throws Exception { @@ -408,38 +409,38 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})"; String expected = "@annot.Foo(@annot.Bar(0))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation13() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({null, @annot.Bar(1)})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation14() throws Exception { @@ -447,21 +448,21 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), null})"; String expected = "@annot.Foo(@annot.Bar(0))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation15() throws Exception { @@ -469,22 +470,22 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})"; String expected = "@annot.Foo({@annot.Bar(0), null, null, @annot.Bar(3)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation16() throws Exception { @@ -492,22 +493,22 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})"; String expected = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 3, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation17() throws Exception { @@ -515,38 +516,38 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})"; String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "nestedAnnotations").getNodeType()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation18() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})"; - this.createTestType(na); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testRemoveAnnotation19() throws Exception { @@ -554,21 +555,21 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), null})"; String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.idField().getAstRoot()), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "nestedAnnotations").getNodeType()); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation20() throws Exception { @@ -576,22 +577,22 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})"; String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, null, @annot.Bar(3)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testRemoveAnnotation21() throws Exception { @@ -599,461 +600,461 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})"; String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); + ICompilationUnit cu = this.createTestType(na); + this.assertSourceDoesNotContain(expected, cu); + this.assertSourceContains(na, cu); DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); + AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(cu), daa1); DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 3, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - CompilationUnit astRoot = this.idField().getAstRoot(); + AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(cu), daa2); + CompilationUnit astRoot = this.buildASTRoot(cu); Annotation annotation = aa2.getAnnotation(astRoot); assertNotNull(annotation); aa2.removeAnnotation(); assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); + this.assertSourceDoesNotContain(na, cu); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar)"); + this.assertSourceContains("@Foo(nestedAnnotations=@Bar)", cu); } public void testNewMarkerAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("Foo", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(@Bar)"); + this.assertSourceContains("@Foo(@Bar)", cu); } public void testNewMarkerAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation9() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - assertNull(aa.getAnnotation(this.idField().getAstRoot())); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + assertNull(aa.getAnnotation(this.buildASTRoot(cu))); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar})"); + this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar})", cu); } public void testNewMarkerAnnotation10() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); + this.assertSourceDoesNotContain("Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar})"); + this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar})", cu); } public void testNewMarkerAnnotation11() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); String expected = "@annot.Foo({@Bar, \"two\"})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation12() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); + this.assertSourceDoesNotContain("Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("Bar})"); // split line + this.assertSourceContains("Bar})", cu); // split line } public void testNewMarkerAnnotation13() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(7)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation14() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); + this.assertSourceDoesNotContain("Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar})"); + this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar})", cu); } public void testNewMarkerAnnotation15() throws Exception { this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)"); String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation16() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))"); String expected = "@annot.Foo({@annot.Bar(55),@Bar})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation17() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); String expected = "@annot.Foo(nestedAnnotations={@Bar})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation18() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + this.assertSourceDoesNotContain("Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("Bar})"); // split line + this.assertSourceContains("Bar})", cu); // split line } public void testNewMarkerAnnotation19() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation20() throws Exception { this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation21() throws Exception { this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar})"); + this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar})", cu); } public void testNewMarkerAnnotation22() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation23() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(88),null,@Bar})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation24() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(88))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(88))"); String expected = "@annot.Foo({@annot.Bar(88),null,@Bar})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testNewMarkerAnnotation25() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77)})"); String expected1 = "@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split String expected2 = "@Bar})"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); + this.assertSourceDoesNotContain(expected1, cu); + this.assertSourceDoesNotContain(expected2, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 4, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); + this.assertSourceContains(expected1, cu); + this.assertSourceContains(expected2, cu); } public void testNewMarkerAnnotation26() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(88), @annot.Bar(77)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(88), @annot.Bar(77)})"); String expected1 = "@annot.Foo({@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split String expected2 = "@Bar})"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); + this.assertSourceDoesNotContain(expected1, cu); + this.assertSourceDoesNotContain(expected2, cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 4, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); + this.assertSourceContains(expected1, cu); + this.assertSourceContains(expected2, cu); } public void testNewSingleMemberAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration); } }); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar(88))"); + this.assertSourceContains("@Foo(nestedAnnotations=@Bar(88))", cu); } void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) { @@ -1070,14 +1071,14 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration); } }); - this.assertSourceContains("@Foo(@Bar(88))"); + this.assertSourceContains("@Foo(@Bar(88))", cu); } void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) { @@ -1094,15 +1095,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) { @@ -1119,15 +1120,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) { @@ -1144,15 +1145,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) { @@ -1169,15 +1170,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) { @@ -1194,15 +1195,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) { @@ -1219,15 +1220,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) { @@ -1244,47 +1245,47 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation9() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ??? + this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})", cu); // ??? } public void testNewSingleMemberAnnotation10() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ??? + this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})", cu); // ??? } public void testNewSingleMemberAnnotation11() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); String expected = "@annot.Foo({@Bar(88), \"two\"})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation11(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation11(ModifiedDeclaration declaration) { @@ -1301,31 +1302,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation12() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Bar(MISSING)})"); // split line + this.assertSourceContains("@Bar(MISSING)})", cu); // split line } public void testNewSingleMemberAnnotation13() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation13(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation13(ModifiedDeclaration declaration) { @@ -1342,32 +1343,32 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation14() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar(MISSING)})"); + this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar(MISSING)})", cu); } public void testNewSingleMemberAnnotation15() throws Exception { this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)"); String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation15(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation15(ModifiedDeclaration declaration) { @@ -1384,15 +1385,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation16() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))"); String expected = "@annot.Foo({@annot.Bar(55),@Bar(88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation16(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation16(ModifiedDeclaration declaration) { @@ -1409,15 +1410,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation17() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); String expected = "@annot.Foo(nestedAnnotations={@Bar(88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation17(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation17(ModifiedDeclaration declaration) { @@ -1434,31 +1435,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewSingleMemberAnnotation18() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Bar(MISSING)})"); // ??? + this.assertSourceContains("@Bar(MISSING)})", cu); // ??? } public void testNewSingleMemberAnnotation19() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation19(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation19(ModifiedDeclaration declaration) { @@ -1476,15 +1477,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation20(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation20(ModifiedDeclaration declaration) { @@ -1502,31 +1503,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("NotBar", "int value();"); this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newSingleMemberAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar(MISSING)})"); + this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar(MISSING)})", cu); } public void testNewSingleMemberAnnotation22() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation22(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewSingleMemberAnnotation22(ModifiedDeclaration declaration) { @@ -1541,14 +1542,14 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration); } }); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar(xxx=88))"); + this.assertSourceContains("@Foo(nestedAnnotations=@Bar(xxx=88))", cu); } void editNewNormalAnnotation1(ModifiedDeclaration declaration) { @@ -1563,14 +1564,14 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration); } }); - this.assertSourceContains("@Foo(@Bar(xxx=88))"); + this.assertSourceContains("@Foo(@Bar(xxx=88))", cu); } void editNewNormalAnnotation2(ModifiedDeclaration declaration) { @@ -1585,15 +1586,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation3(ModifiedDeclaration declaration) { @@ -1608,15 +1609,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); String expected = "@Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation4(ModifiedDeclaration declaration) { @@ -1631,15 +1632,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation5(ModifiedDeclaration declaration) { @@ -1654,15 +1655,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation6(ModifiedDeclaration declaration) { @@ -1677,15 +1678,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(xxx = 88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation7(ModifiedDeclaration declaration) { @@ -1700,15 +1701,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value(); String xxx();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")"); String expected = "@annot.Foo(xxx=\"something\", value = @Bar(xxx = 88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation8(ModifiedDeclaration declaration) { @@ -1723,47 +1724,47 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation9() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar()})"); + this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar()})", cu); } public void testNewNormalAnnotation10() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar()})"); + this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar()})", cu); } public void testNewNormalAnnotation11() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); String expected = "@annot.Foo({@Bar(xxx=88), \"two\"})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation11(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation11(ModifiedDeclaration declaration) { @@ -1778,31 +1779,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation12() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@Bar()})"); // split line + this.assertSourceContains("@Bar()})", cu); // split line } public void testNewNormalAnnotation13() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation13(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation13(ModifiedDeclaration declaration) { @@ -1817,32 +1818,32 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation14() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(7)"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar()})"); + this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar()})", cu); } public void testNewNormalAnnotation15() throws Exception { this.createAnnotationAndMembers("NotBar", "int xxx();"); this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)"); String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation15(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation15(ModifiedDeclaration declaration) { @@ -1857,15 +1858,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation16() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))"); String expected = "@annot.Foo({@annot.Bar(55),@Bar(xxx=88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation16(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation16(ModifiedDeclaration declaration) { @@ -1880,15 +1881,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation17() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); String expected = "@annot.Foo(nestedAnnotations={@Bar(xxx=88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation17(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation17(ModifiedDeclaration declaration) { @@ -1903,31 +1904,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testNewNormalAnnotation18() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@Bar()})"); // split line + this.assertSourceContains("@Bar()})", cu); // split line } public void testNewNormalAnnotation19() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation19(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation19(ModifiedDeclaration declaration) { @@ -1943,15 +1944,15 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("NotBar", "int xxx();"); this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation20(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation20(ModifiedDeclaration declaration) { @@ -1967,31 +1968,31 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe this.createAnnotationAndMembers("NotBar", "int xxx();"); this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); + this.assertSourceDoesNotContain("@Bar", cu); DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newNormalAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar()})"); + this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar()})", cu); } public void testNewNormalAnnotation22() throws Exception { this.createAnnotationAndMembers("Bar", "int xxx();"); this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { + this.assertSourceDoesNotContain(expected, cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation22(declaration); } }); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } void editNewNormalAnnotation22(ModifiedDeclaration declaration) { @@ -2004,215 +2005,215 @@ public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTe public void testMoveAnnotation1() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(00))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(00))"); String expected = "@annot.Foo({null,@annot.Bar(00)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(1); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation2() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({null, @annot.Bar(11)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({null, @annot.Bar(11)})"); String expected = "@annot.Foo(@annot.Bar(11))"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation3() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33)})"); String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation4() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33), @annot.Bar(44)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33), @annot.Bar(44)})"); String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation5() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); String expected = "@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(22)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation6() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), @annot.Bar(00)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation7() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})"); String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation8() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})"); String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})"; - this.assertSourceDoesNotContain(expected); + this.assertSourceDoesNotContain(expected, cu); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation9() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})"; - this.createTestType(expected); // the source should be unchanged + ICompilationUnit cu = this.createTestType(expected); // the source should be unchanged IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(3); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation10() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11)})"); String expected = "@annot.Foo(@annot.Bar(00))"; IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(1); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation11() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(00))"); + ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(00))"); IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); iaa.moveAnnotation(0); - this.assertSourceDoesNotContain("Foo"); + this.assertSourceDoesNotContain("Foo", cu); } public void testMoveAnnotation12() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), null, @annot.Bar(22)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), null, @annot.Bar(22)})"); String expected = "@annot.Foo(@annot.Bar(22))"; IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } public void testMoveAnnotation13() throws Exception { this.createAnnotationAndMembers("Bar", "int value();"); this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(33)})"); + ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(33)})"); String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11)})"; IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(this.idField().getAstRoot()); + IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(cu), idaa); + Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); iaa.moveAnnotation(0); - this.assertSourceContains(expected); + this.assertSourceContains(expected, cu); } } diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java index 0c7e7eaff6..a091ff3a53 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; +import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.Expression; @@ -31,15 +32,15 @@ public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase } private void createAnnotation(String annotationName) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " {}"); + this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " {}"); } public void testAnnotation1() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isMarkerAnnotation()); @@ -47,10 +48,10 @@ public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testAnnotation2() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(1) @annot.Foo(2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(1) @annot.Foo(2)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isSingleMemberAnnotation()); @@ -61,10 +62,10 @@ public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testAnnotation3() throws Exception { this.createAnnotation("Foo"); - this.createTestType("annot.Foo", "@Foo"); + ICompilationUnit cu = this.createTestType("annot.Foo", "@Foo"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); assertEquals("Foo", annotation.getTypeName().getFullyQualifiedName()); assertTrue(annotation.isMarkerAnnotation()); @@ -72,101 +73,101 @@ public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testAnnotationNull1() throws Exception { this.createAnnotation("Foo"); - this.createTestType(); + ICompilationUnit cu = this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); } public void testAnnotationNull2() throws Exception { this.createAnnotation("Foo"); this.createAnnotation("Fop"); - this.createTestType("@annot.Fop"); + ICompilationUnit cu = this.createTestType("@annot.Fop"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); - this.assertSourceContains("@annot.Fop"); + this.assertSourceContains("@annot.Fop", cu); } public void testAnnotationNull3() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); // un-qualified name DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); - this.assertSourceContains("@annot.Foo"); + this.assertSourceContains("@annot.Foo", cu); } public void testRemoveAnnotation1() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); - this.assertSourceContains("@annot.Foo"); + ICompilationUnit cu = this.createTestType("@annot.Foo"); + this.assertSourceContains("@annot.Foo", cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("@annot.Foo"); + this.assertSourceDoesNotContain("@annot.Foo", cu); } public void testRemoveAnnotation2() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(1) @annot.Foo(2)"); - this.assertSourceContains("@annot.Foo(1) @annot.Foo(2)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(1) @annot.Foo(2)"); + this.assertSourceContains("@annot.Foo(1) @annot.Foo(2)", cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.removeAnnotation(); - this.assertSourceDoesNotContain("@annot.Foo(1)"); - this.assertSourceContains("@annot.Foo(2)"); + this.assertSourceDoesNotContain("@annot.Foo(1)", cu); + this.assertSourceContains("@annot.Foo(2)", cu); } public void testNewMarkerAnnotation1() throws Exception { this.createAnnotation("Foo"); - this.createTestType(); - this.assertSourceDoesNotContain("@annot.Foo"); + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@annot.Foo", cu); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); + this.assertSourceContains("import annot.Foo;", cu); + this.assertSourceContains("@Foo", cu); } public void testNewMarkerAnnotation2() throws Exception { this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(88)"); + ICompilationUnit cu = this.createTestType("@annot.Foo(88)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(this.idField().getAstRoot()); + AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(cu), daa); + Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu)); assertNotNull(annotation); aa.newMarkerAnnotation(); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); - this.assertSourceDoesNotContain("@annot.Foo(88)"); + this.assertSourceContains("import annot.Foo;", cu); + this.assertSourceContains("@Foo", cu); + this.assertSourceDoesNotContain("@annot.Foo(88)", cu); } public void testNewSingleMemberAnnotation() throws Exception { this.createAnnotation("Foo"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { SimpleDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation(declaration); } }); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo(\"test string literal\")"); + this.assertSourceContains("import annot.Foo;", cu); + this.assertSourceContains("@Foo(\"test string literal\")", cu); } void editNewSingleMemberAnnotation(ModifiedDeclaration declaration) { @@ -181,15 +182,15 @@ public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase public void testNewNormalAnnotation() throws Exception { this.createAnnotation("Foo"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { + ICompilationUnit cu = this.createTestType(); + this.assertSourceDoesNotContain("@Foo", cu); + this.idField(cu).edit(new Member.Editor() { public void edit(ModifiedDeclaration declaration) { SimpleDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation(declaration); } }); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo(bar=\"test string literal\")"); + this.assertSourceContains("import annot.Foo;", cu); + this.assertSourceContains("@Foo(bar=\"test string literal\")", cu); } void editNewNormalAnnotation(ModifiedDeclaration declaration) { diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java index 956727ba8e..8efb3bef1b 100644 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java +++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/utility/jdt/TypeTests.java @@ -9,15 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.core.tests.internal.utility.jdt; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.internal.utility.jdt.JDTType; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.ICompilationUnit; public class TypeTests extends AnnotationTestCase { - private IType jdtType; - private JDTType testType; - - public TypeTests(String name) { super(name); } @@ -25,19 +21,31 @@ public class TypeTests extends AnnotationTestCase { @Override protected void setUp() throws Exception { super.setUp(); - this.jdtType = this.createTestType(); - this.testType = this.buildType(this.jdtType); + } + + protected ICompilationUnit createCompilationUnit(String source) throws CoreException { + return this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, source); } @Override protected void tearDown() throws Exception { - this.testType = null; - this.jdtType = null; super.tearDown(); } - public void testName() throws Exception { - assertEquals(TYPE_NAME, this.testType.getName()); + public void test1() throws Exception { + ICompilationUnit jdtCompilationUnit = this.createCompilationUnit(this.buildTest1Source()); + assertNotNull(jdtCompilationUnit); + } + + private String buildTest1Source() { + StringBuilder sb = new StringBuilder(); + sb.append("public class ").append(TYPE_NAME).append(" {").append(CR); + sb.append(" private int id;").append(CR); + sb.append(" public int getId() {").append(CR); + sb.append(" return this.id;").append(CR); + sb.append(" }").append(CR); + sb.append("}").append(CR); + return sb.toString(); } } |