Пример #1
0
  public void save() throws Exception {
    GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");

    if (category != null) {
      this.deleteGoods();
      this.deleteCategory();
    }

    category = new GoodsCategory();
    category.setSign("JUnit-TEST");
    category.setName("JUnit测试");
    OgnlUtil.getInstance().setValue("parent.sign", category, "ROOT");
    this.goodsService.save(category);

    Assert.assertNotNull(category.getId());

    Goods goods = new Goods();
    goods.setEngname("test goods");
    goods.setName("测试商品");
    goods.setCategory(category);
    goods.setMarketPrice(BigDecimal.valueOf(0.5));
    goods.setPrice(BigDecimal.valueOf(0.5));
    this.goodsService.save(goods);

    logger.debug("goods sn = " + goods.getSn());
  }
Пример #2
0
 @Test
 public void testFindPager() throws Exception {
   GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");
   List<PropertyFilter> filters = new ArrayList<PropertyFilter>();
   filters.add(new PropertyFilter("EQS_category.sign", category.getSign()));
   this.goodsService.findPager(new Pager<Goods>(), filters);
 }
Пример #3
0
  @Test
  public void testGetCategories() throws Exception {
    List<GoodsCategory> categories = this.goodsService.getCategories("ROOT");

    for (GoodsCategory category : categories) {
      logger.debug(category.getName() + "(" + category.getSign() + ")");
    }
  }
Пример #4
0
 @Test
 public void testCalculateStockNumber() throws Exception {
   GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");
   List<PropertyFilter> filters = new ArrayList<PropertyFilter>();
   filters.add(new PropertyFilter("EQS_category.sign", category.getSign()));
   Long id = this.goodsService.find(filters, "sn", "desc", 0, 1).get(0).getId();
   this.goodsService.calculateStockNumber(id);
 }
Пример #5
0
 public Goods testGetGoods() throws Exception {
   GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");
   List<PropertyFilter> filters = new ArrayList<PropertyFilter>();
   filters.add(new PropertyFilter("EQS_category.sign", category.getSign()));
   List<Goods> goodses = this.goodsService.find(filters, "sn", "desc", 0, 1);
   Assert.assertFalse(goodses.isEmpty());
   return this.goodsService.getGoods(goodses.get(0).getId());
 }
Пример #6
0
 public void deleteGoods() throws Exception {
   GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");
   List<PropertyFilter> filters = new ArrayList<PropertyFilter>();
   filters.add(new PropertyFilter("EQS_category.sign", category.getSign()));
   for (Goods goods : this.goodsService.find(filters, "sn", "asc", 0, 10)) {
     this.goodsService.deleteGoods(goods.getId());
   }
 }
Пример #7
0
  @Test
  public void testGetCategory() throws Exception {
    GoodsCategory category = goodsService.getCategory("JUnit-TEST");

    Assert.assertNotNull(category);

    Assert.assertNotNull(this.goodsService.getCategory(category.getId()));
  }
Пример #8
0
 @Test
 public void testGoodsCategorySignUnique() throws Exception {
   GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");
   this.goodsService.goodsCategorySignUnique("JUnit-TEST", 0l);
   this.goodsService.goodsCategorySignUnique("JUnit-TEST", category.getId());
 }
Пример #9
0
  public void deleteCategory() throws Exception {
    GoodsCategory category = this.goodsService.getCategory("JUnit-TEST");

    this.goodsService.deleteCategory(category.getId());
  }