Package com.vst.dao

Source Code of com.vst.dao.DangerCategoryDaoTest

package com.vst.dao;

import java.util.List;

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

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

public class DangerCategoryDaoTest extends BaseDaoTestCase {
    private Integer dangerCategoryId = new Integer("1");
    private DangerCategoryDao dao = null;

    public void setDangerCategoryDao(DangerCategoryDao dao) {
        this.dao = dao;
    }

    public void testAddDangerCategory() throws Exception {
        DangerCategory dangerCategory = new DangerCategory();

        // set required fields

        dao.saveDangerCategory(dangerCategory);

        // verify a primary key was assigned
        assertNotNull(dangerCategory.getDangerCategoryId());

        // verify set fields are same after save
    }

    public void testGetDangerCategory() throws Exception {
        DangerCategory dangerCategory = dao.getDangerCategory(dangerCategoryId);
        assertNotNull(dangerCategory);
    }

    public void testGetDangerCategorys() throws Exception {
        DangerCategory dangerCategory = new DangerCategory();

        List results = dao.getDangerCategorys(dangerCategory);
        assertTrue(results.size() > 0);
    }

    public void testSaveDangerCategory() throws Exception {
        DangerCategory dangerCategory = dao.getDangerCategory(dangerCategoryId);

        // update required fields

        dao.saveDangerCategory(dangerCategory);

    }

    public void testRemoveDangerCategory() throws Exception {
        Integer removeId = new Integer("3");
        dao.removeDangerCategory(removeId);
        try {
            dao.getDangerCategory(removeId);
            fail("dangerCategory 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.DangerCategoryDaoTest

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.