Ejemplo n.º 1
0
 public void testMultipleTermSelect() throws Exception {
   // Create test setup
   removeAll(Referrer.class);
   Referrer ref1 = new Referrer(1);
   Referrer ref2 = new Referrer(2);
   ref1.setRef(ref2);
   getStore().save(ref1);
   // Select ref1
   List result = getStore().find("find referrer where identity=1 and referrer.ref.identity=2");
   Assert.assertEquals(result.size(), 1);
   Assert.assertEquals(result.get(0), ref1);
 }
Ejemplo n.º 2
0
 public void testSimpleObjectSelect() throws Exception {
   // Create test setup
   removeAll(Referrer.class);
   Referrer ref1 = new Referrer(1);
   Referrer ref2 = new Referrer(2);
   ref1.setRef(ref2);
   ref2.setRef(ref1);
   getStore().save(ref1);
   // Select ref1
   List result = getStore().find("find referrer where referrer.ref=?", new Object[] {ref2});
   Assert.assertEquals(result.size(), 1);
   Assert.assertEquals(result.get(0), ref1);
 }
Ejemplo n.º 3
0
 public void testReferencesLoading() throws Exception {
   // Drop
   removeAll(Referrer.class);
   // Create a list of referrers which refer to a single
   // referrer
   Referrer ref = new Referrer(1);
   getStore().save(ref);
   Referrer refs[] = new Referrer[10];
   for (int i = 0; i < refs.length; i++) {
     refs[i] = new Referrer(10 + i);
     refs[i].setRef(ref);
     getStore().save(refs[i]);
   }
   // Get
   List result = getStore().find("find referrer");
   // Check
   Assert.assertEquals(result.size(), 11);
   for (int i = 0; i < result.size(); i++) {
     Referrer referrer = (Referrer) result.get(i);
     if (referrer.getIdentity() == 1) continue;
     Assert.assertEquals(referrer.getRef(), ref);
   }
 }