dangerCategoryManager.saveDangerCategory(dangerCategory);
dangerCategoryDao.verify();
}
public void testAddAndRemoveDangerCategory() throws Exception {
DangerCategory dangerCategory = new DangerCategory();
// set required fields
// set expected behavior on dao
dangerCategoryDao.expects(once()).method("saveDangerCategory")
.with(same(dangerCategory)).isVoid();
dangerCategoryManager.saveDangerCategory(dangerCategory);
dangerCategoryDao.verify();
// reset expectations
dangerCategoryDao.reset();
dangerCategoryDao.expects(once()).method("removeDangerCategory").with(eq(new Long(dangerCategoryId)));
dangerCategoryManager.removeDangerCategory(dangerCategoryId);
dangerCategoryDao.verify();
// reset expectations
dangerCategoryDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(DangerCategory.class, dangerCategory.getDangerCategoryId());
dangerCategoryDao.expects(once()).method("removeDangerCategory").isVoid();
dangerCategoryDao.expects(once()).method("getDangerCategory").will(throwException(ex));
dangerCategoryManager.removeDangerCategory(dangerCategoryId);
try {
dangerCategoryManager.getDangerCategory(dangerCategoryId);