package com.vst.dao;
import java.util.List;
import com.vst.dao.BaseDaoTestCase;
import com.vst.model.DefectRecomendation;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.orm.ObjectRetrievalFailureException;
public class DefectRecomendationDaoTest extends BaseDaoTestCase {
private Integer defectRecomendationId = new Integer("1");
private DefectRecomendationDao dao = null;
public void setDefectRecomendationDao(DefectRecomendationDao dao) {
this.dao = dao;
}
public void testAddDefectRecomendation() throws Exception {
DefectRecomendation defectRecomendation = new DefectRecomendation();
// set required fields
dao.saveDefectRecomendation(defectRecomendation);
// verify a primary key was assigned
assertNotNull(defectRecomendation.getDefectRecomendationId());
// verify set fields are same after save
}
public void testGetDefectRecomendation() throws Exception {
DefectRecomendation defectRecomendation = dao.getDefectRecomendation(defectRecomendationId);
assertNotNull(defectRecomendation);
}
public void testGetDefectRecomendations() throws Exception {
DefectRecomendation defectRecomendation = new DefectRecomendation();
List results = dao.getDefectRecomendations(defectRecomendation);
assertTrue(results.size() > 0);
}
public void testSaveDefectRecomendation() throws Exception {
DefectRecomendation defectRecomendation = dao.getDefectRecomendation(defectRecomendationId);
// update required fields
dao.saveDefectRecomendation(defectRecomendation);
}
public void testRemoveDefectRecomendation() throws Exception {
Integer removeId = new Integer("3");
dao.removeDefectRecomendation(removeId);
try {
dao.getDefectRecomendation(removeId);
fail("defectRecomendation found in database");
} catch (ObjectRetrievalFailureException e) {
assertNotNull(e.getMessage());
} catch (InvalidDataAccessApiUsageException e) { // Spring 2.0 throws this one
assertNotNull(e.getMessage());
}
}
}