Commit 4395a8dd authored by gaoyan's avatar gaoyan

报错修改

parent bd7d7f76
...@@ -65,7 +65,17 @@ ...@@ -65,7 +65,17 @@
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>8.5.29</version>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apps-edoc</artifactId> <artifactId>apps-edoc</artifactId>
......
/**
* Author : xuqw
* Date : 2015年9月21日 下午2:47:09
*
* Copyright (C) 2015 Seeyon, Inc. All rights reserved.
*
* This software is the proprietary information of Seeyon, Inc.
* Use is subject to license terms.
*/
package com.seeyon.apps.edoc.test.api;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.seeyon.apps.collaboration.vo.AttachmentVO;
import com.seeyon.apps.edoc.api.EdocApi;
import com.seeyon.apps.edoc.api.ReceiveEdocParam;
import com.seeyon.apps.edoc.bo.EdocBodyBO;
import com.seeyon.apps.edoc.bo.EdocElementBO;
import com.seeyon.apps.edoc.bo.EdocSummaryBO;
import com.seeyon.apps.edoc.bo.EdocSummaryComplexBO;
import com.seeyon.apps.edoc.bo.SimpleEdocSummary;
import com.seeyon.apps.edoc.enums.EdocEnum;
import com.seeyon.apps.edoc.test.constants.EdocContant;
import com.seeyon.apps.edoc.test.utils.SeeyonTestUtil;
import com.seeyon.ctp.TestCaseBase;
import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.GlobalNames;
import com.seeyon.ctp.common.authenticate.domain.User;
import com.seeyon.ctp.common.authenticate.domain.UserHelper;
import com.seeyon.ctp.common.constants.ApplicationCategoryEnum;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.filemanager.manager.FileManager;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
import com.seeyon.ctp.common.po.filemanager.Attachment;
import com.seeyon.ctp.common.po.filemanager.V3XFile;
import com.seeyon.ctp.common.po.template.CtpTemplate;
import com.seeyon.ctp.organization.bo.V3xOrgAccount;
import com.seeyon.ctp.organization.bo.V3xOrgMember;
import com.seeyon.ctp.organization.manager.OrgManager;
import com.seeyon.ctp.privilege.manager.PrivilegeMenuManager;
import com.seeyon.ctp.util.UUIDLong;
import com.seeyon.ctp.util.json.JSONUtil;
import com.seeyon.ctp.utils.AssertUtils;
import com.seeyon.v3x.edoc.domain.EdocSummary;
/**
* <p>Title : 公文</p>
* <p>Description : 公文接口单元测试</p>
* <p>Copyright : Copyright (c) 2015</p>
* <p>Company : seeyon.com</p>
*/
public class EdocApiImplTest extends TestCaseBase {
private static final Logger logger = Logger.getLogger(EdocApiImplTest.class);
private static EdocApi edocApi = null;
private static OrgManager orgManager = null;
private static FileManager fileManager = null;
@BeforeClass
public static void initData() {
//bean加载
edocApi = (EdocApi) AppContext.getBean("edocApi");
orgManager = (OrgManager) AppContext.getBean("orgManager");
fileManager = (FileManager)AppContext.getBean("fileManager");
logger.info("会议单元测试 - 数据初始化开始...");
try {
EdocApiImplDataUtil.initData(true);
} catch (BusinessException e) {
logger.error("初始化会议单元测试数据失败..., 业务异常", e);
} catch (Exception e) {
logger.error("初始化会议单元测试数据失败...", e);
}
logger.info("会议单元测试 - 数据初始化结束...");
}
@Before
public void beforTest() {
//注册session
SeeyonTestUtil.generateSession();
}
@After
public void afterTest(){
SeeyonTestUtil.destroySession();
}
/**
* 测试获取当前待办人
* @Author : xuqw
* @Date : 2015年10月16日下午4:26:45
* @throws BusinessException
*/
//@Test
public void testGetCurrentNodesInfo() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createSimpleEdocSummary(subject);
String node = edocApi.getCurrentNodesInfo(summary.getId());
AssertUtils.assertEquals(edoc1.getName(), node);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 测试获取公文数据,正常获取
* @Author : xuqw
* @Date : 2015年10月16日下午4:13:43
* @throws BusinessException
*/
//@Test
public void testGetEdocSummary_0() throws BusinessException {
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummary(subject);
long summaryId = summary.getId();
EdocSummaryBO sBO = edocApi.getEdocSummary(summaryId);
AssertUtils.assertNotNull(sBO);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
private V3xOrgMember createSessionUser(String loginName) throws BusinessException {
V3xOrgMember edoc1 = orgManager.getMemberByLoginName(loginName);
User user = SeeyonTestUtil.createSessionUser(edoc1);
AppContext.putThreadContext(GlobalNames.SESSION_CONTEXT_USERINFO_KEY, user);
// 添加菜单资源
PrivilegeMenuManager pcheck = (PrivilegeMenuManager) AppContext.getBean("privilegeMenuManager");
UserHelper.setResourceJsonStr(JSONUtil.toJSONString(pcheck.getResourceCodeOnlySystem(user.getId(), user.getLoginAccount())));
return edoc1;
}
/**
* 测试获取公文数据,异常
* @Author : xuqw
* @Date : 2015年10月16日下午4:22:52
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testGetEdocSummary_1() throws BusinessException {
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.getEdocSummary(null);
}
/**
* 测试通过流程ID获取公文,正常获取数据
* @Author : xuqw
* @Date : 2015年10月16日下午4:23:58
* @throws BusinessException
*/
//@Test
public void testGetEdocSummaryByProcessId_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createSimpleEdocSummary(subject);
String processId = summary.getProcessId();
EdocSummaryBO sBO = edocApi.getEdocSummaryByProcessId(Long.parseLong(processId));
AssertUtils.assertNotNull(sBO);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 测试通过流程ID获取公文,异常获取数据
* @Author : xuqw
* @Date : 2015年10月16日下午4:23:58
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testGetEdocSummaryByProcessId_1() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.getEdocSummaryByProcessId(null);
}
/**
* 测试获取公文正文
* @Author : xuqw
* @Date : 2015年10月16日下午4:25:53
* @throws BusinessException
*/
//@Test
public void testGetEdocBodys() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummary(subject);
long summaryId = summary.getId();
List<EdocBodyBO> sBO = edocApi.getEdocBodys(summaryId);
AssertUtils.assertCollectionNotEmpty(sBO);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 根据节点期限超期时间来查找待办公文数据,正常获取
* @Author : xuqw
* @Date : 2015年10月16日下午4:26:08
* @throws BusinessException
*/
//@Test
public void testFindMyPendingEdocByExpectedProcessTime_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_流程超期_" + UUIDLong.longUUID();
EdocSummaryDataUtil.createEdocSummaryWithNodeDeadlin(subject);
Date nowDate = new Date();
Map<String, Object> params = new HashMap<String, Object>();
params.put("currentUserID", edoc1.getId());
params.put("beginDate", new Date(nowDate.getTime() - 1000 * 60 * 10));
params.put("endDate", new Date(nowDate.getTime() + 1000 * 60 * 60 * 24 * 3));
List<EdocSummaryComplexBO> summarys = edocApi.findMyPendingEdocByExpectedProcessTime(params);
AssertUtils.assertCollectionNotEmpty(summarys);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 根据节点期限超期时间来查找待办公文数据,获取数据空
* @Author : xuqw
* @Date : 2015年10月16日下午4:26:08
* @throws BusinessException
*/
//@Test
public void testFindMyPendingEdocByExpectedProcessTime_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
Date nowDate = new Date();
Map<String, Object> params = new HashMap<String, Object>();
params.put("currentUserID", edoc1.getId());
params.put("beginDate", new Date(nowDate.getTime() - 1000 * 60 * 60 * 24 * 2));//两天前
params.put("endDate", new Date(nowDate.getTime() - 1000 * 60 * 60 * 24 * 1));//一天前
List<EdocSummaryComplexBO> summarys = edocApi.findMyPendingEdocByExpectedProcessTime(params);
AssertUtils.assertCollectionIsEmpty(summarys);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 根据节点期限超期时间来查找待办公文数据,异常
* @Author : xuqw
* @Date : 2015年10月16日下午4:26:08
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testFindMyPendingEdocByExpectedProcessTime_2() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.findMyPendingEdocByExpectedProcessTime(null);
}
/**
* 测试 判断某人是否有某个单位的公文发起权, 有发文权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_0() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc1_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc1 = createSessionUser("edoc1");
long memberId = edoc1.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.sendEdoc.ordinal());
AssertUtils.assertTrue(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc1.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权, 有收文权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_1() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc1_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc1 = createSessionUser("edoc1");
long memberId = edoc1.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.recEdoc.ordinal());
AssertUtils.assertTrue(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc1.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权, 有签报权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_2() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc1_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc1 = createSessionUser("edoc1");
long memberId = edoc1.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.signReport.ordinal());
AssertUtils.assertTrue(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc1.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权, 没有发文权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_3() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc2_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc2 = createSessionUser("edoc2");
long memberId = edoc2.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.sendEdoc.ordinal());
AssertUtils.assertFalse(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc2.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权, 没有收文权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_4() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc2_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc2 = createSessionUser("edoc2");
long memberId = edoc2.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.recEdoc.ordinal());
AssertUtils.assertFalse(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc2.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权,没有签报权限
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test
public void testIsEdocCreateRole_5() throws BusinessException{
try {
EdocSummaryDataUtil.addMemberMenu(EdocContant.edoc2_id, EdocContant.TEST_ACCOUNT_ID);
V3xOrgMember edoc2 = createSessionUser("edoc2");
long memberId = edoc2.getId();
boolean ret = edocApi.isEdocCreateRole(memberId, EdocContant.TEST_ACCOUNT_ID, EdocEnum.edocType.signReport.ordinal());
AssertUtils.assertFalse(ret);
EdocSummaryDataUtil.clearMemberMenu(memberId, edoc2.getOrgAccountId());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某人是否有某个单位的公文发起权,异常调用
* @Author : xuqw
* @Date : 2015年10月16日下午4:40:13
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testIsEdocCreateRole_6() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.isEdocCreateRole(null, null, EdocEnum.edocType.signReport.ordinal());
}
/**
* 测试 查找指定单位启用或者停用的公文元素,过滤了图片,附注等部分公文元素,因为只供文档中心调用, 查看启用数据
* @Author : xuqw
* @Date : 2015年10月17日上午12:39:40
* @throws BusinessException
*/
//@Test
public void testFindEdocElementsByStatus4Doc_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
List<EdocElementBO> eles = edocApi.findEdocElementsByStatus4Doc(edoc1.getOrgAccountId(), 1);
AssertUtils.assertCollectionNotEmpty(eles);
} catch (BusinessException e){
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 查找指定单位启用或者停用的公文元素,过滤了图片,附注等部分公文元素,因为只供文档中心调用, 查看停用数据
* @Author : xuqw
* @Date : 2015年10月17日上午12:39:40
* @throws BusinessException
*/
//@Test
public void testFindEdocElementsByStatus4Doc_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
List<EdocElementBO> eles = edocApi.findEdocElementsByStatus4Doc(edoc1.getOrgAccountId(), 0);
AssertUtils.assertCollectionNotEmpty(eles);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 查找指定单位启用或者停用的公文元素,过滤了图片,附注等部分公文元素,因为只供文档中心调用, 没有启用数据
* @Author : xuqw
* @Date : 2015年10月17日上午12:39:40
* @throws BusinessException
*/
//@Test
public void testFindEdocElementsByStatus4Doc_2() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
//单位ID随便写的
List<EdocElementBO> eles = edocApi.findEdocElementsByStatus4Doc(101L, 1);
AssertUtils.assertCollectionIsEmpty(eles);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 查找指定单位启用或者停用的公文元素,过滤了图片,附注等部分公文元素,因为只供文档中心调用, 没有停用数据
* @Author : xuqw
* @Date : 2015年10月17日上午12:39:40
* @throws BusinessException
*/
//@Test
public void testFindEdocElementsByStatus4Doc_3() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
// 单位ID随便写的
List<EdocElementBO> eles = edocApi.findEdocElementsByStatus4Doc(-22212101L, -2);
AssertUtils.assertCollectionIsEmpty(eles);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 查找指定单位启用或者停用的公文元素,过滤了图片,附注等部分公文元素,因为只供文档中心调用, 异常调用
* @Author : xuqw
* @Date : 2015年10月17日上午12:39:40
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testFindEdocElementsByStatus4Doc_4() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.findEdocElementsByStatus4Doc(null, 0);
}
/**
* 测试 判断是否是公文, 传入正确的appKey,返回true
* @Author : xuqw
* @Date : 2015年10月17日上午12:48:34
* @throws BusinessException
*/
//@Test
public void testIsEdoc_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.edoc.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.edocRec.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.edocRegister.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.edocSend.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.edocSign.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.exSend.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.exSign.getKey()));
AssertUtils.assertTrue(edocApi.isEdoc(ApplicationCategoryEnum.exchange.getKey()));
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断是否是公文, 传入错误的appKey,返回false
* @Author : xuqw
* @Date : 2015年10月17日上午12:48:34
* @throws BusinessException
*/
//@Test
public void testIsEdoc_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
AssertUtils.assertFalse("协同不是公文类型", edocApi.isEdoc(ApplicationCategoryEnum.collaboration.getKey()));
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 获取所有的公文的相关的枚举
* @Author : xuqw
* @Date : 2015年10月17日上午12:49:01
* @throws BusinessException
*/
//@Test
public void testFindEdocAllAppEnumKeys() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
List<Integer> keys = new ArrayList<Integer>();
keys.add(ApplicationCategoryEnum.edoc.key());
keys.add(ApplicationCategoryEnum.edocRec.key());
keys.add(ApplicationCategoryEnum.edocRegister.key());
keys.add(ApplicationCategoryEnum.edocSend.key());
keys.add(ApplicationCategoryEnum.edocSign.key());
keys.add(ApplicationCategoryEnum.exSend.key());
keys.add(ApplicationCategoryEnum.exSign.key());
keys.add(ApplicationCategoryEnum.exchange.key());
List<Integer> appKeys = edocApi.findEdocAllAppEnumKeys();
AssertUtils.assertCollectionNotEmpty(appKeys);
for(int i : appKeys){
AssertUtils.assertTrue(keys.contains(i));
}
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 根据枚举id 查询枚举值(文档中心使用),用于公文元素的显示
* @Author : xuqw
* @Date : 2015年10月17日上午12:51:25
* @throws BusinessException
*/
//@Test
public void testFindEdocElementEnumItems4Doc() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
EdocElementBO ele = edocApi.getEdocElementByFiledName("urgent_level");
List<CtpEnumItem> ret = edocApi.findEdocElementEnumItems4Doc(ele.getId());
AppContext.removeThreadContext(GlobalNames.SESSION_CONTEXT_USERINFO_KEY);
AssertUtils.assertCollectionNotEmpty(ret);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 根据公文元素代码找到公文元素
* @Author : xuqw
* @Date : 2015年10月17日上午12:51:53
* @throws BusinessException
*/
//@Test
public void testGetEdocElementByFiledName() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
EdocElementBO ret = edocApi.getEdocElementByFiledName("subject");
AppContext.removeThreadContext(GlobalNames.SESSION_CONTEXT_USERINFO_KEY);
AssertUtils.assertNotNull(ret);
AssertUtils.assertEquals("subject", ret.getFieldName());
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 根据summaryId找到这个公文的所有附件。
* @Author : xuqw
* @Date : 2015年10月17日上午12:52:36
* @throws BusinessException
*/
//@Test
public void testGetAttachmentsBySummaryId_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_附件_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummaryWithAttatchment(subject);
long summaryId = summary.getId();
List<AttachmentVO> atts = edocApi.getAttachmentsBySummaryId(summaryId, "");
AssertUtils.assertCollectionNotEmpty(atts);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 测试 根据summaryId找到这个公文的所有附件。
* @Author : xuqw
* @Date : 2015年10月17日上午12:52:36
* @throws BusinessException
*/
//@Test
public void testGetAttachmentsBySummaryId_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_附件_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummary(subject);
long summaryId = summary.getId();
List<AttachmentVO> atts = edocApi.getAttachmentsBySummaryId(summaryId, "");
AssertUtils.assertCollectionIsEmpty(atts);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 测试 根据summaryId找到这个公文的所有附件。
* @Author : xuqw
* @Date : 2015年10月17日上午12:52:36
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testGetAttachmentsBySummaryId_2() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.getAttachmentsBySummaryId(null, "");
}
/**
* 测试 判断某用户是否为收发员(包括部门收发员,单位收发员), 是单位收发员
* @Author : xuqw
* @Date : 2015年10月17日上午12:53:10
* @throws BusinessException
*/
//@Test
public void testIsExchangeRole_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
long memberId = edoc1.getId();
boolean ret = edocApi.isExchangeRole(memberId, EdocContant.TEST_ACCOUNT_ID);
AssertUtils.assertTrue(ret);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某用户是否为收发员(包括部门收发员,单位收发员), 是部门收发员
* @Author : xuqw
* @Date : 2015年10月17日上午12:53:10
* @throws BusinessException
*/
//@Test
public void testIsExchangeRole_1() throws BusinessException{
try {
V3xOrgMember edoc2 = createSessionUser("edoc2");
long memberId = edoc2.getId();
boolean ret = edocApi.isExchangeRole(memberId, EdocContant.TEST_ACCOUNT_ID);
AssertUtils.assertTrue(ret);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某用户是否为收发员(包括部门收发员,单位收发员), 不是收发员
* @Author : xuqw
* @Date : 2015年10月17日上午12:53:10
* @throws BusinessException
*/
//@Test
public void testIsExchangeRole_2() throws BusinessException{
try {
V3xOrgMember edoc3 = createSessionUser("edoc3");
long memberId = edoc3.getId();
boolean ret = edocApi.isExchangeRole(memberId, EdocContant.TEST_ACCOUNT_ID);
AssertUtils.assertFalse(ret);
} catch (BusinessException e) {
logger.error("单元测试报错", e);
AssertUtils.assertTrue(false);//单元测试失败
throw e;
}
}
/**
* 测试 判断某用户是否为收发员(包括部门收发员,单位收发员), 异常调用
* @Author : xuqw
* @Date : 2015年10月17日上午12:53:10
* @throws BusinessException
*/
//@Test(expected = BusinessException.class)
public void testIsExchangeRole_3() throws BusinessException{
V3xOrgMember edoc1 = createSessionUser("edoc1");
edocApi.isExchangeRole(null, EdocContant.TEST_ACCOUNT_ID);
}
//@Test
public void testReceiveEdoc() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
V3xOrgAccount account = orgManager.getAccountById(EdocContant.TEST_ACCOUNT_ID);
ReceiveEdocParam param = new ReceiveEdocParam();
param.setId(UUIDLong.longUUID());
//处理XML数据库的createUnitID是名称而不是ID
String createUnitId = account.getName();
param.setSendUnitName(createUnitId);
//将书生xml对象中的值放到默认收文单的SUMMARY对象
param.setOrgAccountId(account.getId());
param.setHasArchive(false);
param.setDeadline(0L);
param.setEdocType(0);
param.setCanTrack(0);
param.setIdentifier("00000000000000000000");
String subject = "公文单元测试_书生交换_" + UUIDLong.longUUID();
param.setSubject(subject);
param.setKeywords("");
param.setIssuer(edoc1.getName());
// 处理公文号
param.setDocMark("单元测试书生交换文号 " + UUIDLong.longUUID());
param.setCreatePerson(edoc1.getName());
//主送抄送单位
param.setSendTo("");
param.setCopyTo("");
Long now = System.currentTimeMillis();
param.setStartTime(new Timestamp(now));
param.setCreateTime(new Timestamp(now));
param.setState(3);
param.setDocType("1");
param.setSendType("1");
param.setKeepPeriod(1);
param.setSecretLevel("1");
param.setUrgentLevel("1");
param.setSendUserNames(edoc1.getName());
//正文
V3XFile bodyFile = new V3XFile();
bodyFile.setNewId();
bodyFile.setFilename(String.valueOf(UUIDLong.longUUID()));
bodyFile.setCreateDate(param.getCreateTime());
bodyFile.setCategory(1);
String mimeType = "application/msword";
bodyFile.setMimeType(mimeType);
bodyFile.setType(0);
bodyFile.setAccountId(Long.valueOf(param.getOrgAccountId()));
bodyFile.setUpdateDate(param.getCreateTime());
bodyFile.setSize(1024L);// 先设置大小
bodyFile.setFilename("书生交换测试正文" + bodyFile.getId());
//书生交换过来为GD格式,所以此处设置正文类型为GD加密格式,并且问小写
param.setBodyType("gd");
param.setBodyFile(bodyFile);
//附件
List<Attachment> attachments = new ArrayList<Attachment>();// 保存附件
V3XFile attachmentFile = new V3XFile();
attachmentFile.setNewId();
attachmentFile.setFilename(String.valueOf(UUIDLong.longUUID()));
attachmentFile.setCreateDate(param.getCreateTime());
attachmentFile.setCategory(1);
String mimeType1 = "application/msword";
attachmentFile.setMimeType(mimeType1);
attachmentFile.setType(0);
attachmentFile.setAccountId(Long.valueOf(param.getOrgAccountId()));
attachmentFile.setUpdateDate(param.getCreateTime());
attachmentFile.setSize(1024L);
Attachment attachment = new Attachment();
attachment.setNewId();
attachment.setSubReference(param.getId());
attachment.setReference(param.getId());
attachment.setFileUrl(attachmentFile.getId());
attachment.setCategory(4);
attachment.setCreatedate(attachmentFile.getCreateDate());
attachment.setFilename("书生交换测试附件" + attachmentFile.getId());
attachment.setMimeType(attachmentFile.getMimeType());
attachment.setSize(attachmentFile.getSize());
attachment.setSort(0);
attachmentFile.setFilename(attachment.getFilename());
attachment.setType(0);
attachments.add(attachment);
//设置附件
param.setAttachments(attachments);
fileManager.save(bodyFile);
fileManager.save(attachmentFile);
/** 数据取走后,更新中间表数据状态 */
edocApi.receiveEdoc(param);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
*
* 测试通过模板获取 EdocSummaryBO 对象, 传入正确的模板, 返回正确的公文数据
*
* @throws BusinessException
*
* @Author : xuqw
* @Date : 2016年5月30日上午9:45:33
*/
//@Test
public void testGetSummaryFromTemplate_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
//创建summary
String subject = "公文单元测试_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummary(subject);
//创建模板
CtpTemplate c = EdocSummaryDataUtil.createEdocTemplate(edoc1, summary);
EdocSummaryBO sBO = edocApi.getSummaryFromTemplate(c);
AssertUtils.assertNotNull(sBO);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
*
* 测试通过模板获取 EdocSummaryBO 对象, 传入空, 返回null
*
* @throws BusinessException
*
* @Author : xuqw
* @Date : 2016年5月30日上午9:45:33
*/
//@Test
public void testGetSummaryFromTemplate_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
EdocSummaryBO sBO = edocApi.getSummaryFromTemplate(null);
AssertUtils.assertNull(sBO);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 通过公文ID列表获取公文列表测试, 传入正确的ID列表,返回正确的公文列表
* @Author : xuqw
* @Date : 2016年5月27日下午4:49:09
* @throws BusinessException
*/
//@Test
public void testFindSimpleEdocSummarysByIds_0() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
String subject = "公文单元测试_ID列表查找_" + UUIDLong.longUUID();
EdocSummary summary = EdocSummaryDataUtil.createQuickEdocSummary(subject);
long summaryId = summary.getId();
List<Long> ids = new ArrayList<Long>();
ids.add(summaryId);
List<SimpleEdocSummary> summarys = edocApi.findSimpleEdocSummarysByIds(ids);
AssertUtils.assertCollectionNotEmpty(summarys);
AssertUtils.assertEquals(1, summarys.size());
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 通过公文ID列表获取公文列表测试, 传入null列表,返回空公文列表
* @Author : xuqw
* @Date : 2016年5月27日下午4:49:09
* @throws BusinessException
*/
//@Test
public void testFindSimpleEdocSummarysByIds_1() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
List<SimpleEdocSummary> summarys = edocApi.findSimpleEdocSummarysByIds(null);
AssertUtils.assertCollectionIsEmpty(summarys);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
/**
* 通过公文ID列表获取公文列表测试, 传入空列表,返回空公文列表
* @Author : xuqw
* @Date : 2016年5月27日下午4:49:09
* @throws BusinessException
*/
//@Test
public void testFindSimpleEdocSummarysByIds_2() throws BusinessException{
try {
V3xOrgMember edoc1 = createSessionUser("edoc1");
List<SimpleEdocSummary> summarys = edocApi.findSimpleEdocSummarysByIds(new ArrayList<Long>());
AssertUtils.assertCollectionIsEmpty(summarys);
} catch (Exception e) {
throw new BusinessException("单元测试报错", e);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment