mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 04:08:31 +08:00
add ut for dao ... (#923)
* update english documents * refactor zk client * update documents * update zkclient * update zkclient * update documents * add architecture-design * change i18n * update i18n * update english documents * add architecture-design * update english documents * update en-US documents * add architecture-design * update demo site * add mybatis plus model * modify mybatisplus * modify mybatisplus * change interface by mybatisplus * add unit test * refactor dao interface. * add unit test for dao... * add unit test for dao...
This commit is contained in:
parent
bf39b31855
commit
e84c6adcac
@ -158,9 +158,19 @@ public class DataAnalysisService {
|
||||
putErrorRequestParamsMsg(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Integer> projectIds = new ArrayList<>();
|
||||
if(projectId !=0){
|
||||
projectIds.add(projectId);
|
||||
}else if(loginUser.getUserType() == UserType.GENERAL_USER){
|
||||
projectIds = processDao.getProjectIdListHavePerm(loginUser.getId());
|
||||
|
||||
}
|
||||
Integer[] projectIdArray = projectIds.toArray(new Integer[projectIds.size()]);
|
||||
|
||||
List<ExecuteStatusCount> processInstanceStateCounts =
|
||||
processInstanceMapper.countInstanceStateByUser(loginUser.getId(),
|
||||
loginUser.getUserType(), start, end, String.valueOf(projectId));
|
||||
processInstanceMapper.countInstanceStateByUser(start, end,
|
||||
projectIdArray);
|
||||
|
||||
TaskCountDto taskCountResult = new TaskCountDto(processInstanceStateCounts);
|
||||
if (processInstanceStateCounts != null) {
|
||||
@ -259,12 +269,9 @@ public class DataAnalysisService {
|
||||
if(projectId !=0){
|
||||
projectIds.add(projectId);
|
||||
}else if(loginUser.getUserType() == UserType.GENERAL_USER){
|
||||
List<Project> projects = processDao.getProjectListHavePerm(loginUser.getId());
|
||||
for(Project project : projects){
|
||||
projectIds.add(project.getId());
|
||||
}
|
||||
}
|
||||
projectIds = processDao.getProjectIdListHavePerm(loginUser.getId());
|
||||
|
||||
}
|
||||
Integer[] projectIdArray = projectIds.toArray(new Integer[projectIds.size()]);
|
||||
// count command state
|
||||
List<CommandCount> commandStateCounts =
|
||||
|
@ -502,7 +502,9 @@ public class ProcessDefinitionService extends BaseDAGService {
|
||||
case OFFLINE: {
|
||||
processDefinition.setReleaseState(state);
|
||||
processDefineMapper.updateById(processDefinition);
|
||||
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray(String.valueOf(id));
|
||||
List<Schedule> scheduleList = scheduleMapper.selectAllByProcessDefineArray(
|
||||
new int[]{processDefinition.getId()}
|
||||
);
|
||||
|
||||
for(Schedule schedule:scheduleList){
|
||||
logger.info("set schedule offline, schedule id: {}, process definition id: {}", project.getId(), schedule.getId(), id);
|
||||
|
@ -191,7 +191,7 @@ public class ProcessInstanceService extends BaseDAGService {
|
||||
|
||||
IPage<ProcessInstance> processInstanceList =
|
||||
processInstanceMapper.queryProcessInstanceListPaging(page,
|
||||
project.getId(), processDefineId, searchVal, statesStr, host, start, end);
|
||||
project.getId(), processDefineId, searchVal, statusArray, host, start, end);
|
||||
|
||||
Set<String> exclusionSet = new HashSet<String>(){{
|
||||
add(Constants.CLASS);
|
||||
|
@ -243,7 +243,7 @@ public class QueueService extends BaseService {
|
||||
* @return
|
||||
*/
|
||||
private boolean checkQueueExist(String queue) {
|
||||
return queueMapper.queryByQueue(queue) == null ? false : true;
|
||||
return queueMapper.queryAllQueueList(queue, null).size()>0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,7 +253,7 @@ public class QueueService extends BaseService {
|
||||
* @return
|
||||
*/
|
||||
private boolean checkQueueNameExist(String queueName) {
|
||||
return queueMapper.queryByQueueName(queueName) == null ? false : true;
|
||||
return queueMapper.queryAllQueueList(null ,queueName).size()>0 ? false : true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -168,8 +168,7 @@ public class TenantService extends BaseService{
|
||||
* if the tenant code is modified, the original resource needs to be copied to the new tenant.
|
||||
*/
|
||||
if (!tenant.getTenantCode().equals(tenantCode)){
|
||||
Tenant newTenant = tenantMapper.queryByTenantCode(tenantCode);
|
||||
if (newTenant == null){
|
||||
if (checkTenant(tenantCode)){
|
||||
// if hdfs startup
|
||||
if (PropertyUtils.getResUploadStartupState()){
|
||||
String resourcePath = HadoopUtils.getHdfsDataBasePath() + "/" + tenantCode + "/resources";
|
||||
@ -279,8 +278,7 @@ public class TenantService extends BaseService{
|
||||
*/
|
||||
public Result verifyTenantCode(String tenantCode) {
|
||||
Result result=new Result();
|
||||
Tenant tenant= tenantMapper.queryByTenantCode(tenantCode);
|
||||
if (tenant != null) {
|
||||
if (checkTenant(tenantCode)) {
|
||||
logger.error("tenant {} has exist, can't create again.", tenantCode);
|
||||
putMsg(result, Status.TENANT_NAME_EXIST);
|
||||
}else{
|
||||
|
@ -396,6 +396,11 @@ public class UsersService extends BaseService {
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM, Constants.STATUS)) {
|
||||
return result;
|
||||
}
|
||||
User user = userMapper.selectById(userId);
|
||||
if(user == null){
|
||||
putMsg(result, Status.USER_NOT_EXIST, userId);
|
||||
return result;
|
||||
}
|
||||
|
||||
resourcesUserMapper.deleteResourceUser(userId, 0);
|
||||
|
||||
|
@ -278,18 +278,6 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
return processInstanceMapper.selectById(processId);
|
||||
}
|
||||
|
||||
/**
|
||||
* find process instance by scheduler time.
|
||||
* @param defineId
|
||||
* @param scheduleTime
|
||||
* @return
|
||||
*/
|
||||
public ProcessInstance findProcessInstanceByScheduleTime(int defineId, Date scheduleTime){
|
||||
|
||||
return processInstanceMapper.queryByScheduleTime(defineId,
|
||||
DateUtils.dateToString(scheduleTime), 0, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* find process define by id.
|
||||
* @param processDefinitionId
|
||||
@ -315,7 +303,7 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
*/
|
||||
public int deleteAllSubWorkProcessByParentId(int processInstanceId){
|
||||
|
||||
List<Integer> subProcessIdList = processInstanceMapper.querySubIdListByParentId(processInstanceId);
|
||||
List<Integer> subProcessIdList = processInstanceMapMapper.querySubIdListByParentId(processInstanceId);
|
||||
|
||||
for(Integer subId : subProcessIdList ){
|
||||
deleteAllSubWorkProcessByParentId(subId);
|
||||
@ -1465,8 +1453,7 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
|
||||
public List<ProcessInstance> queryNeedFailoverProcessInstances(String host){
|
||||
|
||||
String states = StringUtils.join(stateArray, ",");
|
||||
return processInstanceMapper.queryByHostAndStatus(host, states);
|
||||
return processInstanceMapper.queryByHostAndStatus(host, stateArray);
|
||||
}
|
||||
|
||||
|
||||
@ -1533,7 +1520,11 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
* @return
|
||||
*/
|
||||
public ProcessInstance findProcessInstanceByTaskId(int taskId){
|
||||
return processInstanceMapper.queryByTaskId(taskId);
|
||||
TaskInstance taskInstance = taskInstanceMapper.selectById(taskId);
|
||||
if(taskInstance!= null){
|
||||
return processInstanceMapper.selectById(taskInstance.getProcessInstanceId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1562,7 +1553,7 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
*/
|
||||
public List<Schedule> selectAllByProcessDefineId(int[] ids){
|
||||
return scheduleMapper.selectAllByProcessDefineArray(
|
||||
StringUtils.join(ids, ","));
|
||||
ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1653,40 +1644,6 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
return cycleDependencyList;
|
||||
}
|
||||
|
||||
/**
|
||||
* find process instance by time interval
|
||||
* @param defineId
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
public ProcessInstance findProcessInstanceByTimeInterval(int defineId, Date startTime, Date endTime, int excludeId) {
|
||||
|
||||
return processInstanceMapper.queryByScheduleTime(defineId, null, excludeId,
|
||||
DateUtils.dateToString(startTime), DateUtils.dateToString(endTime));
|
||||
}
|
||||
|
||||
@Transactional(value = "TransactionManager",rollbackFor = Exception.class)
|
||||
public void selfFaultTolerant(ProcessInstance processInstance){
|
||||
|
||||
processInstance.setState(ExecutionStatus.FAILURE);
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
// insert to command
|
||||
|
||||
Command command = new Command();
|
||||
command.setCommandType(CommandType.START_FAILURE_TASK_PROCESS);
|
||||
command.setProcessDefinitionId(processInstance.getProcessDefinitionId());
|
||||
command.setCommandParam(String.format("{\"%s\":%d}",
|
||||
CMDPARAM_RECOVER_PROCESS_ID_STRING, processInstance.getId()));
|
||||
|
||||
|
||||
command.setExecutorId(processInstance.getExecutorId());
|
||||
command.setProcessInstancePriority(processInstance.getProcessInstancePriority());
|
||||
|
||||
createCommand(command);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* find last scheduler process instance in the date interval
|
||||
* @param definitionId
|
||||
@ -1701,8 +1658,8 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
|
||||
public ProcessInstance findLastManualProcessInterval(int definitionId, DateInterval dateInterval) {
|
||||
return processInstanceMapper.queryLastManualProcess(definitionId,
|
||||
DateUtils.dateToString(dateInterval.getStartTime()),
|
||||
DateUtils.dateToString(dateInterval.getEndTime()));
|
||||
dateInterval.getStartTime(),
|
||||
dateInterval.getEndTime());
|
||||
}
|
||||
|
||||
public ProcessInstance findLastRunningProcess(int definitionId, DateInterval dateInterval) {
|
||||
@ -1767,9 +1724,23 @@ public class ProcessDao extends AbstractBaseDao {
|
||||
List<Project> createProjects = projectMapper.queryProjectCreatedByUser(userId);
|
||||
List<Project> authedProjects = projectMapper.queryAuthedProjectListByUserId(userId);
|
||||
|
||||
createProjects.addAll(authedProjects);
|
||||
return createProjects;
|
||||
if(createProjects == null){
|
||||
createProjects = new ArrayList<>();
|
||||
}
|
||||
|
||||
if(authedProjects != null){
|
||||
createProjects.addAll(authedProjects);
|
||||
}
|
||||
return createProjects;
|
||||
}
|
||||
|
||||
public List<Integer> getProjectIdListHavePerm(int userId){
|
||||
|
||||
List<Integer> projectIdList = new ArrayList<>();
|
||||
for(Project project : getProjectListHavePerm(userId)){
|
||||
projectIdList.add(project.getId());
|
||||
}
|
||||
return projectIdList;
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ package cn.escheduler.dao.entity;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
@ -77,6 +78,7 @@ public class ProcessInstance {
|
||||
/**
|
||||
* process definition structure
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private ProcessDefinition processDefinition;
|
||||
/**
|
||||
* process command type
|
||||
@ -141,11 +143,13 @@ public class ProcessInstance {
|
||||
/**
|
||||
* tenant code
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String tenantCode;
|
||||
|
||||
/**
|
||||
* queue
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String queue;
|
||||
|
||||
/**
|
||||
@ -177,6 +181,7 @@ public class ProcessInstance {
|
||||
* process duration
|
||||
* @return
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
@ -202,16 +207,19 @@ public class ProcessInstance {
|
||||
/**
|
||||
* worker group name. for api.
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String workerGroupName;
|
||||
|
||||
/**
|
||||
* receivers for api
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String receivers;
|
||||
|
||||
/**
|
||||
* receivers cc for api
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String receiversCc;
|
||||
|
||||
public ProcessInstance(){
|
||||
|
@ -18,6 +18,7 @@ package cn.escheduler.dao.entity;
|
||||
|
||||
import cn.escheduler.common.enums.*;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@ -42,17 +43,20 @@ public class Schedule {
|
||||
/**
|
||||
* process definition name
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String processDefinitionName;
|
||||
|
||||
/**
|
||||
* project name
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String projectName;
|
||||
|
||||
/**
|
||||
* schedule description
|
||||
*/
|
||||
private String desc;
|
||||
@TableField(exist = false)
|
||||
private String definitionDescription;
|
||||
|
||||
/**
|
||||
* schedule start time
|
||||
@ -97,6 +101,7 @@ public class Schedule {
|
||||
/**
|
||||
* created user name
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
@ -201,13 +206,7 @@ public class Schedule {
|
||||
this.releaseState = releaseState;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getProcessDefinitionId() {
|
||||
return processDefinitionId;
|
||||
@ -281,7 +280,7 @@ public class Schedule {
|
||||
", processDefinitionId=" + processDefinitionId +
|
||||
", processDefinitionName='" + processDefinitionName + '\'' +
|
||||
", projectName='" + projectName + '\'' +
|
||||
", desc='" + desc + '\'' +
|
||||
", description='" + definitionDescription + '\'' +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", crontab='" + crontab + '\'' +
|
||||
@ -298,4 +297,11 @@ public class Schedule {
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getDefinitionDescription() {
|
||||
return definitionDescription;
|
||||
}
|
||||
|
||||
public void setDefinitionDescription(String definitionDescription) {
|
||||
this.definitionDescription = definitionDescription;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import cn.escheduler.dao.entity.ProcessInstanceMap;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcessInstanceMapMapper extends BaseMapper<ProcessInstanceMap> {
|
||||
|
||||
|
||||
@ -31,4 +33,6 @@ public interface ProcessInstanceMapMapper extends BaseMapper<ProcessInstanceMap>
|
||||
|
||||
int deleteByParentProcessId(@Param("parentProcessId") int parentProcessId);
|
||||
|
||||
List<Integer> querySubIdListByParentId(@Param("parentInstanceId") int parentInstanceId);
|
||||
|
||||
}
|
||||
|
@ -31,47 +31,33 @@ public interface ProcessInstanceMapper extends BaseMapper<ProcessInstance> {
|
||||
|
||||
ProcessInstance queryDetailById(@Param("processId") int processId);
|
||||
|
||||
List<ProcessInstance> queryByHostAndStatus(@Param("host") String host, @Param("states") String stateArray);
|
||||
List<ProcessInstance> queryByHostAndStatus(@Param("host") String host,
|
||||
@Param("states") int[] stateArray);
|
||||
|
||||
IPage<ProcessInstance> queryProcessInstanceListPaging(Page<ProcessInstance> page,
|
||||
@Param("projectId") int projectId,
|
||||
@Param("processDefinitionId") Integer processDefinitionId,
|
||||
@Param("searchVal") String searchVal,
|
||||
@Param("states") String statusArray,
|
||||
@Param("states") int[] statusArray,
|
||||
@Param("host") String host,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime
|
||||
);
|
||||
|
||||
int setFailoverByHostAndStateArray(@Param("host") String host,
|
||||
@Param("states") String stateArray);
|
||||
@Param("states") int[] stateArray);
|
||||
|
||||
int updateProcessInstanceByState(@Param("originState") ExecutionStatus originState,
|
||||
@Param("destState") ExecutionStatus destState);
|
||||
|
||||
|
||||
ProcessInstance queryByTaskId(@Param("taskId") int taskId);
|
||||
|
||||
|
||||
List<ExecuteStatusCount> countInstanceStateByUser(
|
||||
@Param("userId") int userId,
|
||||
@Param("userType") UserType userType,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime,
|
||||
@Param("projectIds") String projectIds);
|
||||
|
||||
List<Integer> querySubIdListByParentId(@Param("parentInstanceId") int parentInstanceId);
|
||||
|
||||
|
||||
List<ProcessInstance> queryByProcessDefineId(@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("size") int size);
|
||||
|
||||
ProcessInstance queryByScheduleTime(@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("scheduleTime") String scheduleTime,
|
||||
@Param("excludeId") int excludeId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("projectIds") Integer[] projectIds);
|
||||
|
||||
List<ProcessInstance> queryByProcessDefineId(
|
||||
@Param("processDefinitionId") int processDefinitionId,
|
||||
@Param("size") int size);
|
||||
|
||||
ProcessInstance queryLastSchedulerProcess(@Param("processDefinitionId") int definitionId,
|
||||
@Param("startTime") String startTime,
|
||||
@ -83,6 +69,6 @@ public interface ProcessInstanceMapper extends BaseMapper<ProcessInstance> {
|
||||
@Param("states") int[] stateArray);
|
||||
|
||||
ProcessInstance queryLastManualProcess(@Param("processDefinitionId") int definitionId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -29,7 +31,7 @@ public interface QueueMapper extends BaseMapper<Queue> {
|
||||
IPage<Queue> queryQueuePaging(IPage<Queue> page,
|
||||
@Param("searchVal") String searchVal);
|
||||
|
||||
Queue queryByQueue(@Param("queue") String queue);
|
||||
List<Queue> queryAllQueueList(@Param("queue") String queue,
|
||||
@Param("queueName") String queueName);
|
||||
|
||||
Queue queryByQueueName(@Param("queueName") String queueName);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public interface ScheduleMapper extends BaseMapper<Schedule> {
|
||||
List<Schedule> querySchedulerListByProjectName(@Param("projectName") String projectName);
|
||||
|
||||
|
||||
List<Schedule> selectAllByProcessDefineArray(@Param("processDefineIds") String processDefineIds);
|
||||
List<Schedule> selectAllByProcessDefineArray(@Param("processDefineIds") int[] processDefineIds);
|
||||
|
||||
List<Schedule> queryByProcessDefinitionId(@Param("processDefinitionId") int processDefinitionId);
|
||||
|
||||
|
@ -21,11 +21,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TenantMapper extends BaseMapper<Tenant> {
|
||||
|
||||
Tenant queryById(@Param("tenantId") int tenantId);
|
||||
|
||||
Tenant queryByTenantCode(@Param("tenantCode") String tenantCode);
|
||||
List<Tenant> queryByTenantCode(@Param("tenantCode") String tenantCode);
|
||||
|
||||
IPage<Tenant> queryTenantPaging(IPage<Tenant> page,
|
||||
@Param("searchVal") String searchVal);
|
||||
|
@ -25,12 +25,12 @@
|
||||
<if test="userId != 0">
|
||||
and id in
|
||||
(select datasource_id
|
||||
from t_escheduler_relation_datasource_user
|
||||
where user_id=#{userId}
|
||||
union select id as datasource_id
|
||||
from t_escheduler_datasource
|
||||
where user_id=#{userId}
|
||||
)
|
||||
from t_escheduler_relation_datasource_user
|
||||
where user_id=#{userId}
|
||||
union select id as datasource_id
|
||||
from t_escheduler_datasource
|
||||
where user_id=#{userId}
|
||||
)
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat ('%', #{name}, '%')
|
||||
|
@ -18,4 +18,9 @@
|
||||
from t_escheduler_relation_process_instance
|
||||
where process_instance_id = #{subProcessId}
|
||||
</select>
|
||||
<select id="querySubIdListByParentId" resultType="java.lang.Integer">
|
||||
select process_instance_id
|
||||
from t_escheduler_process_instance_map
|
||||
where parent_process_instance_id = #{parentInstanceId}
|
||||
</select>
|
||||
</mapper>
|
@ -2,8 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.escheduler.dao.mapper.ProcessInstanceMapper">
|
||||
<select id="queryDetailById" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select inst.*,UNIX_TIMESTAMP(inst.end_time)-UNIX_TIMESTAMP(inst.start_time) as duration
|
||||
from t_escheduler_process_instance
|
||||
select inst.*
|
||||
from t_escheduler_process_instance inst
|
||||
where inst.id = #{processId}
|
||||
</select>
|
||||
<select id="queryByHostAndStatus" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
@ -13,15 +13,19 @@
|
||||
<if test="host != null and host != ''">
|
||||
and host=#{host}
|
||||
</if>
|
||||
and state in (#{states})
|
||||
and state in
|
||||
<foreach collection="states" item="i" open="(" close=")" separator=",">
|
||||
#{i}
|
||||
</foreach>
|
||||
order by id asc
|
||||
</select>
|
||||
<select id="queryProcessInstanceListPaging" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select instance.*, (UNIX_TIMESTAMP(instance.end_time) - UNIX_TIMESTAMP(instance.start_time)) as duration
|
||||
select instance.*
|
||||
from t_escheduler_process_instance instance
|
||||
join t_escheduler_process_definition define ON instance.process_definition_id = define.id
|
||||
where 1=1
|
||||
and instance.is_sub_process=0 and define.project_id = #{projectId}
|
||||
and instance.is_sub_process=0
|
||||
and define.project_id = #{projectId}
|
||||
<if test="processDefinitionId != 0">
|
||||
and instance.process_definition_id = #{processDefinitionId}
|
||||
</if>
|
||||
@ -32,7 +36,10 @@
|
||||
and instance.start_time > #{startTime} and instance.start_time <![CDATA[ <=]]> #{endTime}
|
||||
</if>
|
||||
<if test="states != null and states != ''">
|
||||
and instance.state in ( #{states} )
|
||||
and instance.state in
|
||||
<foreach collection="states" index="index" item="i" open="(" separator="," close=")">
|
||||
#{i}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
and instance.host like concat('%', #{host}, '%')
|
||||
@ -42,60 +49,42 @@
|
||||
<update id="setFailoverByHostAndStateArray">
|
||||
update t_escheduler_process_instance
|
||||
set host=null
|
||||
where host =#{host} and state in (#{states})
|
||||
where host =#{host} and state in
|
||||
<foreach collection="states" index="index" item="i" open="(" close=")" separator=",">
|
||||
#{i}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateProcessInstanceByState">
|
||||
update t_escheduler_process_instance
|
||||
set state = #{destState}
|
||||
where state = #{originState}
|
||||
</update>
|
||||
<select id="queryByTaskId" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select process.*, UNIX_TIMESTAMP(process.end_time)-UNIX_TIMESTAMP(process.start_time) as duration
|
||||
from t_escheduler_process_instance process
|
||||
join t_escheduler_task_instance task on task.process_instance_id = process.id
|
||||
where task.id = #{taskId}
|
||||
</select>
|
||||
<select id="countInstanceStateByUser" resultType="cn.escheduler.dao.entity.ExecuteStatusCount">
|
||||
select state, count(0) as count
|
||||
select t.state, count(0) as count
|
||||
from t_escheduler_process_instance t
|
||||
join t_escheduler_process_definition d on d.id=t.process_definition_id
|
||||
join t_escheduler_project p on p.id=d.project_id
|
||||
where t.flag = 1
|
||||
where 1 = 1
|
||||
and t.is_sub_process = 0
|
||||
and t.start_time > #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
|
||||
<if test="startTime != null and endTime != null">
|
||||
and t.start_time >= #{startTime} and t.start_time <![CDATA[ <= ]]> #{endTime}
|
||||
</if>
|
||||
<if test="projectIds != null and projectIds != ''">
|
||||
and p.id in (#projectIds)
|
||||
and p.id in
|
||||
<foreach collection="projectIds" index="index" item="i" open="(" close=")" separator=",">
|
||||
#{i}
|
||||
</foreach>
|
||||
</if>
|
||||
group by t.state
|
||||
</select>
|
||||
<select id="querySubIdListByParentId" resultType="java.lang.Integer">
|
||||
select process_instance_id
|
||||
from t_escheduler_process_instance
|
||||
where parent_process_instance_id = #{parentInstanceId}
|
||||
</select>
|
||||
<select id="queryByProcessDefineId" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select *,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration
|
||||
select *
|
||||
from t_escheduler_process_instance
|
||||
where process_definition_id=#{processDefinitionId}
|
||||
order by start_time desc limit #{size}
|
||||
</select>
|
||||
<select id="queryByScheduleTime" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select *,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration
|
||||
from t_escheduler_process_instance
|
||||
where process_definition_id=#{processDefinitionId}
|
||||
<if test="scheduleTime != null" >
|
||||
and schedule_time=#{scheduleTime}
|
||||
</if>
|
||||
<if test="startTime!=null and endTime != null ">
|
||||
and command_start_time between #{startTime} and #{endTime}
|
||||
</if>
|
||||
<if test="excludeId != 0">
|
||||
where id not in (#{excludeId})
|
||||
</if>
|
||||
order by startTime desc limit 1
|
||||
</select>
|
||||
<select id="queryLastSchedulerProcess" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select *,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration
|
||||
select *
|
||||
from t_escheduler_process_instance
|
||||
where process_definition_id=#{processDefinitionId}
|
||||
<if test="startTime!=null and endTime != null ">
|
||||
@ -104,16 +93,23 @@
|
||||
order by end_time desc limit 1
|
||||
</select>
|
||||
<select id="queryLastRunningProcess" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select *,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration
|
||||
select *
|
||||
from t_escheduler_process_instance
|
||||
where state in (#{states})
|
||||
where 1=1
|
||||
<if test="states !=null and states.length != 0">
|
||||
and state in
|
||||
<foreach collection="states" item="i" index="index" open="(" separator="," close=")">
|
||||
#{i}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="startTime!=null and endTime != null ">
|
||||
and process_definition_id=#{processDefinitionId}
|
||||
and (schedule_time between #{startTime} and #{endTime} or start_time between #{startTime} and #{endTime})
|
||||
</if>
|
||||
order by start_time desc limit 1
|
||||
</select>
|
||||
<select id="queryLastManualProcess" resultType="cn.escheduler.dao.entity.ProcessInstance">
|
||||
select *,UNIX_TIMESTAMP(end_time)-UNIX_TIMESTAMP(start_time) as duration
|
||||
select *
|
||||
from t_escheduler_process_instance
|
||||
where process_definition_id=#{processDefinitionId}
|
||||
and schedule_time is null
|
||||
|
@ -3,17 +3,17 @@
|
||||
<mapper namespace="cn.escheduler.dao.mapper.ProjectUserMapper">
|
||||
<delete id="deleteProjectRelation">
|
||||
delete from t_escheduler_relation_project_user
|
||||
where user_id = #{userId}
|
||||
where 1=1
|
||||
and user_id = #{userId}
|
||||
<if test="projectId != 0 ">
|
||||
and project_id = #{projectId}
|
||||
</if>
|
||||
</delete>
|
||||
<select id="queryProjectRelation" resultType="cn.escheduler.dao.entity.ProjectUser">
|
||||
select p_u.*, u.user_name as user_name, p.name as proect_name
|
||||
from t_escheduler_relation_project_user p_u
|
||||
join t_escheduler_user u on u.id = p_u.user_id
|
||||
join t_escheduler_project p on p.id = p_u.project_id
|
||||
where p_u.project_id = #{projectId}
|
||||
and p_u.user_id = #{userId}
|
||||
select *
|
||||
from t_escheduler_relation_project_user
|
||||
where project_id = #{projectId}
|
||||
and user_id = #{userId}
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
@ -4,19 +4,22 @@
|
||||
<select id="queryQueuePaging" resultType="cn.escheduler.dao.entity.Queue">
|
||||
select *
|
||||
from t_escheduler_queue
|
||||
where queue_name like concat('%', #{searchVal}, '%')
|
||||
where 1= 1
|
||||
<if test="searchVal != null and searchVal != ''">
|
||||
and queue_name like concat('%', #{searchVal}, '%')
|
||||
</if>
|
||||
order by update_time desc
|
||||
</select>
|
||||
<select id="queryByQueue" resultType="cn.escheduler.dao.entity.Queue">
|
||||
select *
|
||||
from t_escheduler_queue
|
||||
where queue=#{queue}
|
||||
order by update_time desc
|
||||
</select>
|
||||
<select id="queryByQueueName" resultType="cn.escheduler.dao.entity.Queue">
|
||||
<select id="queryAllQueueList" resultType="cn.escheduler.dao.entity.Queue">
|
||||
select *
|
||||
from t_escheduler_queue
|
||||
where queue_name =#{queueName}
|
||||
where 1=1
|
||||
<if test="queue != null and queue != ''">
|
||||
and queue = #{queue}
|
||||
</if>
|
||||
<if test="queueName != null and queueName != ''">
|
||||
and queue_name =#{queueName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -9,7 +9,7 @@
|
||||
and user_id = #{userId}
|
||||
</if>
|
||||
<if test="resourceId != 0">
|
||||
and resource_id = #{resourceId}
|
||||
and resources_id = #{resourceId}
|
||||
</if>
|
||||
</delete>
|
||||
</mapper>
|
@ -14,7 +14,7 @@
|
||||
order by s.update_time desc
|
||||
</select>
|
||||
<select id="querySchedulerListByProjectName" resultType="cn.escheduler.dao.entity.Schedule">
|
||||
select p_f.name as process_definition_name, p_f.desc as `desc`, p.name as project_name,u.user_name,s.*
|
||||
select p_f.name as process_definition_name, p_f.description as definition_description, p.name as project_name,u.user_name,s.*
|
||||
from t_escheduler_schedules s
|
||||
join t_escheduler_process_definition p_f on s.process_definition_id = p_f.id
|
||||
join t_escheduler_project as p on p_f.project_id = p.id
|
||||
@ -24,7 +24,13 @@
|
||||
<select id="selectAllByProcessDefineArray" resultType="cn.escheduler.dao.entity.Schedule">
|
||||
select *
|
||||
from t_escheduler_schedules
|
||||
where process_definition_id in (#{processDefineIds})
|
||||
where 1= 1
|
||||
<if test="processDefineIds != null and processDefineIds.length != 0 ">
|
||||
and process_definition_id in
|
||||
<foreach collection="processDefineIds" index="index" item="i" open="(" separator="," close=")">
|
||||
#{i}
|
||||
</foreach>
|
||||
</if>
|
||||
and release_state = 1
|
||||
</select>
|
||||
<select id="queryByProcessDefinitionId" resultType="cn.escheduler.dao.entity.Schedule">
|
||||
|
@ -10,11 +10,11 @@
|
||||
<select id="queryByTenantCode" resultType="cn.escheduler.dao.entity.Tenant">
|
||||
select *
|
||||
from t_escheduler_tenant
|
||||
where `tenant_code` = #{tenantCode}
|
||||
where tenant_code = #{tenantCode}
|
||||
</select>
|
||||
<select id="queryTenantPaging" resultType="cn.escheduler.dao.entity.Tenant">
|
||||
SELECT t.*,q.queue_name
|
||||
FROM t_escheduler_tenantt,t_escheduler_queue q
|
||||
FROM t_escheduler_tenant t,t_escheduler_queue q
|
||||
WHERE t.queue_id = q.id
|
||||
<if test="searchVal != null and searchVal != ''">
|
||||
and t.tenant_name like concat('%', #{searchVal}, '%')
|
||||
|
@ -114,4 +114,20 @@ public class ProcessInstanceMapMapperTest {
|
||||
);
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void querySubIdListByParentId() {
|
||||
ProcessInstanceMap processInstanceMap = insertOne();
|
||||
processInstanceMap.setProcessInstanceId(1);
|
||||
processInstanceMap.setParentProcessInstanceId(1010);
|
||||
|
||||
processInstanceMapMapper.updateById(processInstanceMap);
|
||||
|
||||
List<Integer> subIds = processInstanceMapMapper.querySubIdListByParentId(processInstanceMap.getParentProcessInstanceId());
|
||||
|
||||
Assert.assertNotEquals(subIds.size(), 0);
|
||||
|
||||
processInstanceMapMapper.deleteById(processInstanceMap.getId());
|
||||
|
||||
}
|
||||
}
|
@ -17,15 +17,21 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.dao.entity.ProcessInstance;
|
||||
import cn.escheduler.dao.entity.ProcessInstanceMap;
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
import cn.escheduler.common.enums.Flag;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.dao.entity.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mortbay.jetty.servlet.AbstractSessionIdManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ -36,12 +42,24 @@ public class ProcessInstanceMapperTest {
|
||||
@Autowired
|
||||
ProcessInstanceMapper processInstanceMapper;
|
||||
|
||||
@Autowired
|
||||
ProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
@Autowired
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
|
||||
private ProcessInstance insertOne(){
|
||||
//insertOne
|
||||
ProcessInstance processInstanceMap = new ProcessInstance();
|
||||
processInstanceMapper.insert(processInstanceMap);
|
||||
return processInstanceMap;
|
||||
ProcessInstance processInstance = new ProcessInstance();
|
||||
Date start = new Date(2019-1900, 1-1, 1, 0, 10,0);
|
||||
Date end = new Date(2019-1900, 1-1, 1, 1, 0,0);
|
||||
processInstance.setStartTime(start);
|
||||
processInstance.setEndTime(end);
|
||||
processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS);
|
||||
|
||||
processInstanceMapper.insert(processInstance);
|
||||
return processInstance;
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -63,62 +81,207 @@ public class ProcessInstanceMapperTest {
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
ProcessInstance processInstanceMap = insertOne();
|
||||
ProcessInstance processInstance = insertOne();
|
||||
//query
|
||||
List<ProcessInstance> dataSources = processInstanceMapper.selectList(null);
|
||||
Assert.assertNotEquals(dataSources.size(), 0);
|
||||
processInstanceMapper.deleteById(processInstanceMap.getId());
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryDetailById() {
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
ProcessInstance processInstance1 = processInstanceMapper.queryDetailById(processInstance.getId());
|
||||
Assert.assertNotEquals(processInstance1, 50);
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByHostAndStatus() {
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstance.setHost("192.168.2.155");
|
||||
processInstance.setState(ExecutionStatus.RUNNING_EXEUTION);
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
int[] stateArray = new int[]{
|
||||
ExecutionStatus.RUNNING_EXEUTION.ordinal(),
|
||||
ExecutionStatus.SUCCESS.ordinal()};
|
||||
|
||||
processInstanceMapper.queryByHostAndStatus(processInstance.getHost(), stateArray);
|
||||
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryProcessInstanceListPaging() {
|
||||
|
||||
|
||||
int[] stateArray = new int[]{
|
||||
ExecutionStatus.RUNNING_EXEUTION.ordinal(),
|
||||
ExecutionStatus.SUCCESS.ordinal()};
|
||||
|
||||
ProcessDefinition processDefinition = new ProcessDefinition();
|
||||
processDefinition.setProjectId(1010);
|
||||
processDefinition.setReleaseState(ReleaseState.ONLINE);
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstance.setProcessDefinitionId(processDefinition.getId());
|
||||
processInstance.setState(ExecutionStatus.RUNNING_EXEUTION);
|
||||
processInstance.setIsSubProcess(Flag.NO);
|
||||
processInstance.setStartTime(new Date());
|
||||
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
|
||||
Page<ProcessInstance> page = new Page(1, 3);
|
||||
|
||||
IPage<ProcessInstance> processInstanceIPage = processInstanceMapper.queryProcessInstanceListPaging(
|
||||
page,
|
||||
processDefinition.getProjectId(),
|
||||
processInstance.getProcessDefinitionId(),
|
||||
processInstance.getName(),
|
||||
stateArray,
|
||||
processInstance.getHost(),
|
||||
null,
|
||||
null
|
||||
);
|
||||
Assert.assertNotEquals(processInstanceIPage.getTotal(), 0);
|
||||
|
||||
processDefinitionMapper.deleteById(processDefinition.getId());
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetFailoverByHostAndStateArray() {
|
||||
|
||||
int[] stateArray = new int[]{
|
||||
ExecutionStatus.RUNNING_EXEUTION.ordinal(),
|
||||
ExecutionStatus.SUCCESS.ordinal()};
|
||||
|
||||
ProcessInstance processInstance = insertOne();
|
||||
|
||||
processInstance.setState(ExecutionStatus.RUNNING_EXEUTION);
|
||||
processInstance.setHost("192.168.2.220");
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
String host = processInstance.getHost();
|
||||
int update = processInstanceMapper.setFailoverByHostAndStateArray(host, stateArray);
|
||||
Assert.assertNotEquals(update, 0);
|
||||
|
||||
processInstance = processInstanceMapper.selectById(processInstance.getId());
|
||||
Assert.assertEquals(processInstance.getHost(), null);
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateProcessInstanceByState() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByTaskId() {
|
||||
|
||||
ProcessInstance processInstance = insertOne();
|
||||
|
||||
processInstance.setState(ExecutionStatus.RUNNING_EXEUTION);
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
processInstanceMapper.updateProcessInstanceByState(ExecutionStatus.RUNNING_EXEUTION, ExecutionStatus.SUCCESS);
|
||||
|
||||
ProcessInstance processInstance1 = processInstanceMapper.selectById(processInstance.getId());
|
||||
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
Assert.assertEquals(processInstance1.getState(), ExecutionStatus.SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountInstanceStateByUser() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuerySubIdListByParentId() {
|
||||
processDefinitionMapper.delete(null);
|
||||
processInstanceMapper.delete(null);
|
||||
|
||||
Project project = new Project();
|
||||
project.setName("testProject");
|
||||
projectMapper.insert(project);
|
||||
|
||||
ProcessDefinition processDefinition = new ProcessDefinition();
|
||||
processDefinition.setProjectId(project.getId());
|
||||
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstance.setProcessDefinitionId(processDefinition.getId());
|
||||
int update = processInstanceMapper.updateById(processInstance);
|
||||
|
||||
Integer[] projectIds = new Integer[]{processDefinition.getProjectId()};
|
||||
|
||||
List<ExecuteStatusCount> executeStatusCounts = processInstanceMapper.countInstanceStateByUser(null, null, projectIds);
|
||||
|
||||
|
||||
Assert.assertNotEquals(executeStatusCounts.size(), 0);
|
||||
|
||||
projectMapper.deleteById(project.getId());
|
||||
processDefinitionMapper.deleteById(processDefinition.getId());
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByProcessDefineId() {
|
||||
}
|
||||
ProcessInstance processInstance = insertOne();
|
||||
ProcessInstance processInstance1 = insertOne();
|
||||
|
||||
@Test
|
||||
public void testQueryByScheduleTime() {
|
||||
|
||||
List<ProcessInstance> processInstances = processInstanceMapper.queryByProcessDefineId(processInstance.getProcessDefinitionId(), 1);
|
||||
Assert.assertEquals(processInstances.size(), 1);
|
||||
|
||||
processInstances = processInstanceMapper.queryByProcessDefineId(processInstance.getProcessDefinitionId(), 2);
|
||||
Assert.assertEquals(processInstances.size(), 2);
|
||||
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
processInstanceMapper.deleteById(processInstance1.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryLastSchedulerProcess() {
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstance.setScheduleTime(new Date());
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
ProcessInstance processInstance1 = processInstanceMapper.queryLastSchedulerProcess(processInstance.getProcessDefinitionId(), null, null );
|
||||
Assert.assertNotEquals(processInstance1, null);
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryLastRunningProcess() {
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstance.setState(ExecutionStatus.RUNNING_EXEUTION);
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
int[] stateArray = new int[]{
|
||||
ExecutionStatus.RUNNING_EXEUTION.ordinal(),
|
||||
ExecutionStatus.SUBMITTED_SUCCESS.ordinal()};
|
||||
|
||||
ProcessInstance processInstance1 = processInstanceMapper.queryLastRunningProcess(processInstance.getProcessDefinitionId(), null, null , stateArray);
|
||||
|
||||
Assert.assertNotEquals(processInstance1, null);
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryLastManualProcess() {
|
||||
ProcessInstance processInstance = insertOne();
|
||||
processInstanceMapper.updateById(processInstance);
|
||||
|
||||
Date start = new Date(2019-1900, 1-1, 01, 0, 0, 0);
|
||||
Date end = new Date(2019-1900, 1-1, 01, 5, 0, 0);
|
||||
ProcessInstance processInstance1 = processInstanceMapper.queryLastManualProcess(processInstance.getProcessDefinitionId(),start, end
|
||||
);
|
||||
Assert.assertEquals(processInstance1.getId(), processInstance.getId());
|
||||
|
||||
start = new Date(2019-1900, 1-1, 01, 1, 0, 0);
|
||||
processInstance1 = processInstanceMapper.queryLastManualProcess(processInstance.getProcessDefinitionId(),start, end
|
||||
);
|
||||
Assert.assertEquals(processInstance1, null);
|
||||
|
||||
processInstanceMapper.deleteById(processInstance.getId());
|
||||
|
||||
}
|
||||
}
|
@ -17,20 +17,79 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.ExecutionStatus;
|
||||
import cn.escheduler.dao.entity.ProjectUser;
|
||||
import cn.escheduler.dao.entity.ProjectUser;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ProjectUserMapperTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
ProjectUserMapper projectUserMapper;
|
||||
|
||||
private ProjectUser insertOne(){
|
||||
//insertOne
|
||||
ProjectUser projectUser = new ProjectUser();
|
||||
projectUser.setProjectId(1010);
|
||||
projectUser.setUserId(111);
|
||||
projectUserMapper.insert(projectUser);
|
||||
return projectUser;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
ProjectUser projectUser = insertOne();
|
||||
projectUser.setCreateTime(new Date());
|
||||
//update
|
||||
int update = projectUserMapper.updateById(projectUser);
|
||||
Assert.assertEquals(update, 1);
|
||||
projectUserMapper.deleteById(projectUser.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
ProjectUser projectUserMap = insertOne();
|
||||
int delete = projectUserMapper.deleteById(projectUserMap.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
ProjectUser projectUser = insertOne();
|
||||
//query
|
||||
List<ProjectUser> projectUsers = projectUserMapper.selectList(null);
|
||||
Assert.assertNotEquals(projectUsers.size(), 0);
|
||||
projectUserMapper.deleteById(projectUser.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteProjectRelation() {
|
||||
|
||||
|
||||
ProjectUser projectUser = insertOne();
|
||||
int delete = projectUserMapper.deleteProjectRelation(projectUser.getProjectId(), projectUser.getUserId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryProjectRelation() {
|
||||
ProjectUser projectUser = insertOne();
|
||||
ProjectUser projectUser1 = projectUserMapper.queryProjectRelation(projectUser.getProjectId(), projectUser.getUserId());
|
||||
Assert.assertNotEquals(projectUser1, null);
|
||||
|
||||
projectUserMapper.deleteById(projectUser.getId());
|
||||
}
|
||||
}
|
@ -17,24 +17,92 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.dao.entity.Queue;
|
||||
import cn.escheduler.dao.entity.Queue;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class QueueMapperTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
QueueMapper queueMapper;
|
||||
|
||||
|
||||
private Queue insertOne(){
|
||||
//insertOne
|
||||
Queue queue = new Queue();
|
||||
queue.setQueueName("queue");
|
||||
queue.setQueue("queue");
|
||||
queue.setCreateTime(new Date());
|
||||
queue.setUpdateTime(new Date());
|
||||
queueMapper.insert(queue);
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
Queue queue = insertOne();
|
||||
queue.setCreateTime(new Date());
|
||||
//update
|
||||
int update = queueMapper.updateById(queue);
|
||||
Assert.assertEquals(update, 1);
|
||||
queueMapper.deleteById(queue.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
Queue queue = insertOne();
|
||||
int delete = queueMapper.deleteById(queue.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
Queue queue = insertOne();
|
||||
//query
|
||||
List<Queue> queues = queueMapper.selectList(null);
|
||||
Assert.assertNotEquals(queues.size(), 0);
|
||||
queueMapper.deleteById(queue.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryQueuePaging() {
|
||||
|
||||
Queue queue = insertOne();
|
||||
Page<Queue> page = new Page(1,3);
|
||||
|
||||
IPage<Queue> queueIPage= queueMapper.queryQueuePaging(page,
|
||||
null);
|
||||
Assert.assertNotEquals(queueIPage.getTotal(), 0);
|
||||
|
||||
queueIPage= queueMapper.queryQueuePaging(page,
|
||||
queue.getQueueName());
|
||||
Assert.assertNotEquals(queueIPage.getTotal(), 0);
|
||||
queueMapper.deleteById(queue.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByQueue() {
|
||||
}
|
||||
public void queryAllQueueList() {
|
||||
Queue queue = insertOne();
|
||||
|
||||
@Test
|
||||
public void testQueryByQueueName() {
|
||||
List<Queue> queues = queueMapper.queryAllQueueList(queue.getQueue(), null);
|
||||
Assert.assertNotEquals(queues.size(), 0);
|
||||
|
||||
queues = queueMapper.queryAllQueueList(null, queue.getQueueName());
|
||||
Assert.assertNotEquals(queues.size(), 0);
|
||||
queueMapper.deleteById(queue.getId());
|
||||
}
|
||||
}
|
@ -17,16 +17,71 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.dao.entity.ResourcesUser;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ResourceUserMapperTest {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
ResourceUserMapper resourceUserMapper;
|
||||
|
||||
private ResourcesUser insertOne(){
|
||||
//insertOne
|
||||
ResourcesUser queue = new ResourcesUser();
|
||||
queue.setCreateTime(new Date());
|
||||
queue.setUpdateTime(new Date());
|
||||
queue.setUserId(11111);
|
||||
queue.setResourcesId(1110);
|
||||
resourceUserMapper.insert(queue);
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
ResourcesUser queue = insertOne();
|
||||
queue.setCreateTime(new Date());
|
||||
//update
|
||||
int update = resourceUserMapper.updateById(queue);
|
||||
Assert.assertEquals(update, 1);
|
||||
resourceUserMapper.deleteById(queue.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
ResourcesUser queue = insertOne();
|
||||
int delete = resourceUserMapper.deleteById(queue.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
ResourcesUser queue = insertOne();
|
||||
//query
|
||||
List<ResourcesUser> queues = resourceUserMapper.selectList(null);
|
||||
Assert.assertNotEquals(queues.size(), 0);
|
||||
resourceUserMapper.deleteById(queue.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteResourceUser() {
|
||||
|
||||
ResourcesUser queue = insertOne();
|
||||
int delete = resourceUserMapper.deleteResourceUser(
|
||||
queue.getUserId(),
|
||||
queue.getResourcesId());
|
||||
Assert.assertNotEquals(delete, 0);
|
||||
}
|
||||
}
|
@ -17,28 +17,177 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.common.enums.FailureStrategy;
|
||||
import cn.escheduler.common.enums.ReleaseState;
|
||||
import cn.escheduler.common.enums.WarningType;
|
||||
import cn.escheduler.dao.entity.ProcessDefinition;
|
||||
import cn.escheduler.dao.entity.Project;
|
||||
import cn.escheduler.dao.entity.Schedule;
|
||||
import cn.escheduler.dao.entity.User;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ScheduleMapperTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
ScheduleMapper scheduleMapper;
|
||||
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
@Autowired
|
||||
ProcessDefinitionMapper processDefinitionMapper;
|
||||
|
||||
private Schedule insertOne(){
|
||||
//insertOne
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setStartTime(new Date());
|
||||
schedule.setEndTime(new Date());
|
||||
schedule.setCrontab("");
|
||||
schedule.setFailureStrategy(FailureStrategy.CONTINUE);
|
||||
schedule.setReleaseState(ReleaseState.OFFLINE);
|
||||
schedule.setWarningType(WarningType.NONE);
|
||||
schedule.setCreateTime(new Date());
|
||||
schedule.setUpdateTime(new Date());
|
||||
scheduleMapper.insert(schedule);
|
||||
return schedule;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
Schedule schedule = insertOne();
|
||||
schedule.setCreateTime(new Date());
|
||||
//update
|
||||
int update = scheduleMapper.updateById(schedule);
|
||||
Assert.assertEquals(update, 1);
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
Schedule schedule = insertOne();
|
||||
int delete = scheduleMapper.deleteById(schedule.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
Schedule schedule = insertOne();
|
||||
//query
|
||||
List<Schedule> schedules = scheduleMapper.selectList(null);
|
||||
Assert.assertNotEquals(schedules.size(), 0);
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByProcessDefineIdPaging() {
|
||||
|
||||
User user = new User();
|
||||
user.setUserName("ut name");
|
||||
userMapper.insert(user);
|
||||
|
||||
Project project = new Project();
|
||||
project.setName("ut project");
|
||||
project.setUserId(user.getId());
|
||||
projectMapper.insert(project);
|
||||
|
||||
ProcessDefinition processDefinition = new ProcessDefinition();
|
||||
processDefinition.setProjectId(project.getId());
|
||||
processDefinition.setUserId(user.getId());
|
||||
processDefinition.setLocations("");
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
|
||||
Schedule schedule= insertOne();
|
||||
schedule.setUserId(user.getId());
|
||||
schedule.setProcessDefinitionId(processDefinition.getId());
|
||||
scheduleMapper.insert(schedule);
|
||||
|
||||
Page<Schedule> page = new Page(1,3);
|
||||
IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging(page,
|
||||
processDefinition.getId(), ""
|
||||
);
|
||||
Assert.assertNotEquals(scheduleIPage.getSize(), 0);
|
||||
|
||||
|
||||
projectMapper.deleteById(project.getId());
|
||||
processDefinitionMapper.deleteById(processDefinition.getId());
|
||||
userMapper.deleteById(user.getId());
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuerySchedulerListByProjectName() {
|
||||
|
||||
|
||||
User user = new User();
|
||||
user.setUserName("ut name");
|
||||
userMapper.insert(user);
|
||||
|
||||
Project project = new Project();
|
||||
project.setName("ut project");
|
||||
project.setUserId(user.getId());
|
||||
projectMapper.insert(project);
|
||||
|
||||
ProcessDefinition processDefinition = new ProcessDefinition();
|
||||
processDefinition.setProjectId(project.getId());
|
||||
processDefinition.setUserId(user.getId());
|
||||
processDefinition.setLocations("");
|
||||
processDefinitionMapper.insert(processDefinition);
|
||||
|
||||
Schedule schedule= insertOne();
|
||||
schedule.setUserId(user.getId());
|
||||
schedule.setProcessDefinitionId(processDefinition.getId());
|
||||
scheduleMapper.insert(schedule);
|
||||
|
||||
Page<Schedule> page = new Page(1,3);
|
||||
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(
|
||||
project.getName()
|
||||
);
|
||||
projectMapper.deleteById(project.getId());
|
||||
processDefinitionMapper.deleteById(processDefinition.getId());
|
||||
userMapper.deleteById(user.getId());
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
|
||||
Assert.assertNotEquals(schedules.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectAllByProcessDefineArray() {
|
||||
|
||||
Schedule schedule = insertOne();
|
||||
schedule.setProcessDefinitionId(12345);
|
||||
schedule.setReleaseState(ReleaseState.ONLINE);
|
||||
scheduleMapper.updateById(schedule);
|
||||
|
||||
List<Schedule> schedules= scheduleMapper.selectAllByProcessDefineArray(new int[] {schedule.getProcessDefinitionId()});
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
Assert.assertNotEquals(schedules.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByProcessDefinitionId() {
|
||||
public void queryByProcessDefinitionId() {
|
||||
Schedule schedule = insertOne();
|
||||
schedule.setProcessDefinitionId(12345);
|
||||
scheduleMapper.updateById(schedule);
|
||||
|
||||
List<Schedule> schedules= scheduleMapper.queryByProcessDefinitionId(schedule.getProcessDefinitionId());
|
||||
scheduleMapper.deleteById(schedule.getId());
|
||||
Assert.assertNotEquals(schedules.size(), 0);
|
||||
}
|
||||
}
|
@ -17,16 +17,66 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.dao.entity.Session;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SessionMapperTest {
|
||||
|
||||
@Autowired
|
||||
SessionMapper sessionMapper;
|
||||
|
||||
private Session insertOne(){
|
||||
//insertOne
|
||||
Session session = new Session();
|
||||
session.setLastLoginTime(new Date());
|
||||
session.setUserId(11111);
|
||||
sessionMapper.insert(session);
|
||||
return session;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
Session session = insertOne();
|
||||
session.setLastLoginTime(new Date());
|
||||
//update
|
||||
int update = sessionMapper.updateById(session);
|
||||
Assert.assertEquals(update, 1);
|
||||
sessionMapper.deleteById(session.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
Session session = insertOne();
|
||||
int delete = sessionMapper.deleteById(session.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
Session session = insertOne();
|
||||
//query
|
||||
List<Session> sessions = sessionMapper.selectList(null);
|
||||
Assert.assertNotEquals(sessions.size(), 0);
|
||||
sessionMapper.deleteById(session.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByUserId() {
|
||||
Session session = insertOne();
|
||||
List<Session> sessions = sessionMapper.queryByUserId(session.getUserId());
|
||||
Assert.assertNotEquals(sessions.size(), 0);
|
||||
|
||||
sessionMapper.deleteById(session.getId());
|
||||
}
|
||||
}
|
@ -17,24 +17,109 @@
|
||||
package cn.escheduler.dao.mapper;
|
||||
|
||||
|
||||
import cn.escheduler.dao.entity.Queue;
|
||||
import cn.escheduler.dao.entity.Tenant;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class TenantMapperTest {
|
||||
|
||||
@Autowired
|
||||
TenantMapper tenantMapper;
|
||||
|
||||
@Autowired
|
||||
QueueMapper queueMapper;
|
||||
|
||||
private Tenant insertOne(){
|
||||
//insertOne
|
||||
Tenant tenant = new Tenant();
|
||||
tenant.setCreateTime(new Date());
|
||||
tenant.setUpdateTime(new Date());
|
||||
tenantMapper.insert(tenant);
|
||||
return tenant;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate(){
|
||||
//insertOne
|
||||
Tenant tenant = insertOne();
|
||||
tenant.setUpdateTime(new Date());
|
||||
//update
|
||||
int update = tenantMapper.updateById(tenant);
|
||||
Assert.assertEquals(update, 1);
|
||||
tenantMapper.deleteById(tenant.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
Tenant tenant = insertOne();
|
||||
int delete = tenantMapper.deleteById(tenant.getId());
|
||||
Assert.assertEquals(delete, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() {
|
||||
Tenant tenant = insertOne();
|
||||
//query
|
||||
List<Tenant> tenants = tenantMapper.selectList(null);
|
||||
Assert.assertNotEquals(tenants.size(), 0);
|
||||
tenantMapper.deleteById(tenant.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryById() {
|
||||
|
||||
Queue queue = new Queue();
|
||||
queue.setQueueName("ut queue name");
|
||||
queue.setQueue("ut queue");
|
||||
queueMapper.insert(queue);
|
||||
|
||||
|
||||
Tenant tenant = insertOne();
|
||||
tenant.setQueueId(queue.getId());
|
||||
tenantMapper.updateById(tenant);
|
||||
|
||||
Tenant tenant1 = tenantMapper.queryById(tenant.getId());
|
||||
|
||||
tenantMapper.deleteById(tenant.getId());
|
||||
Assert.assertNotEquals(tenant1, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryByTenantCode() {
|
||||
|
||||
Tenant tenant = insertOne();
|
||||
tenant.setTenantCode("ut code");
|
||||
tenantMapper.updateById(tenant);
|
||||
|
||||
List<Tenant> tenant1 = tenantMapper.queryByTenantCode(tenant.getTenantCode());
|
||||
|
||||
tenantMapper.deleteById(tenant.getId());
|
||||
Assert.assertNotEquals(tenant1.size(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryTenantPaging() {
|
||||
Tenant tenant = insertOne();
|
||||
tenant.setTenantCode("ut code");
|
||||
tenant.setTenantName("ut name");
|
||||
tenantMapper.updateById(tenant);
|
||||
Page<Tenant> page = new Page(1,3);
|
||||
|
||||
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, tenant.getTenantName());
|
||||
|
||||
tenantMapper.deleteById(tenant.getId());
|
||||
Assert.assertNotEquals(tenantIPage.getTotal(), 0);
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ public abstract class AbstractYarnTask extends AbstractTask {
|
||||
/**
|
||||
* process instance
|
||||
*/
|
||||
protected ProcessInstance processInstance;
|
||||
|
||||
/**
|
||||
* process task
|
||||
@ -53,7 +52,6 @@ public abstract class AbstractYarnTask extends AbstractTask {
|
||||
public AbstractYarnTask(TaskProps taskProps, Logger logger) {
|
||||
super(taskProps, logger);
|
||||
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class);
|
||||
this.processInstance = processDao.findProcessInstanceByTaskId(taskProps.getTaskInstId());
|
||||
this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
|
||||
taskProps.getTaskDir(),
|
||||
taskProps.getTaskAppId(),
|
||||
|
Loading…
Reference in New Issue
Block a user