Ejemplo n.º 1
0
  public void testCreateModifyAndReadWithDescriptionsListReference() throws Exception {

    // Create
    execute("CRUD.new");
    setValue("number", "66");
    setValue("description", "JUNIT PRODUCT");
    setValue("family.number", "2");
    assertNoErrors();
    setValue("subfamily.number", "12");
    Warehouse warehouseKey = new Warehouse();
    warehouseKey.setNumber(1);
    warehouseKey.setZoneNumber(2);
    setValue("warehouse.KEY", toKeyString(warehouseKey));
    setValue("unitPrice", "125.66");
    assertNoErrors();
    assertNoEditable("unitPriceInPesetas");
    execute("CRUD.save");
    assertNoErrors();

    // Search for verify
    setValue("number", "66");
    execute("CRUD.refresh");
    assertNoErrors();
    assertValue("number", "66");
    assertValue("description", "JUNIT PRODUCT");
    assertValue("family.number", "2");
    assertValue("subfamily.number", "12");
    assertValue("warehouse.KEY", toKeyString(warehouseKey));
    assertValue("unitPrice", "125.66");

    // Modify
    setValue("subfamily.number", "13");
    execute("CRUD.save");
    assertNoErrors();
    assertValue("number", "");
    assertValue("description", "");

    // Verifying just modified
    setValue("number", "66");
    execute("CRUD.refresh");
    assertNoErrors();
    assertValue("number", "66");
    assertValue("description", "JUNIT PRODUCT");
    assertValue("family.number", "2");
    assertValue("subfamily.number", "13");

    // Delete
    execute("CRUD.delete");
    assertMessage("Product deleted successfully");
  }
Ejemplo n.º 2
0
 private void createProduct(int number, String description, int zone) throws Exception {
   Product2 p = new Product2();
   p.setNumber(number);
   p.setDescription(description);
   Family2 f = new Family2();
   f.setNumber(1);
   p.setFamily(f);
   Subfamily2 sf = new Subfamily2();
   sf.setNumber(1);
   p.setSubfamily(sf);
   Warehouse w = new Warehouse();
   w.setNumber(1);
   w.setZoneNumber(zone);
   p.setWarehouse(w);
   p.setUnitPrice(new BigDecimal("1.00"));
   XPersistence.getManager().persist(p);
   XPersistence.commit();
 }
Ejemplo n.º 3
0
 public Warehouse getWarehouse() {
   // In this way because the columns for warehouse can contain
   // 0 for no value
   try {
     if (warehouse != null) warehouse.toString(); // to force load
     return warehouse;
   } catch (EntityNotFoundException ex) {
     return null;
   }
 }
Ejemplo n.º 4
0
  public void testReferencesAsDescriptionListUsesFilterOfDefaultTab() throws Exception {
    execute("CRUD.new");
    execute("Product2.changeLimitZone");

    Warehouse key1 = new Warehouse();
    key1.setZoneNumber(1);
    key1.setNumber(1);
    Warehouse key2 = new Warehouse();
    key2.setZoneNumber(1);
    key2.setNumber(2);
    Warehouse key3 = new Warehouse();
    key3.setZoneNumber(1);
    key3.setNumber(3);

    String[][] warehouses = {
      {"", ""},
      {toKeyString(key1), "CENTRAL VALENCIA"},
      {toKeyString(key3), "VALENCIA NORTE"},
      {toKeyString(key2), "VALENCIA SURETE"}
    };
    assertValidValues("warehouse.KEY", warehouses);
  }
Ejemplo n.º 5
0
  public void testOnChangeDescriptionsListReferenceMultipleKey() throws Exception {
    execute("CRUD.new");
    assertNotExists("zoneOne");

    Warehouse warehouseKeyZone1 = new Warehouse();
    warehouseKeyZone1.setNumber(1);
    warehouseKeyZone1.setZoneNumber(1);
    setValue("warehouse.KEY", toKeyString(warehouseKeyZone1));
    assertExists("zoneOne");

    Warehouse warehouseKeyZone2 = new Warehouse();
    warehouseKeyZone2.setNumber(1);
    warehouseKeyZone2.setZoneNumber(2);
    setValue("warehouse.KEY", toKeyString(warehouseKeyZone2));
    assertNotExists("zoneOne");

    createProduct(66, "JUNIT ZONE 1", 1);
    createProduct(67, "JUNIT ZONE 2", 2);

    setValue("number", "66");
    execute("CRUD.refresh");
    assertNoErrors();
    assertValue("description", "JUNIT ZONE 1");
    assertExists("zoneOne");

    execute("CRUD.new");
    setValue("number", "67");
    execute("CRUD.refresh");
    assertNoErrors();
    assertValue("description", "JUNIT ZONE 2");
    assertNotExists("zoneOne");

    setValue("warehouse.KEY", "");
    assertValue("warehouse.KEY", "");

    deleteProduct(66);
    deleteProduct(67);
  }