Package com.vst.dao

Source Code of com.vst.dao.DefectZoneDaoTest

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());         
        }
    }
}
TOP

Related Classes of com.vst.dao.DefectZoneDaoTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.