Package com.vst.dao

Source Code of com.vst.dao.ObjectTypeDaoTest

package com.vst.dao;

import java.util.List;

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

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

public class ObjectTypeDaoTest extends BaseDaoTestCase {
    private Integer objectTypeId = new Integer("1");
    private ObjectTypeDao dao = null;

    public void setObjectTypeDao(ObjectTypeDao dao) {
        this.dao = dao;
    }

    public void testAddObjectType() throws Exception {
        ObjectType objectType = new ObjectType();

        // set required fields

        dao.saveObjectType(objectType);

        // verify a primary key was assigned
        assertNotNull(objectType.getObjectTypeId());

        // verify set fields are same after save
    }

    public void testGetObjectType() throws Exception {
        ObjectType objectType = dao.getObjectType(objectTypeId);
        assertNotNull(objectType);
    }

    public void testGetObjectTypes() throws Exception {
        ObjectType objectType = new ObjectType();

        List results = dao.getObjectTypes(objectType);
        assertTrue(results.size() > 0);
    }

    public void testSaveObjectType() throws Exception {
        ObjectType objectType = dao.getObjectType(objectTypeId);

        // update required fields

        dao.saveObjectType(objectType);

    }

    public void testRemoveObjectType() throws Exception {
        Integer removeId = new Integer("3");
        dao.removeObjectType(removeId);
        try {
            dao.getObjectType(removeId);
            fail("objectType 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.ObjectTypeDaoTest

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.