public void testGetCategoriesByProduct() { int count = jdbcTemplate.queryForInt( "select count(0) from product_category " + "where product_id=1000"); Product product = productSevice.getProductById(1000); List categories = (List) categoryService.getCategoriesByProduct(product); assertEquals("Product should belong to one category", count, categories.size()); assertEquals( "Category name does not match", "Adventure", ((Category) categories.get(0)).getName()); }
public void testAddProductCategory() { Category category = categoryService.getCategoryById(2); // int count = category.getProductCategories().size(); int count = jdbcTemplate.queryForInt("select count(0) from product_category where category_id=2"); Product product = productSevice.getProductById(1005); ProductCategory productCategory = new ProductCategory(category, product); categoryService.saveProductCategory(productCategory); category.getProductCategories().add(productCategory); Category cat = categoryService.saveCategory(category); category = categoryService.getCategoryById(cat.getCategoryId()); assertEquals( "The new product category mapping was not added", count + 1, category.getProductCategories().size()); }
public void testGetAwardCategoryForProduct() { Product product = productSevice.getProductById(1005); Collection awardCategories = categoryService.getAwardCategoriesForProduct(product); assertEquals("List should be empty", 0, awardCategories.size()); }