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()); }
@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); }
@Test public void testGetCategories() throws Exception { List<GoodsCategory> categories = this.goodsService.getCategories("ROOT"); for (GoodsCategory category : categories) { logger.debug(category.getName() + "(" + category.getSign() + ")"); } }
@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); }
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()); }
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()); } }
@Test public void testGetCategory() throws Exception { GoodsCategory category = goodsService.getCategory("JUnit-TEST"); Assert.assertNotNull(category); Assert.assertNotNull(this.goodsService.getCategory(category.getId())); }
@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()); }
public void deleteCategory() throws Exception { GoodsCategory category = this.goodsService.getCategory("JUnit-TEST"); this.goodsService.deleteCategory(category.getId()); }