materialManager.saveMaterial(material);
materialDao.verify();
}
public void testAddAndRemoveMaterial() throws Exception {
Material material = new Material();
// set required fields
// set expected behavior on dao
materialDao.expects(once()).method("saveMaterial")
.with(same(material)).isVoid();
materialManager.saveMaterial(material);
materialDao.verify();
// reset expectations
materialDao.reset();
materialDao.expects(once()).method("removeMaterial").with(eq(new Long(materialId)));
materialManager.removeMaterial(materialId);
materialDao.verify();
// reset expectations
materialDao.reset();
// remove
Exception ex = new ObjectRetrievalFailureException(Material.class, material.getMaterialId());
materialDao.expects(once()).method("removeMaterial").isVoid();
materialDao.expects(once()).method("getMaterial").will(throwException(ex));
materialManager.removeMaterial(materialId);
try {
materialManager.getMaterial(materialId);