提交 555b6ecc authored 作者: ww1xhqc's avatar ww1xhqc

[数据模型] 修改一个更新的bug,提交工作流测试

上级 bd6db46d
...@@ -239,6 +239,8 @@ public class ModelImpl implements ModelService { ...@@ -239,6 +239,8 @@ public class ModelImpl implements ModelService {
} }
} }
newSession.save(tableName,map); newSession.save(tableName,map);
newSession.getTransaction().begin();
newSession.getTransaction().commit();
newSession.close(); newSession.close();
} }
......
...@@ -44,7 +44,7 @@ public class WorkFlowController { ...@@ -44,7 +44,7 @@ public class WorkFlowController {
return workFlowService.findTaskByUserId(nextTaskVo); return workFlowService.findTaskByUserId(nextTaskVo);
} }
@PostMapping("/findTaskDetail") @GetMapping("/findTaskDetail")
@ApiOperation("任务个人待办任务详情") @ApiOperation("任务个人待办任务详情")
public Map<String, Object> findTaskDetail(String taskId){ public Map<String, Object> findTaskDetail(String taskId){
return workFlowService.findTaskDetail(taskId); return workFlowService.findTaskDetail(taskId);
......
...@@ -225,7 +225,8 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -225,7 +225,8 @@ public class WorkFlowServiceImpl implements WorkFlowService {
if (nextTaskVo.getRoleId() != null || nextTaskVo.getUserId() != null) { if (nextTaskVo.getRoleId() != null || nextTaskVo.getUserId() != null) {
taskQuery.or(); taskQuery.or();
if (nextTaskVo.getUserId() != null) { if (nextTaskVo.getUserId() != null) {
taskQuery.taskCandidateUser(nextTaskVo.getUserId()).orderByTaskCreateTime().desc(); // taskQuery.taskCandidateUser(nextTaskVo.getUserId()).orderByTaskCreateTime().desc();
taskQuery.taskAssignee(nextTaskVo.getUserId()).orderByTaskCreateTime().desc();
} }
if (nextTaskVo.getRoleId() != null && nextTaskVo.getRoleId().size() > 0) { if (nextTaskVo.getRoleId() != null && nextTaskVo.getRoleId().size() > 0) {
taskQuery.taskCandidateGroupIn(nextTaskVo.getRoleId()).orderByTaskCreateTime().desc(); taskQuery.taskCandidateGroupIn(nextTaskVo.getRoleId()).orderByTaskCreateTime().desc();
......
package com.tykj.workflowcore;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.workflow_editer.controller.FlowsInfoController;
import com.tykj.workflowcore.workflow_editer.controller.WorkFlowController;
import org.aspectj.lang.annotation.Before;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import springfox.documentation.spring.web.json.Json;
import static org.hamcrest.Matchers.equalToObject;
import static org.hamcrest.Matchers.not;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
class WorkflowCoreApplicationTests_workflow {
@Autowired
private FlowsInfoController flowsInfoController;
@Autowired
private WorkFlowController workFlowController;
@Autowired
MockMvc mockMvc;
RequestBuilder request;
@Before("")
public void setUp() {
mockMvc = MockMvcBuilders.standaloneSetup(flowsInfoController).build();
mockMvc = MockMvcBuilders.standaloneSetup(workFlowController).build();
}
@Test
//部署流程
void deployFlow() throws Exception {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<bpmn2:definitions xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:bpmn2=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\" xmlns:flowable=\"http://flowable.org/bpmn\" targetNamespace=\"http://bpmn.io/schema/bpmn\">\n" +
" <bpmn2:process id=\"processId_26246e2b-2f1a-46a5-b2f1-f3df8109d06b\" name=\"测试流程1\" isExecutable=\"true\">\n" +
" <bpmn2:documentation>这是一个测试流程1</bpmn2:documentation>\n" +
" <bpmn2:startEvent id=\"StartEvent_38617d3f-09e7-4342-aa7a-49e89189d4d2\">\n" +
" <bpmn2:outgoing>Flow_1jxsm3b</bpmn2:outgoing>\n" +
" </bpmn2:startEvent>\n" +
" <bpmn2:sequenceFlow id=\"Flow_1jxsm3b\" sourceRef=\"StartEvent_38617d3f-09e7-4342-aa7a-49e89189d4d2\" targetRef=\"Activity_b4c5faae-2078-4c24-8e8c-d8fae56c2136\" />\n" +
" <bpmn2:sequenceFlow id=\"Flow_1xfelj7\" sourceRef=\"Activity_b4c5faae-2078-4c24-8e8c-d8fae56c2136\" targetRef=\"Activity_32aa4df7-1f13-439d-a3f9-58c3d01ef9f9\" />\n" +
" <bpmn2:userTask id=\"Activity_b4c5faae-2078-4c24-8e8c-d8fae56c2136\" name=\"人工节点1\" flowable:assignee=\"zhangsan\">\n" +
" <bpmn2:incoming>Flow_1jxsm3b</bpmn2:incoming>\n" +
" <bpmn2:outgoing>Flow_1xfelj7</bpmn2:outgoing>\n" +
" </bpmn2:userTask>\n" +
" <bpmn2:userTask id=\"Activity_32aa4df7-1f13-439d-a3f9-58c3d01ef9f9\" name=\"人工节点2\" flowable:assignee=\"lisi\">\n" +
" <bpmn2:incoming>Flow_1xfelj7</bpmn2:incoming>\n" +
" <bpmn2:outgoing>Flow_0n5k9bw</bpmn2:outgoing>\n" +
" </bpmn2:userTask>\n" +
" <bpmn2:endEvent id=\"Event_5835a2ee-d2ae-43c5-9d4a-7d8c9dff0dea\">\n" +
" <bpmn2:incoming>Flow_0n5k9bw</bpmn2:incoming>\n" +
" </bpmn2:endEvent>\n" +
" <bpmn2:sequenceFlow id=\"Flow_0n5k9bw\" sourceRef=\"Activity_32aa4df7-1f13-439d-a3f9-58c3d01ef9f9\" targetRef=\"Event_5835a2ee-d2ae-43c5-9d4a-7d8c9dff0dea\" />\n" +
" </bpmn2:process>\n" +
" <bpmndi:BPMNDiagram id=\"BPMNDiagram_1\">\n" +
" <bpmndi:BPMNPlane id=\"BPMNPlane_1\" bpmnElement=\"processId_26246e2b-2f1a-46a5-b2f1-f3df8109d06b\">\n" +
" <bpmndi:BPMNEdge id=\"Flow_1jxsm3b_di\" bpmnElement=\"Flow_1jxsm3b\">\n" +
" <di:waypoint x=\"196\" y=\"178\" />\n" +
" <di:waypoint x=\"250\" y=\"178\" />\n" +
" </bpmndi:BPMNEdge>\n" +
" <bpmndi:BPMNEdge id=\"Flow_1xfelj7_di\" bpmnElement=\"Flow_1xfelj7\">\n" +
" <di:waypoint x=\"350\" y=\"178\" />\n" +
" <di:waypoint x=\"410\" y=\"178\" />\n" +
" </bpmndi:BPMNEdge>\n" +
" <bpmndi:BPMNEdge id=\"Flow_0n5k9bw_di\" bpmnElement=\"Flow_0n5k9bw\">\n" +
" <di:waypoint x=\"510\" y=\"178\" />\n" +
" <di:waypoint x=\"572\" y=\"178\" />\n" +
" </bpmndi:BPMNEdge>\n" +
" <bpmndi:BPMNShape id=\"_BPMNShape_StartEvent_2\" bpmnElement=\"StartEvent_38617d3f-09e7-4342-aa7a-49e89189d4d2\">\n" +
" <dc:Bounds x=\"160\" y=\"160\" width=\"36\" height=\"36\" />\n" +
" </bpmndi:BPMNShape>\n" +
" <bpmndi:BPMNShape id=\"Activity_051mk34_di\" bpmnElement=\"Activity_b4c5faae-2078-4c24-8e8c-d8fae56c2136\">\n" +
" <dc:Bounds x=\"250\" y=\"138\" width=\"100\" height=\"80\" />\n" +
" </bpmndi:BPMNShape>\n" +
" <bpmndi:BPMNShape id=\"Activity_0audtcs_di\" bpmnElement=\"Activity_32aa4df7-1f13-439d-a3f9-58c3d01ef9f9\">\n" +
" <dc:Bounds x=\"410\" y=\"138\" width=\"100\" height=\"80\" />\n" +
" </bpmndi:BPMNShape>\n" +
" <bpmndi:BPMNShape id=\"Event_181nibi_di\" bpmnElement=\"Event_5835a2ee-d2ae-43c5-9d4a-7d8c9dff0dea\">\n" +
" <dc:Bounds x=\"572\" y=\"160\" width=\"36\" height=\"36\" />\n" +
" </bpmndi:BPMNShape>\n" +
" </bpmndi:BPMNPlane>\n" +
" </bpmndi:BPMNDiagram>\n" +
"</bpmn2:definitions>\n";
JSONObject jsonObject = new JSONObject();
jsonObject.put("fileXml",xml);
jsonObject.put("flowKey","processId_26246e2b-2f1a-46a5-b2f1-f3df8109d06b");
jsonObject.put("flowName","测试流程1");
request = post("/flowsInfo/saveXml/")
.contentType(MediaType.APPLICATION_JSON)
.content(jsonObject.toJSONString())
// .param("fileXml",xml)//参数
// .param("flowKey","processId_df8ce31c-c23c-4e5d-8401-e4e99286dba8")//参数
// .param("flowName","processName_2")
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE);
mockMvc.perform(request).andExpect(status().isOk())
.andExpect(content().string(not(""))) //条件
.andExpect(content().string(not("[]")))
.andDo(print());//打印输出结果
}
@Test
//开启流程
void startFlow() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("flowKey","processId_26246e2b-2f1a-46a5-b2f1-f3df8109d06b");
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("handlingOpinion","0");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("id","5");
jsonObject2.put("userName","张三");
jsonObject1.put("workFlowUser",jsonObject2);
jsonObject.put("map",jsonObject1);
request = post("/workFlow/startFlow/")
.contentType(MediaType.APPLICATION_JSON)
.content(jsonObject.toJSONString())
// .param("fileXml",xml)//参数
// .param("flowKey","processId_df8ce31c-c23c-4e5d-8401-e4e99286dba8")//参数
// .param("flowName","processName_2")
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE);
mockMvc.perform(request).andExpect(status().isOk())
// .andExpect(content().string(not(""))) //条件
.andExpect(content().string(not("[]")))
.andDo(print());//打印输出结果
}
@Test
//查询代办
void findUserTask() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId","zhangsan");
request = post("/workFlow/findUserTask/")
.contentType(MediaType.APPLICATION_JSON)
.content(jsonObject.toJSONString())
// .param("userId","zhangsan")//参数
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE);
mockMvc.perform(request).andExpect(status().isOk())
.andExpect(content().string(not(""))) //条件
// .andExpect(content().string(not("[]")))
.andDo(print());//打印输出结果
}
@Test
//查询代办
void findUserTaskDetail() throws Exception {
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("taskId","2563cd2d-8c72-11eb-9463-005056c00001");
request = get("/workFlow/findTaskDetail/")
.contentType(MediaType.APPLICATION_JSON)
.param("taskId","2563cd2d-8c72-11eb-9463-005056c00001")//参数
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE);
mockMvc.perform(request).andExpect(status().isOk())
.andExpect(content().string(not(""))) //条件
// .andExpect(content().string(not("[]")))
.andDo(print());//打印输出结果
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论