@Test public void testUpdate() { Product product = productService.findById(16); product.setProductname("平凡的世界-贾平凹"); product.setDescption("平凡的世界-贾平凹"); productService.update(product); }
@Test public void testQuery() { List<Product> list = productService.query("平板", 0, 5); for (Product product : list) { System.out.println( product.getProductname() + "\t" + product.getDescption() + "\t" + product.getCategory().getCategoryname()); } }
@Test public void testSave() { Product product = new Product(); product.setProductname("华为平板电脑"); product.setPrice(78.0f); product.setDescption("华为平板电脑"); Category category = categoryService.findById(7); /*Category category=new Category(); category.setCategoryname("平板");*/ product.setCategory(category); productService.save(product); }