Example #1
0
 public void testOnSelectElementActionAndSelectDeselectFilterWithPaging() throws Exception {
   setConditionValues("L'AJUNTAMENT");
   execute("List.filter");
   assertListRowCount(1);
   execute("List.viewDetail", "row=0");
   assertValueInCollection("ingredients", 0, 1, "AZUCAR");
   assertValueInCollection("ingredients", 9, 1, "AZUCAR");
   execute("List.goNextPage", "collection=ingredients");
   assertValueInCollection("ingredients", 2, 1, "CAFE");
   execute("List.goPreviousPage", "collection=ingredients");
   setConditionValues("ingredients", new String[] {"", Ingredient.findByName("CAFE").getOid()});
   execute("List.filter", "collection=ingredients");
   assertCollectionRowCount("ingredients", 1);
   assertValueInCollection("ingredients", 0, 1, "CAFE");
   checkRowCollection("ingredients", 0);
   assertValue("selectedIngredientSize", "1");
   setConditionValues("ingredients", new String[] {"", ""});
   execute("List.filter", "collection=ingredients");
   assertValue("selectedIngredientSize", "1");
   assertValueInCollection("ingredients", 0, 1, "AZUCAR");
   assertValueInCollection("ingredients", 9, 1, "AZUCAR");
   assertRowCollectionUnchecked("ingredients", 0);
   checkRowCollection("ingredients", 5);
   assertValue("selectedIngredientSize", "2");
   assertRowCollectionUnchecked("ingredients", 0);
   setConditionValues("ingredients", new String[] {"", Ingredient.findByName("CAFE").getOid()});
   execute("List.filter", "collection=ingredients");
   assertCollectionRowCount("ingredients", 1);
   assertValueInCollection("ingredients", 0, 1, "CAFE");
   assertRowCollectionChecked("ingredients", 0);
   uncheckRowCollection("ingredients", 0);
   assertRowCollectionUnchecked("ingredients", 0);
   assertValue("selectedIngredientSize", "1");
 };
Example #2
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();
  }
Example #3
0
  public void testSelectAndFilter() throws Exception {
    assertValueInList(0, 0, "HTML TEST");
    execute("List.viewDetail", "row=0");

    assertCollectionRowCount("ingredients", 2);
    assertValueInCollection("ingredients", 0, 1, "AZUCAR");
    assertValueInCollection("ingredients", 1, 1, "CAFE");
    checkAllCollection("ingredients");

    setConditionValues("ingredients", new String[] {"", Ingredient.findByName("AZUCAR").getOid()});
    execute("List.filter", "collection=ingredients");
    assertCollectionRowCount("ingredients", 1);
    assertRowCollectionChecked("ingredients", 0);

    setConditionValues("ingredients", new String[] {"", ""});
    execute("List.filter", "collection=ingredients");
    assertCollectionRowCount("ingredients", 2);
    assertRowCollectionChecked("ingredients", 0);
    assertRowCollectionChecked("ingredients", 1);
  }