Package org.itnaf.dao

Source Code of org.itnaf.dao.RoleDaoTest

package org.itnaf.dao;

import org.itnaf.Constants;
import org.itnaf.model.Role;

public class RoleDaoTest extends BaseDaoTestCase {
    private Role role = null;
    private RoleDao dao = null;

    public void setRoleDao(RoleDao dao) {
        this.dao = dao;
    }

    public void testGetRoleInvalid() throws Exception {
        role = dao.getRoleByName("badrolename");
        assertNull(role);
    }

    public void testGetRole() throws Exception {
        role = dao.getRoleByName(Constants.USER_ROLE);
        assertNotNull(role);
    }

    public void testUpdateRole() throws Exception {
        role = dao.getRoleByName("user");
        log.debug(role);
        role.setDescription("test descr");

        dao.saveRole(role);
        assertEquals(role.getDescription(), "test descr");
    }

    public void testAddAndRemoveRole() throws Exception {
        role = new Role("testrole");
        role.setDescription("new role descr");

        dao.saveRole(role);
        assertNotNull(role.getName());

        dao.removeRole("testrole");

        endTransaction();

        role = dao.getRoleByName("testrole");
        assertNull(role);
    }
}
TOP

Related Classes of org.itnaf.dao.RoleDaoTest

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.