Пример #1
0
  public void testPagingInCollection() throws Exception {
    // create objects in database
    Formula formula = Formula.findByName("HTML TEST");
    Ingredient ingredient = Ingredient.findByName("LECHE");
    for (int x = 0; x <= 12; x++) {
      FormulaIngredient fi = new FormulaIngredient();
      fi.setFormula(formula);
      fi.setIngredient(ingredient);
      XPersistence.getManager().persist(fi);
    }
    XPersistence.commit();

    //
    execute("Mode.detailAndFirst");
    assertValue("name", "HTML TEST");
    assertCollectionRowCount("ingredients", 10);
    checkRowCollection("ingredients", 0);
    execute("List.goNextPage", "collection=ingredients");
    execute("List.goPreviousPage", "collection=ingredients");
    assertRowCollectionChecked("ingredients", 0);

    // remove objects from database
    String sentencia = " DELETE FROM FormulaIngredient WHERE ingredient.oid = :ingredient ";
    Query query = XPersistence.getManager().createQuery(sentencia);
    query.setParameter("ingredient", ingredient.getOid());
    query.executeUpdate();
    XPersistence.commit();
  }