defectVarityManager.saveDefectVarity(defectVarity);
defectVarityDao.verify();
}
public void testAddAndRemoveDefectVarity() throws Exception {
DefectVarity defectVarity = new DefectVarity();
// set required fields
// set expected behavior on dao
defectVarityDao.expects(once()).method("saveDefectVarity")
.with(same(defectVarity)).isVoid();
defectVarityManager.saveDefectVarity(defectVarity);
defectVarityDao.verify();
// reset expectations
defectVarityDao.reset();
defectVarityDao.expects(once()).method("removeDefectVarity").with(eq(new Long(defectVarityId)));
defectVarityManager.removeDefectVarity(defectVarityId);
defectVarityDao.verify();
// reset expectations
defectVarityDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(DefectVarity.class, defectVarity.getVarityId());
defectVarityDao.expects(once()).method("removeDefectVarity").isVoid();
defectVarityDao.expects(once()).method("getDefectVarity").will(throwException(ex));
defectVarityManager.removeDefectVarity(defectVarityId);
try {
defectVarityManager.getDefectVarity(defectVarityId);