@Test public void testGetCategory() { String name = "testGetCategory"; long id = categoryService.createCategory(name); Category ctg = categoryService.getCategory(id, false); assertEquals(name, ctg.getName()); }
public Category getCategory(long id, boolean withSub){ Category category = em.find(Category.class, id); if(withSub && category != null){ category.getSubCategories().size(); } return category; }
CategoryService { public Category getCategory(long id, boolean withSub){ Category category = em.find(Category.class, id); if(withSub && category != null){ category.getSubCategories().size(); } return category; } }
CategoryService { public Category getCategory(long id, boolean withSub){ Category category = em.find(Category.class, id); if(withSub && category != null){ category.getSubCategories().size(); } return category; }  }
CategoryService { public Category getCategory(long id, boolean withSub){ Category category = em.find(Category.class, id); if(withSub && category != null){ category.getSubCategories().size(); } return category; }  Long createCategory(String name); Long createSubCategory(long parentId, String name); List<Category> getAllCategories(boolean withSub); Category getCategory(long id, boolean withSub); SubCategory getSubCategory(long id); }
CategoryService { public Category getCategory(long id, boolean withSub){ Category category = em.find(Category.class, id); if(withSub && category != null){ category.getSubCategories().size(); } return category; }  Long createCategory(String name); Long createSubCategory(long parentId, String name); List<Category> getAllCategories(boolean withSub); Category getCategory(long id, boolean withSub); SubCategory getSubCategory(long id);  }