修复单元测试问题,删除starter
This commit is contained in:
@@ -38,9 +38,4 @@ cd hcframe-parent/hcframe-base/
|
||||
```
|
||||
6. 执行``mvn install``
|
||||
7. 刷新其他项目maven依赖
|
||||
8. 进入starter目录
|
||||
```bash
|
||||
cd ../hcframe-starter
|
||||
```
|
||||
9. 执行 ``mvn install``
|
||||
10. 刷新maven依赖
|
||||
8. 刷新maven依赖
|
||||
|
||||
@@ -17,9 +17,19 @@
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hcframe</groupId>
|
||||
<artifactId>hcframe-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hcframe</groupId>
|
||||
@@ -32,4 +42,12 @@
|
||||
<version>7.1.0.M1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.hcframe.activiti;
|
||||
|
||||
import com.hcframe.base.module.datasource.config.DataSourceConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.hcframe.activiti;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ActivitiApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.hcframe.activiti;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hcframe.activiti.activiti.ActivitiUtils;
|
||||
import com.hcframe.activiti.activiti.CommonTask;
|
||||
import com.hcframe.activiti.controller.TaskController;
|
||||
import com.hcframe.base.common.ResultPageInfo;
|
||||
import com.hcframe.base.common.WebPageInfo;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootTest
|
||||
@Component
|
||||
public class TaskControllerTest {
|
||||
|
||||
@Autowired
|
||||
TaskController taskController;
|
||||
|
||||
@Autowired
|
||||
ActivitiUtils activitiUtils;
|
||||
|
||||
@Test
|
||||
public void startTask() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("tableName", "user");
|
||||
map.put("tableId", 10);
|
||||
map.put("approvalPerson", "lhc");
|
||||
// taskController.startTaskByKey("test", map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTaskList(){
|
||||
CommonTask commonTask = new CommonTask();
|
||||
commonTask.setName("test");
|
||||
commonTask.setAssignee("lhc");
|
||||
ResultPageInfo<CommonTask> list =activitiUtils.getTaskList(commonTask, WebPageInfo.builder().pageNum(1).pageSize(10).build(), Collections.emptyMap());
|
||||
List<CommonTask> commonTaskList=list.getList();
|
||||
for (CommonTask commonTask1 : commonTaskList) {
|
||||
System.out.println(commonTask1.getId());
|
||||
System.out.println(commonTask1.getTaskDefinitionKey());
|
||||
System.out.println(commonTask1.getName());
|
||||
System.out.println(commonTask1.getAssignee());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeTask(){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("day", 3);
|
||||
String data = JSONObject.toJSONString(map);
|
||||
taskController.commitTask("6e49a42d-ee6c-11ea-846d-f20e832dd5e1", data,false,null);
|
||||
}
|
||||
@Test
|
||||
public void complete2Task(){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("status", 0);
|
||||
String data = JSONObject.toJSONString(map);
|
||||
taskController.commitTask("c3c3f756-ee6c-11ea-b7c9-f20e832dd5e1", data,false,null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void complete3Task(){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("status", 1);
|
||||
String data = JSONObject.toJSONString(map);
|
||||
taskController.commitTask("c3cc82e0-ee6c-11ea-b7c9-f20e832dd5e1", data,false,null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void deleteTask(){
|
||||
taskController.deleteTaskInstans("2d45a8a8-ee47-11ea-8baf-f20e832dd5e1","",true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.hcframe.activiti;
|
||||
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.impl.ProcessInstanceQueryProperty;
|
||||
import org.activiti.engine.repository.Deployment;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootTest
|
||||
public class TestClass {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(TestClass.class);
|
||||
|
||||
@Resource
|
||||
RuntimeService runtimeService;
|
||||
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Resource
|
||||
private TaskService taskService;
|
||||
|
||||
@Resource
|
||||
private HistoryService historyService;
|
||||
|
||||
/**
|
||||
* 部署一个流程
|
||||
*/
|
||||
@Test
|
||||
public void deployement(){
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = new FileInputStream( "/Users/mac/Documents/common-frame/gitea/common-activiti/src/main/resources/bpmn/数据采集(数据应用室发起).bpmn");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Deployment deployment = repositoryService.createDeployment()
|
||||
.addInputStream("start_123",is)
|
||||
.name("数据采集")
|
||||
.deploy();
|
||||
logger.info("流程名称:"+deployment.getName());
|
||||
logger.info("流程ID:"+deployment.getId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getModel(){
|
||||
ProcessInstanceQueryProperty queryProperty = new ProcessInstanceQueryProperty("processQuery");
|
||||
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().orderBy(queryProperty).asc().list();
|
||||
for (ProcessDefinition processDefinition : list) {
|
||||
System.out.println("流程定义ID:"+processDefinition.getId());//流程定义的key+版本+随机生成数
|
||||
System.out.println("流程定义名称:"+processDefinition.getName());//对应HelloWorld.bpmn文件中的name属性值
|
||||
System.out.println("流程定义的key:"+processDefinition.getKey());//对应HelloWorld.bpmn文件中的id属性值
|
||||
System.out.println("流程定义的版本:"+processDefinition.getVersion());//当流程定义的key值相同的情况下,版本升级,默认从1开始
|
||||
System.out.println("资源名称bpmn文件:"+processDefinition.getResourceName());
|
||||
System.out.println("资源名称png文件:"+processDefinition.getDiagramResourceName());
|
||||
System.out.println("部署对象ID:"+processDefinition.getDeploymentId());
|
||||
System.out.println("################################");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始一个流程实例
|
||||
*/
|
||||
@Test
|
||||
public void startProcessInstance(){
|
||||
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceByKey("");
|
||||
System.out.println("流程实例ID:"+instance.getId());
|
||||
System.out.println("流程定义ID:"+instance.getProcessDefinitionId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程任务
|
||||
*/
|
||||
@Test
|
||||
public void taskQuery(){
|
||||
List<Task> list = taskService.createTaskQuery()
|
||||
.processDefinitionKey("task__111")
|
||||
.taskAssignee("tom").listPage(0,10);
|
||||
|
||||
if(list!=null && list.size()>0){
|
||||
for(Task task:list){
|
||||
System.out.println("任务ID:"+task.getId());
|
||||
System.out.println("任务名称:"+task.getName());
|
||||
System.out.println("任务的创建时间:"+task.getCreateTime());
|
||||
System.out.println("任务的办理人:"+task.getAssignee());
|
||||
System.out.println("流程实例ID:"+task.getProcessInstanceId());
|
||||
System.out.println("执行对象ID:"+task.getExecutionId());
|
||||
System.out.println("流程定义ID:"+task.getProcessDefinitionId());
|
||||
System.out.println("getOwner:"+task.getOwner());
|
||||
System.out.println("getCategory:"+task.getCategory());
|
||||
System.out.println("getDescription:"+task.getDescription());
|
||||
System.out.println("getFormKey:"+task.getFormKey());
|
||||
Map<String, Object> map = task.getProcessVariables();
|
||||
for (Map.Entry<String, Object> m : map.entrySet()) {
|
||||
System.out.println("key:" + m.getKey() + " value:" + m.getValue());
|
||||
}
|
||||
for (Map.Entry<String, Object> m : task.getTaskLocalVariables().entrySet()) {
|
||||
System.out.println("key:" + m.getKey() + " value:" + m.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*/
|
||||
@Test
|
||||
public void completeTask(){
|
||||
//任务ID
|
||||
String taskId = "64610e0c-bf5c-11ea-b195-be54a4f8513e";
|
||||
taskService.complete(taskId);
|
||||
System.out.println("完成任务:任务ID:"+taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史活动实例查询
|
||||
*/
|
||||
@Test
|
||||
public void queryHistoryTask() {
|
||||
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery() // 创建历史活动实例查询
|
||||
.processInstanceId("645e9d08-bf5c-11ea-b195-be54a4f8513e") // 执行流程实例id
|
||||
.orderByTaskCreateTime()
|
||||
.asc()
|
||||
.list();
|
||||
for (HistoricTaskInstance hai : list) {
|
||||
System.out.println("活动ID:" + hai.getId());
|
||||
System.out.println("流程实例ID:" + hai.getProcessInstanceId());
|
||||
System.out.println("活动名称:" + hai.getName());
|
||||
System.out.println("办理人:" + hai.getAssignee());
|
||||
System.out.println("开始时间:" + hai.getStartTime());
|
||||
System.out.println("结束时间:" + hai.getEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteFlow() {
|
||||
repositoryService.deleteDeployment("f71e44b2-bf56-11ea-85b5-be54a4f8513e",true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,12 +22,21 @@
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hcframe</groupId>
|
||||
<artifactId>hcframe-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.hcframe</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>hcframe-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -22,9 +22,19 @@
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hcframe</groupId>
|
||||
<artifactId>hcframe-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
Reference in New Issue
Block a user