diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java')
-rw-r--r-- | jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java index b2718ee03a..e8fa64dd6e 100644 --- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/resource/java/NamedNativeQueryTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. + * Copyright (c) 2007, 2011 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. @@ -11,9 +11,9 @@ package org.eclipse.jpt.jpa.core.tests.internal.resource.java; import java.util.Iterator; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jpt.common.core.resource.java.JavaResourceType; import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; import org.eclipse.jpt.jpa.core.resource.java.JPA; -import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation; @SuppressWarnings("nls") @@ -95,25 +95,25 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testNamedNativeQuery() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertNotNull(namedQuery); } public void testGetName() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); } public void testSetName() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithName(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_NAME, namedQuery.getName()); namedQuery.setName("foo"); @@ -129,17 +129,17 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testGetQuery() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); } public void testSetQuery() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_QUERY, namedQuery.getQuery()); namedQuery.setQuery("foo"); @@ -155,17 +155,17 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testGetResultClass() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass()); } public void testSetResultClass() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_CLASS, namedQuery.getResultClass()); namedQuery.setResultClass("foo"); @@ -181,9 +181,9 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testGetFullyQualifiedClass() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithResultClass(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertNotNull(namedQuery.getResultClass()); assertEquals("Result", namedQuery.getFullyQualifiedResultClassName());//bug 196200 changed this @@ -195,17 +195,17 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testGetResultSetMapping() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping()); } public void testSetResultSetMapping() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithResultSetMapping(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); assertEquals(QUERY_RESULT_SET_MAPPING, namedQuery.getResultSetMapping()); namedQuery.setResultSetMapping("foo"); @@ -221,40 +221,40 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testHints() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); - assertEquals(0, namedQuery.hintsSize()); + assertEquals(0, namedQuery.getHintsSize()); } public void testHints2() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0); namedQuery.addHint(1); - assertEquals(2, namedQuery.hintsSize()); + assertEquals(2, namedQuery.getHintsSize()); } public void testHints3() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); - assertEquals(2, namedQuery.hintsSize()); + assertEquals(2, namedQuery.getHintsSize()); } public void testAddHint() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQuery(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("FOO"); namedQuery.addHint(1); @@ -268,73 +268,73 @@ public class NamedNativeQueryTests extends JpaJavaResourceModelTestCase { public void testRemoveHint() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("BAZ"); assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertEquals(3, namedQuery.hintsSize()); + assertEquals(3, namedQuery.getHintsSize()); namedQuery.removeHint(2); assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); - assertEquals(2, namedQuery.hintsSize()); + assertEquals(2, namedQuery.getHintsSize()); 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()); + assertEquals(1, namedQuery.getHintsSize()); assertSourceContains("@NamedNativeQuery(hints = @QueryHint(name = \"BAR\", value = \"FOO\"))", cu); namedQuery.removeHint(0); - assertEquals(0, namedQuery.hintsSize()); + assertEquals(0, namedQuery.getHintsSize()); assertSourceDoesNotContain("@NamedNativeQuery(", cu); } public void testMoveHint() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("BAZ"); assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertEquals(3, namedQuery.hintsSize()); + assertEquals(3, namedQuery.getHintsSize()); namedQuery.moveHint(2, 0); assertEquals("BAR", namedQuery.hintAt(0).getName()); assertNull(namedQuery.hintAt(1).getName()); assertEquals("BAZ", namedQuery.hintAt(2).getName()); - assertEquals(3, namedQuery.hintsSize()); + assertEquals(3, namedQuery.getHintsSize()); assertSourceContains("@NamedNativeQuery(hints = {@QueryHint(name = \"BAR\", value = \"FOO\"), @QueryHint, @QueryHint(name = \"BAZ\")})", cu); } public void testMoveHint2() throws Exception { ICompilationUnit cu = this.createTestNamedNativeQueryWithQueryHints(); - JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + JavaResourceType resourceType = buildJavaResourceType(cu); - NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getAnnotation(JPA.NAMED_NATIVE_QUERY); + NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) resourceType.getAnnotation(0, JPA.NAMED_NATIVE_QUERY); namedQuery.addHint(0).setName("BAZ"); assertEquals("BAZ", namedQuery.hintAt(0).getName()); assertEquals("BAR", namedQuery.hintAt(1).getName()); assertNull(namedQuery.hintAt(2).getName()); - assertEquals(3, namedQuery.hintsSize()); + assertEquals(3, namedQuery.getHintsSize()); namedQuery.moveHint(0, 2); assertNull(namedQuery.hintAt(0).getName()); assertEquals("BAZ", namedQuery.hintAt(1).getName()); assertEquals("BAR", namedQuery.hintAt(2).getName()); - assertEquals(3, namedQuery.hintsSize()); + assertEquals(3, namedQuery.getHintsSize()); assertSourceContains("@NamedNativeQuery(hints = {@QueryHint, @QueryHint(name = \"BAZ\"), @QueryHint(name = \"BAR\", value = \"FOO\")})", cu); } |