@Test public void testNoCategory(){ List<Category> list = ctgEjb.getAllCategories(false); assertEquals(0, list.size()); }
public List<Category> getAllCategories(boolean withSub){ TypedQuery<Category> query = em.createQuery("select c from Category c", Category.class); List<Category> categories = query.getResultList(); if(withSub){ categories.forEach(c -> c.getSubCategories().size()); } return categories; }
CategoryEjb { public List<Category> getAllCategories(boolean withSub){ TypedQuery<Category> query = em.createQuery("select c from Category c", Category.class); List<Category> categories = query.getResultList(); if(withSub){ categories.forEach(c -> c.getSubCategories().size()); } return categories; } }
CategoryEjb { public List<Category> getAllCategories(boolean withSub){ TypedQuery<Category> query = em.createQuery("select c from Category c", Category.class); List<Category> categories = query.getResultList(); if(withSub){ categories.forEach(c -> c.getSubCategories().size()); } return categories; }  }
CategoryEjb { public List<Category> getAllCategories(boolean withSub){ TypedQuery<Category> query = em.createQuery("select c from Category c", Category.class); List<Category> categories = query.getResultList(); if(withSub){ categories.forEach(c -> c.getSubCategories().size()); } return categories; }  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); }
CategoryEjb { public List<Category> getAllCategories(boolean withSub){ TypedQuery<Category> query = em.createQuery("select c from Category c", Category.class); List<Category> categories = query.getResultList(); if(withSub){ categories.forEach(c -> c.getSubCategories().size()); } return categories; }  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);  }