예제 #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());
  }