コード例 #1
0
ファイル: OrdersProducts.java プロジェクト: DmitryOrlik/eshop
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    OrdersProducts that = (OrdersProducts) o;

    return !(product != null ? !product.equals(that.product) : that.product != null);
  }
コード例 #2
0
 @Override
 public String toString() {
   return "MealsetItem{"
       + "id="
       + id
       + ", price="
       + price
       + ", amount="
       + amount
       + ", mealsetId="
       + mealsetId
       + ", mealset="
       + mealset.getName()
       + ", productId="
       + productId
       + ", product="
       + product.getName()
       + '}';
 }
コード例 #3
0
  public void testPropertyValidatorsAsBeanValidationAnnotation() throws Exception {
    Product p = new Product();
    p.setNumber(66);
    p.setDescription("MOTO");
    p.setFamilyNumber(1);
    p.setSubfamilyNumber(1);
    p.setWarehouseKey(new Warehouse());
    p.setUnitPrice(new BigDecimal("900"));

    XPersistence.getManager().persist(p);
    try {
      XPersistence.commit();
    } catch (RollbackException ex) {
      if (ex.getCause() instanceof ConstraintViolationException) {
        ConstraintViolationException cex = (ConstraintViolationException) ex.getCause();
        assertEquals("1 constraint violation expected", 1, cex.getConstraintViolations().size());
        ConstraintViolation v = cex.getConstraintViolations().iterator().next();
        assertEquals("Property", "description", v.getPropertyPath().toString());
        assertEquals("Message text", "", v.getMessage());
        return;
      }
    }
    fail("A constraint violation exception should be thrown");
  }
コード例 #4
0
  public void testEntityValidatorsAsHibernateAnnotation() throws Exception {
    Product p = new Product();
    p.setNumber(66);
    p.setDescription("BUENO, BONITO, BARATO"); // It's cheap ('BARATO') thus...
    p.setFamilyNumber(1);
    p.setSubfamilyNumber(1);
    p.setWarehouseKey(new Warehouse());
    p.setUnitPrice(new BigDecimal("900")); // ... it cannot cost 900 (max 100)

    XPersistence.getManager().persist(p);
    try {
      XPersistence.commit();
    } catch (RollbackException ex) {
      if (ex.getCause() instanceof ConstraintViolationException) {
        ConstraintViolationException cex = (ConstraintViolationException) ex.getCause();
        assertEquals("1 constraint violation expected", 1, cex.getConstraintViolations().size());
        ConstraintViolation v = cex.getConstraintViolations().iterator().next();
        assertEquals("Bean", "Product", v.getRootBean().getClass().getSimpleName());
        assertEquals("Message text", "", v.getMessage());
        return;
      }
    }
    fail("A constraint violation exception should be thrown");
  }
コード例 #5
0
ファイル: Category.java プロジェクト: villacak/FirstProject
  public Product removeProduct(Product product) {
    getProducts().remove(product);
    product.setCategoryBean(null);

    return product;
  }
コード例 #6
0
ファイル: Category.java プロジェクト: villacak/FirstProject
  public Product addProduct(Product product) {
    getProducts().add(product);
    product.setCategoryBean(this);

    return product;
  }
コード例 #7
0
ファイル: OrdersProducts.java プロジェクト: DmitryOrlik/eshop
 @Override
 public int hashCode() {
   return product != null ? product.hashCode() : 0;
 }