defectCategoryManager.saveDefectCategory(defectCategory);
defectCategoryDao.verify();
}
public void testAddAndRemoveDefectCategory() throws Exception {
DefectCategory defectCategory = new DefectCategory();
// set required fields
// set expected behavior on dao
defectCategoryDao.expects(once()).method("saveDefectCategory")
.with(same(defectCategory)).isVoid();
defectCategoryManager.saveDefectCategory(defectCategory);
defectCategoryDao.verify();
// reset expectations
defectCategoryDao.reset();
defectCategoryDao.expects(once()).method("removeDefectCategory").with(eq(new Long(defectCategoryId)));
defectCategoryManager.removeDefectCategory(defectCategoryId);
defectCategoryDao.verify();
// reset expectations
defectCategoryDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(DefectCategory.class, defectCategory.getDefectCategoryId());
defectCategoryDao.expects(once()).method("removeDefectCategory").isVoid();
defectCategoryDao.expects(once()).method("getDefectCategory").will(throwException(ex));
defectCategoryManager.removeDefectCategory(defectCategoryId);
try {
defectCategoryManager.getDefectCategory(defectCategoryId);