Package com.vst.dao

Source Code of com.vst.dao.DefectTypeDaoTest

package com.vst.dao;

import java.util.List;

import com.vst.dao.BaseDaoTestCase;
import com.vst.model.DefectType;

import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.orm.ObjectRetrievalFailureException;

public class DefectTypeDaoTest extends BaseDaoTestCase {
    private Integer defectTypeId = new Integer("1");
    private DefectTypeDao dao = null;

    public void setDefectTypeDao(DefectTypeDao dao) {
        this.dao = dao;
    }

    public void testAddDefectType() throws Exception {
        DefectType defectType = new DefectType();

        // set required fields

        dao.saveDefectType(defectType);

        // verify a primary key was assigned
        assertNotNull(defectType.getDefectTypeId());

        // verify set fields are same after save
    }

    public void testGetDefectType() throws Exception {
        DefectType defectType = dao.getDefectType(defectTypeId);
        assertNotNull(defectType);
    }

    public void testGetDefectTypes() throws Exception {
        DefectType defectType = new DefectType();

        List results = dao.getDefectTypes(defectType);
        assertTrue(results.size() > 0);
    }

    public void testSaveDefectType() throws Exception {
        DefectType defectType = dao.getDefectType(defectTypeId);

        // update required fields

        dao.saveDefectType(defectType);

    }

    public void testRemoveDefectType() throws Exception {
        Integer removeId = new Integer("3");
        dao.removeDefectType(removeId);
        try {
            dao.getDefectType(removeId);
            fail("defectType 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.DefectTypeDaoTest

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.