Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-02-12 20:43:40 +0000
committerkmoore2008-02-12 20:43:40 +0000
commitccd6bb486b14b9d68071588cd0488d5e6e65edbd (patch)
tree91772296dd908a9bd110740842c507dddf3ad56a /jpa/tests/org.eclipse.jpt.core.tests
parent084ad7883a9937057a67ed9b3fbd011cad1788ac (diff)
downloadwebtools.dali-ccd6bb486b14b9d68071588cd0488d5e6e65edbd.tar.gz
webtools.dali-ccd6bb486b14b9d68071588cd0488d5e6e65edbd.tar.xz
webtools.dali-ccd6bb486b14b9d68071588cd0488d5e6e65edbd.zip
fixed orderBy problems, created 3 booleans to hold state
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.core.tests')
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaManyToManyMappingTests.java113
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/java/JavaOneToManyMappingTests.java98
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlManyToManyMappingTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlOneToManyMappingTests.java2
4 files changed, 109 insertions, 106 deletions
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 44566773a5..4e6a3cadae 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
@@ -813,98 +813,111 @@ public class JavaManyToManyMappingTests extends ContextModelTestCase
assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
- public void testIsNoOrdering() throws Exception {
+ public void testUpdateNoOrdering() throws Exception {
createTestEntityWithManyToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IManyToManyMapping manyToManyMapping = (IManyToManyMapping) persistentAttribute.getMapping();
+ JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
+ JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
+
assertTrue(manyToManyMapping.isNoOrdering());
-
- manyToManyMapping.setOrderBy("foo");
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
+
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
assertFalse(manyToManyMapping.isNoOrdering());
- manyToManyMapping.setOrderBy(null);
+ OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
+ orderBy.setValue("newOrderBy");
+ assertFalse(manyToManyMapping.isNoOrdering());
+
+ //set orderBy to null in the resource model
+ attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
assertTrue(manyToManyMapping.isNoOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
- public void testSetNoOrdering() throws Exception {
+ public void testModifyNoOrdering() throws Exception {
createTestEntityWithManyToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IManyToManyMapping manyToManyMapping = (IManyToManyMapping) persistentAttribute.getMapping();
- assertTrue(manyToManyMapping.isNoOrdering());
-
- manyToManyMapping.setOrderBy("foo");
- assertFalse(manyToManyMapping.isNoOrdering());
-
- manyToManyMapping.setNoOrdering();
- assertTrue(manyToManyMapping.isNoOrdering());
- assertNull(manyToManyMapping.getOrderBy());
-
JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
- assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
- }
-
- public void testIsCustomOrdering() throws Exception {
- createTestEntityWithManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IManyToManyMapping manyToManyMapping = (IManyToManyMapping) persistentAttribute.getMapping();
+ assertTrue(manyToManyMapping.isNoOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
- assertFalse(manyToManyMapping.isCustomOrdering());
-
- manyToManyMapping.setOrderBy("foo");
- assertTrue(manyToManyMapping.isCustomOrdering());
-
- manyToManyMapping.setOrderBy(null);
- assertFalse(manyToManyMapping.isCustomOrdering());
- }
-
- public void testIdOrderByPk() throws Exception {
+// manyToManyMapping.setNoOrdering(false); //this does nothing
+// //set mappedBy in the context model, verify resource model updated
+// manyToManyMapping.setOrderBy("newOrderBy");
+// assertEquals("newOrderBy", manyToManyMapping.getOrderBy());
+// OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
+// assertEquals("newOrderBy", orderBy.getValue());
+//
+// //set mappedBy to null in the context model
+// manyToManyMapping.setOrderBy(null);
+// assertNull(manyToManyMapping.getOrderBy());
+// assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
+ }
+
+ public void testUpdatePkOrdering() throws Exception {
createTestEntityWithManyToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IManyToManyMapping manyToManyMapping = (IManyToManyMapping) persistentAttribute.getMapping();
-
- assertFalse(manyToManyMapping.isOrderByPk());
JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
- OrderBy orderBy = (OrderBy) attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
- assertTrue(manyToManyMapping.isOrderByPk());
-
- orderBy.setValue("foo");
- assertFalse(manyToManyMapping.isOrderByPk());
+ assertFalse(manyToManyMapping.isPkOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
+
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
+ assertTrue(manyToManyMapping.isPkOrdering());
+ OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
+ orderBy.setValue("newOrderBy");
+ assertFalse(manyToManyMapping.isPkOrdering());
+
+ //set orderBy to null in the resource model
attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
- assertFalse(manyToManyMapping.isOrderByPk());
+ assertFalse(manyToManyMapping.isPkOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
-
- public void testSetOrderByPk() throws Exception {
+
+ public void testUpdateCustomOrdering() throws Exception {
createTestEntityWithManyToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IManyToManyMapping manyToManyMapping = (IManyToManyMapping) persistentAttribute.getMapping();
-
- assertFalse(manyToManyMapping.isOrderByPk());
- assertNull(manyToManyMapping.getOrderBy());
-
- manyToManyMapping.setOrderByPk();
JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
-
+
+ assertFalse(manyToManyMapping.isCustomOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
+
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isCustomOrdering());
+
OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
- assertNotNull(orderBy);
- assertNull(orderBy.getValue());
+ orderBy.setValue("newOrderBy");
+ assertTrue(manyToManyMapping.isCustomOrdering());
+
+ //set orderBy to null in the resource model
+ attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
+ assertFalse(manyToManyMapping.isCustomOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
+
}
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 89df5d1083..23f2e24c89 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
@@ -816,94 +816,84 @@ public class JavaOneToManyMappingTests extends ContextModelTestCase
assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
- public void testIsNoOrdering() throws Exception {
+ public void testUpdateNoOrdering() throws Exception {
createTestEntityWithOneToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IOneToManyMapping oneToManyMapping = (IOneToManyMapping) persistentAttribute.getMapping();
+ JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
+ JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
+
assertTrue(oneToManyMapping.isNoOrdering());
-
- oneToManyMapping.setOrderBy("foo");
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
+
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
assertFalse(oneToManyMapping.isNoOrdering());
- oneToManyMapping.setOrderBy(null);
+ OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
+ orderBy.setValue("newOrderBy");
+ assertFalse(oneToManyMapping.isNoOrdering());
+
+ //set orderBy to null in the resource model
+ attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
assertTrue(oneToManyMapping.isNoOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
- public void testSetNoOrdering() throws Exception {
+ public void testUpdatePkOrdering() throws Exception {
createTestEntityWithOneToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IOneToManyMapping oneToManyMapping = (IOneToManyMapping) persistentAttribute.getMapping();
- assertTrue(oneToManyMapping.isNoOrdering());
-
- oneToManyMapping.setOrderBy("foo");
- assertFalse(oneToManyMapping.isNoOrdering());
-
- oneToManyMapping.setNoOrdering();
- assertTrue(oneToManyMapping.isNoOrdering());
- assertNull(oneToManyMapping.getOrderBy());
- }
-
- public void testIsCustomOrdering() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
+ JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
- IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IOneToManyMapping oneToManyMapping = (IOneToManyMapping) persistentAttribute.getMapping();
+ assertFalse(oneToManyMapping.isPkOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
- assertFalse(oneToManyMapping.isCustomOrdering());
-
- oneToManyMapping.setOrderBy("foo");
- assertTrue(oneToManyMapping.isCustomOrdering());
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
+ assertTrue(oneToManyMapping.isPkOrdering());
- oneToManyMapping.setOrderBy(null);
- assertFalse(oneToManyMapping.isCustomOrdering());
+ OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
+ orderBy.setValue("newOrderBy");
+ assertFalse(oneToManyMapping.isPkOrdering());
+
+ //set orderBy to null in the resource model
+ attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isPkOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
- public void testIdOrderByPk() throws Exception {
+ public void testUpdateCustomOrdering() throws Exception {
createTestEntityWithOneToManyMapping();
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
IOneToManyMapping oneToManyMapping = (IOneToManyMapping) persistentAttribute.getMapping();
-
- assertFalse(oneToManyMapping.isOrderByPk());
JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
- OrderBy orderBy = (OrderBy) attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
- assertTrue(oneToManyMapping.isOrderByPk());
-
- orderBy.setValue("foo");
- assertFalse(oneToManyMapping.isOrderByPk());
-
- attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
- assertFalse(oneToManyMapping.isOrderByPk());
- }
-
- public void testSetOrderByPk() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- IPersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
- IOneToManyMapping oneToManyMapping = (IOneToManyMapping) persistentAttribute.getMapping();
+ assertFalse(oneToManyMapping.isCustomOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
- assertFalse(oneToManyMapping.isOrderByPk());
- assertNull(oneToManyMapping.getOrderBy());
-
- oneToManyMapping.setOrderByPk();
+ //set orderBy in the resource model, verify context model updated
+ attributeResource.addAnnotation(OrderBy.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isCustomOrdering());
- JavaPersistentTypeResource typeResource = jpaProject().javaPersistentTypeResource(FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentAttributeResource attributeResource = typeResource.attributes().next();
-
OrderBy orderBy = (OrderBy) attributeResource.annotation(OrderBy.ANNOTATION_NAME);
- assertNotNull(orderBy);
- assertNull(orderBy.getValue());
+ orderBy.setValue("newOrderBy");
+ assertTrue(oneToManyMapping.isCustomOrdering());
+
+ //set orderBy to null in the resource model
+ attributeResource.removeAnnotation(OrderBy.ANNOTATION_NAME);
+ assertFalse(oneToManyMapping.isCustomOrdering());
+ assertNull(attributeResource.annotation(OrderBy.ANNOTATION_NAME));
}
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlManyToManyMappingTests.java
index 5fd5d44bc5..e701113381 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlManyToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlManyToManyMappingTests.java
@@ -320,7 +320,7 @@ public class XmlManyToManyMappingTests extends ContextModelTestCase
xmlManyToManyMapping.setOrderBy("foo");
assertFalse(xmlManyToManyMapping.isNoOrdering());
- xmlManyToManyMapping.setNoOrdering();
+ xmlManyToManyMapping.setNoOrdering(true);
assertTrue(xmlManyToManyMapping.isNoOrdering());
assertNull(xmlManyToManyMapping.getOrderBy());
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlOneToManyMappingTests.java
index af16fd8add..2261c2dfd3 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/context/orm/XmlOneToManyMappingTests.java
@@ -324,7 +324,7 @@ public class XmlOneToManyMappingTests extends ContextModelTestCase
xmlOneToManyMapping.setOrderBy("foo");
assertFalse(xmlOneToManyMapping.isNoOrdering());
- xmlOneToManyMapping.setNoOrdering();
+ xmlOneToManyMapping.setNoOrdering(true);
assertTrue(xmlOneToManyMapping.isNoOrdering());
assertNull(xmlOneToManyMapping.getOrderBy());
}

Back to the top