BpmTestCaseController.java
6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.hotent.runtime.controller;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.controller.BaseController;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.util.StringUtil;
import com.hotent.base.util.UniqueIdUtil;
import com.hotent.runtime.manager.BpmTestCaseManager;
import com.hotent.runtime.model.BpmTestCase;
import com.hotent.runtime.params.TestCaseBaseInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
* 流程的测试用例设置 控制器类
*
* @company 广州宏天软件股份有限公司
* @author zhangxianwen
* @email zhangxw@jee-soft.cn
* @date 2018年6月28日
*/
@RestController
@RequestMapping("/runtime/bpmTestCase/v1/")
@Api(tags="流程测试用例设置")
@ApiGroup(group= {ApiGroupConsts.GROUP_BPM})
public class BpmTestCaseController extends BaseController<BpmTestCaseManager,BpmTestCase>{
@Resource
BpmTestCaseManager bpmTestCaseManager;
@RequestMapping(value="list", method=RequestMethod.POST, produces={"application/json; charset=utf-8" })
@ApiOperation(value = "获取测试用例设置列表(带分页信息)", httpMethod = "POST", notes = "获取测试用例设置列表")
public PageList<BpmTestCase> listJson(@ApiParam(name="queryFilter",value="通用查询对象")@RequestBody QueryFilter queryFilter) throws Exception {
return bpmTestCaseManager.query(queryFilter);
}
@RequestMapping(value="get",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取测试用例设置明细", httpMethod = "GET", notes = "获取测试用例设置明细")
public BpmTestCase get(@ApiParam(name="id",value="bo定义别名", required = true) @RequestParam String id) throws Exception{
return bpmTestCaseManager.get(id);
}
@RequestMapping(value="save",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "保存流程的测试用例设置信息", httpMethod = "POST", notes = "保存流程的测试用例设置信息")
public CommonResult<String> save(@ApiParam(name="bpmTestCase",value="流程的测试用例设置", required = true) @RequestBody BpmTestCase bpmTestCase) throws Exception{
String id=bpmTestCase.getId();
String resultMsg=null;
if(StringUtil.isEmpty(id)){
bpmTestCase.setId(UniqueIdUtil.getSuid());
bpmTestCaseManager.create(bpmTestCase);
resultMsg="添加流程的测试用例设置成功";
}else{
bpmTestCaseManager.update(bpmTestCase);
resultMsg="更新流程的测试用例设置成功";
}
return new CommonResult<String>(true,resultMsg,"");
}
@RequestMapping(value="remove",method=RequestMethod.DELETE, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "删除流程的测试用例设置", httpMethod = "DELETE", notes = "删除流程的测试用例设置")
public CommonResult<String> remove(@ApiParam(name="ids",value="流程的测试用例设置id,多个用“,”号分隔", required = true) @RequestParam String ids) throws Exception{
String message = "删除流程的测试用例设置成功";
boolean isTrue = true;
try {
String[] idArr = null;
if(!StringUtil.isEmpty(ids)){
idArr = ids.split(",");
}
bpmTestCaseManager.removeByIds(idArr);
} catch (Exception e) {
message= "删除流程的测试用例设置失败:"+e.getMessage();
isTrue = false;
}
return new CommonResult<String>(isTrue,message,"");
}
@RequestMapping(value="startTest",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "启动测试", httpMethod = "POST", notes = "启动测试")
public CommonResult<String> startTest(@ApiParam(name="ids",value="流程的测试用例设置id,多个用“,”号分隔", required = true) @RequestBody String ids) throws Exception{
bpmTestCaseManager.startTest(ids);
return new CommonResult<String>(true,"启动测试用例成功","");
}
@RequestMapping(value="doNext",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "继续启动测试用例试", httpMethod = "POST", notes = "继续启动测试用例")
public CommonResult<String> doNext(@ApiParam(name="id",value="流程实例id", required = true) @RequestParam String id) throws Exception{
if(StringUtil.isEmpty(id)){
return new CommonResult<String>(false, "没有传递流程实例id","");
}
bpmTestCaseManager.doNext(id);
return new CommonResult<String>(true, "测试用例重新启动成功","");
}
@RequestMapping(value="getBaseInfo",method=RequestMethod.GET, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取配置信息", httpMethod = "GET", notes = "获取配置信息")
public TestCaseBaseInfoVo getBaseInfo(@ApiParam(name="defKey",value="流程定义Key", required = true) @RequestParam String defKey) throws Exception{
return bpmTestCaseManager.getBaseInfo(defKey);
}
@RequestMapping(value="getReportData",method=RequestMethod.POST, produces = { "application/json; charset=utf-8" })
@ApiOperation(value = "获取测试用例图表信息", httpMethod = "POST", notes = "获取测试用例图表信息")
public CommonResult<ObjectNode> getReportData(@ApiParam(name="aryIds",value="流程的测试用例设置id,多个用“,”号分隔", required = true) @RequestBody String aryIds) throws Exception{
if(StringUtil.isEmpty(aryIds)){
return new CommonResult<ObjectNode>(false, "测试用例id不能为空", null);
}
ObjectNode jo = bpmTestCaseManager.getReportData(aryIds);
return new CommonResult<ObjectNode>(true, "获取测试用例图表信息成功", jo);
}
}