measureManager.saveMeasure(measure);
measureDao.verify();
}
public void testAddAndRemoveMeasure() throws Exception {
Measure measure = new Measure();
// set required fields
// set expected behavior on dao
measureDao.expects(once()).method("saveMeasure")
.with(same(measure)).isVoid();
measureManager.saveMeasure(measure);
measureDao.verify();
// reset expectations
measureDao.reset();
measureDao.expects(once()).method("removeMeasure").with(eq(new Long(measureId)));
measureManager.removeMeasure(measureId);
measureDao.verify();
// reset expectations
measureDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(Measure.class, measure.getMeasureId());
measureDao.expects(once()).method("removeMeasure").isVoid();
measureDao.expects(once()).method("getMeasure").will(throwException(ex));
measureManager.removeMeasure(measureId);
try {
measureManager.getMeasure(measureId);