Package com.vst.dao

Source Code of com.vst.dao.QuestionTypeDaoTest

package com.vst.dao;

import java.util.List;

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

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

public class QuestionTypeDaoTest extends BaseDaoTestCase {
    private Integer questionTypeId = new Integer("1");
    private QuestionTypeDao dao = null;

    public void setQuestionTypeDao(QuestionTypeDao dao) {
        this.dao = dao;
    }

    public void testAddQuestionType() throws Exception {
        QuestionType questionType = new QuestionType();

        // set required fields

        dao.saveQuestionType(questionType);

        // verify a primary key was assigned
        assertNotNull(questionType.getQuestionTypeId());

        // verify set fields are same after save
    }

    public void testGetQuestionType() throws Exception {
        QuestionType questionType = dao.getQuestionType(questionTypeId);
        assertNotNull(questionType);
    }

    public void testGetQuestionTypes() throws Exception {
        QuestionType questionType = new QuestionType();

        List results = dao.getQuestionTypes(questionType);
        assertTrue(results.size() > 0);
    }

    public void testSaveQuestionType() throws Exception {
        QuestionType questionType = dao.getQuestionType(questionTypeId);

        // update required fields

        dao.saveQuestionType(questionType);

    }

    public void testRemoveQuestionType() throws Exception {
        Integer removeId = new Integer("3");
        dao.removeQuestionType(removeId);
        try {
            dao.getQuestionType(removeId);
            fail("questionType 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.QuestionTypeDaoTest

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.