⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 departmentactiontest.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.core.department.action;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import junit.framework.TestCase;

import cn.myapps.core.department.ejb.DepartmentVO;
import cn.myapps.util.sequence.Sequence;

public class DepartmentActionTest extends TestCase {

	private DepartmentAction action;
	String departmentName=null;
    String SuperiorId=null;
    DepartmentVO department=new DepartmentVO();
	protected void setUp() throws Exception {
		super.setUp();
		action = new DepartmentAction();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doSave()'
	 */
	
	public void testDoSave() throws Exception {
		 DepartmentVO depart=new DepartmentVO();
		departmentName = "b部";
		SuperiorId="1154018281061000";
        
		department.setName(departmentName);
		
		
		
		action.setContent(department);
		action.set_superiorid(SuperiorId);
		action.doSave();    //保存前检索是否有相同名字。
		doView();
		doList();
		doEdit();
		doSelect();
		doDelete();
		

	}
	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doView()'
	 */
	public void doView() throws Exception {
		String id = action.getContent().getId();
		HashMap mp = new HashMap();
		mp.put("id", new String[] { id });

		action.getContext().setParameters(mp);
		action.doView();

		String afterViewId = action.getContent().getId();
		assertEquals(afterViewId, id);

	}
	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doList()'
	 */
	public void doList() throws Exception {

		HashMap mp = new HashMap();
		mp.put("s_name", departmentName);
		action.getContext().setParameters(mp);
		action.doList();
		Collection data = action.getDatas().datas;
		assertNotNull(data);
		DepartmentVO dep = (DepartmentVO) data.iterator().next();
		assertEquals(dep.getName(), departmentName);

	}
	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doEdit()'
	 */
	public void doEdit() throws Exception {

		String id = action.getContent().getId();
		HashMap mp = new HashMap();
		mp.put("id", new String[] { id });

		action.getContext().setParameters(mp);
		action.doEdit();
       

	}
	

	
	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doDelete()'
	 */

	public void doDelete() throws Exception {
        
		String id = action.getContent().getId();
		action.set_selects(new String[] { id });
		action.doDelete();
		DepartmentAction actions=new DepartmentAction();
		HashMap mp = new HashMap();
		mp.put("s_name", departmentName);
		action.getContext().setParameters(mp);
		action.doList();
		Collection data = action.getDatas().datas;
		assertFalse(data.size()>0);
		
	
		

	}

	/*
	 * Test method for 'cn.myapps.core.action.DepartmentAction.doSelect()'
	 */

	public void doSelect() throws Exception {

		String id = action.getContent().getId();
		HashMap mp = new HashMap();
		mp.put("s_id",id);
		action.getContext().setParameters(mp);
		action.doSelect();
		Collection _deptSelect=action.get_deptSelect();
		assertNotNull(_deptSelect);
		DepartmentVO dep = (DepartmentVO) _deptSelect.iterator().next();
		assertEquals(dep.getId(), id);
		
		

	}
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -