defectZoneManager.saveDefectZone(defectZone);
defectZoneDao.verify();
}
public void testAddAndRemoveDefectZone() throws Exception {
DefectZone defectZone = new DefectZone();
// set required fields
// set expected behavior on dao
defectZoneDao.expects(once()).method("saveDefectZone")
.with(same(defectZone)).isVoid();
defectZoneManager.saveDefectZone(defectZone);
defectZoneDao.verify();
// reset expectations
defectZoneDao.reset();
defectZoneDao.expects(once()).method("removeDefectZone").with(eq(new Long(defectZoneId)));
defectZoneManager.removeDefectZone(defectZoneId);
defectZoneDao.verify();
// reset expectations
defectZoneDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(DefectZone.class, defectZone.getDefectZoneId());
defectZoneDao.expects(once()).method("removeDefectZone").isVoid();
defectZoneDao.expects(once()).method("getDefectZone").will(throwException(ex));
defectZoneManager.removeDefectZone(defectZoneId);
try {
defectZoneManager.getDefectZone(defectZoneId);