Ejemplo n.º 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();
  }
Ejemplo n.º 2
0
 private void createDeliveryType(int number, String description) {
   DeliveryType type = new DeliveryType();
   type.setNumber(number);
   type.setDescription(description);
   XPersistence.getManager().persist(type);
   XPersistence.commit();
 }
Ejemplo n.º 3
0
 private void deleteDeliveryType(int number) {
   DeliveryType type = XPersistence.getManager().find(DeliveryType.class, number);
   XPersistence.getManager().remove(type);
   XPersistence.commit();
 }