private Item storedItem(String id) {
   Query query = newQuery(Item.class);
   query.descend("_id").constrain(id);
   ObjectSet<Item> result = query.execute();
   Assert.isTrue(result.hasNext());
   return result.next();
 }
Ejemplo n.º 2
0
  public void testDelete() {
    ExtObjectContainer oc = fixture().db();
    initGenericObjects();
    ReflectClass rc = getReflectClass(oc, PERSON_CLASSNAME);
    Assert.isNotNull(rc);
    Query q = oc.query();
    q.constrain(rc);
    ObjectSet results = q.execute();
    while (results.hasNext()) {
      Object o = results.next();
      oc.delete(o);
    }
    oc.commit();

    // now query to make sure there are none left
    q = oc.query();
    q.constrain(rc);
    q.descend("surname").constrain("John");
    results = q.execute();
    Assert.isTrue(results.size() == 0);
  }