@Test(expected = DataIntegrityViolationException.class) public void deleteCategoryWhenPublicationExistsTest() throws Exception { System.out.println("CategoryService.deleteCategoryWhenPublicationExistsTest"); categoryService.deleteCategoryById(c1.getId()); // should throw exception }
@Test public void deleteCategoryTest() throws Exception { System.out.println("CategoryService.deleteCategoryTest"); Category c = new Category(null, "Patent4", 1.0); int id = categoryService.createCategory(c); int result = categoryService.deleteCategoryById(id); assertTrue("There should be exactly 1 category deleted, but was: " + result, result == 1); }