@Test public void testCreateTwice(){ String ctg = "Computer Science"; ctgEjb.createCategory(ctg); try { ctgEjb.createCategory(ctg); fail(); }catch (Exception e){ } }
public Long createCategory(String name){ Category category = new Category(); category.setName(name); em.persist(category); return category.getId(); }
CategoryEjb { public Long createCategory(String name){ Category category = new Category(); category.setName(name); em.persist(category); return category.getId(); } }
CategoryEjb { public Long createCategory(String name){ Category category = new Category(); category.setName(name); em.persist(category); return category.getId(); }  }
CategoryEjb { public Long createCategory(String name){ Category category = new Category(); category.setName(name); em.persist(category); return category.getId(); }  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 Long createCategory(String name){ Category category = new Category(); category.setName(name); em.persist(category); return category.getId(); }  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);  }