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