cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r479224 - /incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
Date Sat, 25 Nov 2006 22:53:14 GMT
Author: aadamchik
Date: Sat Nov 25 14:53:13 2006
New Revision: 479224

URL: http://svn.apache.org/viewvc?view=rev&rev=479224
Log:
CAY-682:Generic Cayenne POJO enhancer
(starting to-many tests)

Modified:
    incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java

Modified: incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java?view=diff&rev=479224&r1=479223&r2=479224
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
(original)
+++ incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/OneToManyObjectTest.java
Sat Nov 25 14:53:13 2006
@@ -19,7 +19,6 @@
 package org.apache.cayenne.itest.pojo;
 
 import java.lang.reflect.Field;
-import java.util.Collection;
 import java.util.List;
 
 import org.apache.cayenne.query.SelectQuery;
@@ -41,6 +40,12 @@
                 16, 5
         });
 
+        getDbHelper().insert("many_to_one_entity1", new String[] {
+                "id", "one_to_many_entity1_id"
+        }, new Object[] {
+                17, 5
+        });
+
         SelectQuery q = new SelectQuery(OneToManyEntity1.class);
         List results = context.performQuery(q);
         assertEquals(1, results.size());
@@ -50,9 +55,35 @@
         Field f = OneToManyEntity1.class.getDeclaredField("$cay_faultResolved_toMany");
         assertEquals(Boolean.FALSE, f.get(o1));
 
-        Collection<ManyToOneEntity1> or = o1.getToMany();
+        List<ManyToOneEntity1> or = o1.getToMany();
         assertNotNull(or);
-        
+
         assertEquals(Boolean.TRUE, f.get(o1));
+        assertEquals(2, or.size());
+        assertSame(o1, or.get(0).getToOne());
+    }
+
+    public void testNew() throws Exception {
+        getDbHelper().deleteAll("many_to_one_entity1");
+        getDbHelper().deleteAll("one_to_many_entity1");
+
+        OneToManyEntity1 o1 = (OneToManyEntity1) context
+                .newObject(OneToManyEntity1.class);
+        assertNotNull(o1.getToMany());
+        assertEquals(0, o1.getToMany().size());
+
+        ManyToOneEntity1 o2 = (ManyToOneEntity1) context
+                .newObject(ManyToOneEntity1.class);
+        o1.getToMany().add(o2);
+
+        assertEquals(1, o1.getToMany().size());
+  
+        ManyToOneEntity1 o3 = (ManyToOneEntity1) context
+                .newObject(ManyToOneEntity1.class);
+        o1.getToMany().add(o3);
+
+        context.commitChanges();
+        assertEquals(2, getDbHelper().getRowCount("many_to_one_entity1"));
+        assertEquals(1, getDbHelper().getRowCount("one_to_many_entity1"));
     }
 }



Mime
View raw message