package com.vst.dao;
import java.util.List;
import com.vst.dao.BaseDaoTestCase;
import com.vst.model.DefectZone;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.orm.ObjectRetrievalFailureException;
public class DefectZoneDaoTest extends BaseDaoTestCase {
private Integer defectZoneId = new Integer("1");
private DefectZoneDao dao = null;
public void setDefectZoneDao(DefectZoneDao dao) {
this.dao = dao;
}
public void testAddDefectZone() throws Exception {
DefectZone defectZone = new DefectZone();
// set required fields
dao.saveDefectZone(defectZone);
// verify a primary key was assigned
assertNotNull(defectZone.getDefectZoneId());
// verify set fields are same after save
}
public void testGetDefectZone() throws Exception {
DefectZone defectZone = dao.getDefectZone(defectZoneId);
assertNotNull(defectZone);
}
public void testGetDefectZones() throws Exception {
DefectZone defectZone = new DefectZone();
List results = dao.getDefectZones(defectZone);
assertTrue(results.size() > 0);
}
public void testSaveDefectZone() throws Exception {
DefectZone defectZone = dao.getDefectZone(defectZoneId);
// update required fields
dao.saveDefectZone(defectZone);
}
public void testRemoveDefectZone() throws Exception {
Integer removeId = new Integer("3");
dao.removeDefectZone(removeId);
try {
dao.getDefectZone(removeId);
fail("defectZone found in database");
} catch (ObjectRetrievalFailureException e) {
assertNotNull(e.getMessage());
} catch (InvalidDataAccessApiUsageException e) { // Spring 2.0 throws this one
assertNotNull(e.getMessage());
}
}
}