mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-05 13:48:10 +08:00
[Improvement-5880][api] Optimized data structure of pagination query API results (#5895)
* [5880][refactor]Optimized data structure of pagination query API results - refactor PageInfo and delete returnDataListPaging in API - modify the related Controller and Service and the corresponding Test * Merge branch 'dev' of github.com:apache/dolphinscheduler into dev Conflicts: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java Co-authored-by: 蔡泽华 <sorea1k@163.com>
This commit is contained in:
parent
1401c2e5f7
commit
f567517031
@ -24,7 +24,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_LIS
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ACCESS_TOKEN_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ACCESS_TOKEN_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
@ -128,13 +127,13 @@ public class AccessTokenController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
|
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = accessTokenService.queryAccessTokenList(loginUser, searchVal, pageNo, pageSize);
|
result = accessTokenService.queryAccessTokenList(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,14 +132,12 @@ public class AlertGroupController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = alertGroupService.listPaging(loginUser, searchVal, pageNo, pageSize);
|
return alertGroupService.listPaging(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,13 +226,11 @@ public class AlertPluginInstanceController extends BaseController {
|
|||||||
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
return alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
|
||||||
result = alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
|
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,9 @@ import static org.apache.dolphinscheduler.common.Constants.HTTP_X_FORWARDED_FOR;
|
|||||||
import static org.apache.dolphinscheduler.common.Constants.HTTP_X_REAL_IP;
|
import static org.apache.dolphinscheduler.common.Constants.HTTP_X_REAL_IP;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||||
import org.apache.dolphinscheduler.dao.entity.Resource;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -47,8 +45,8 @@ public class BaseController {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return check result code
|
* @return check result code
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> checkPageParams(int pageNo, int pageSize) {
|
public Result checkPageParams(int pageNo, int pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>(4);
|
Result result = new Result();
|
||||||
Status resultEnum = Status.SUCCESS;
|
Status resultEnum = Status.SUCCESS;
|
||||||
String msg = Status.SUCCESS.getMsg();
|
String msg = Status.SUCCESS.getMsg();
|
||||||
if (pageNo <= 0) {
|
if (pageNo <= 0) {
|
||||||
@ -58,8 +56,8 @@ public class BaseController {
|
|||||||
resultEnum = Status.REQUEST_PARAMS_NOT_VALID_ERROR;
|
resultEnum = Status.REQUEST_PARAMS_NOT_VALID_ERROR;
|
||||||
msg = MessageFormat.format(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getMsg(), Constants.PAGE_SIZE);
|
msg = MessageFormat.format(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getMsg(), Constants.PAGE_SIZE);
|
||||||
}
|
}
|
||||||
result.put(Constants.STATUS, resultEnum);
|
result.setCode(resultEnum.getCode());
|
||||||
result.put(Constants.MSG, msg);
|
result.setMsg(msg);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,25 +106,6 @@ public class BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* return data list with paging
|
|
||||||
* @param result result code
|
|
||||||
* @return result code
|
|
||||||
*/
|
|
||||||
public Result returnDataListPaging(Map<String, Object> result) {
|
|
||||||
Status status = (Status) result.get(Constants.STATUS);
|
|
||||||
if (status == Status.SUCCESS) {
|
|
||||||
result.put(Constants.MSG, Status.SUCCESS.getMsg());
|
|
||||||
PageInfo<Resource> pageInfo = (PageInfo<Resource>) result.get(Constants.DATA_LIST);
|
|
||||||
return success(pageInfo.getLists(), pageInfo.getCurrentPage(), pageInfo.getTotalCount(),
|
|
||||||
pageInfo.getTotalPage());
|
|
||||||
} else {
|
|
||||||
Integer code = status.getCode();
|
|
||||||
String msg = (String) result.get(Constants.MSG);
|
|
||||||
return error(code, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* success
|
* success
|
||||||
*
|
*
|
||||||
|
@ -186,6 +186,4 @@ public class DataAnalysisController extends BaseController {
|
|||||||
Map<String, Object> result = dataAnalysisService.countQueueState(loginUser, projectId);
|
Map<String, Object> result = dataAnalysisService.countQueueState(loginUser, projectId);
|
||||||
return returnDataList(result);
|
return returnDataList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -179,13 +179,12 @@ public class DataSourceController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
return dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,10 +278,14 @@ public class ProcessDefinitionController extends BaseController {
|
|||||||
@RequestParam(value = "pageNo") int pageNo,
|
@RequestParam(value = "pageNo") int pageNo,
|
||||||
@RequestParam(value = "pageSize") int pageSize,
|
@RequestParam(value = "pageSize") int pageSize,
|
||||||
@RequestParam(value = "processDefinitionCode") long processDefinitionCode) {
|
@RequestParam(value = "processDefinitionCode") long processDefinitionCode) {
|
||||||
Map<String, Object> result = processDefinitionService.queryProcessDefinitionVersions(loginUser
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
|
if (!result.checkResult()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = processDefinitionService.queryProcessDefinitionVersions(loginUser
|
||||||
, projectName, pageNo, pageSize, processDefinitionCode);
|
, projectName, pageNo, pageSize, processDefinitionCode);
|
||||||
|
|
||||||
return returnDataList(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -460,13 +464,13 @@ public class ProcessDefinitionController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam(value = "userId", required = false, defaultValue = "0") Integer userId,
|
@RequestParam(value = "userId", required = false, defaultValue = "0") Integer userId,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectName, searchVal, pageNo, pageSize, userId);
|
return processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectName, searchVal, pageNo, pageSize, userId);
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,14 +125,14 @@ public class ProcessInstanceController extends BaseController {
|
|||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
|
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = processInstanceService.queryProcessInstanceList(
|
result = processInstanceService.queryProcessInstanceList(
|
||||||
loginUser, projectName, processDefinitionId, startTime, endTime, searchVal, executorName, stateType, host, pageNo, pageSize);
|
loginUser, projectName, processDefinitionId, startTime, endTime, searchVal, executorName, stateType, host, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,8 +253,8 @@ public class ProcessInstanceController extends BaseController {
|
|||||||
@RequestParam(value = "endTime",required = true) String endTime
|
@RequestParam(value = "endTime",required = true) String endTime
|
||||||
|
|
||||||
) {
|
) {
|
||||||
projectName=ParameterUtils.handleEscapes(projectName);
|
projectName = ParameterUtils.handleEscapes(projectName);
|
||||||
Map<String,Object> result=processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectName, size, startTime, endTime);
|
Map<String,Object> result = processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectName, size, startTime, endTime);
|
||||||
return returnDataList(result);
|
return returnDataList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.QUERY_UNAUTHORIZED_PR
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROJECT_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_PROJECT_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
|
||||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||||
@ -171,13 +170,13 @@ public class ProjectController extends BaseController {
|
|||||||
@RequestParam("pageNo") Integer pageNo
|
@RequestParam("pageNo") Integer pageNo
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = projectService.queryProjectListPaging(loginUser, pageSize, pageNo, searchVal);
|
result = projectService.queryProjectListPaging(loginUser, pageSize, pageNo, searchVal);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,6 +300,4 @@ public class ProjectController extends BaseController {
|
|||||||
Map<String, Object> result = projectService.queryAllProjectList();
|
Map<String, Object> result = projectService.queryAllProjectList();
|
||||||
return returnDataList(result);
|
return returnDataList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_QUEUE_ERROR;
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_QUEUE_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_QUEUE_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.QueueService;
|
import org.apache.dolphinscheduler.api.service.QueueService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
@ -100,14 +99,14 @@ public class QueueController extends BaseController {
|
|||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = queueService.queryList(loginUser, searchVal, pageNo, pageSize);
|
result = queueService.queryList(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,6 +184,4 @@ public class QueueController extends BaseController {
|
|||||||
|
|
||||||
return queueService.verifyQueue(queue, queueName);
|
return queueService.verifyQueue(queue, queueName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public class ResourcesController extends BaseController {
|
|||||||
@RequestParam(value = "type") ResourceType type,
|
@RequestParam(value = "type") ResourceType type,
|
||||||
@RequestParam(value = "name") String alias,
|
@RequestParam(value = "name") String alias,
|
||||||
@RequestParam(value = "description", required = false) String description,
|
@RequestParam(value = "description", required = false) String description,
|
||||||
@RequestParam(value = "file" ,required = false) MultipartFile file) {
|
@RequestParam(value = "file",required = false) MultipartFile file) {
|
||||||
return resourceService.updateResource(loginUser, resourceId, alias, description, type, file);
|
return resourceService.updateResource(loginUser, resourceId, alias, description, type, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,14 +240,14 @@ public class ResourcesController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageSize") Integer pageSize
|
@RequestParam("pageSize") Integer pageSize
|
||||||
) {
|
) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = resourceService.queryResourceListPaging(loginUser, id, type, searchVal, pageNo, pageSize);
|
result = resourceService.queryResourceListPaging(loginUser, id, type, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -597,13 +597,13 @@ public class ResourcesController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageSize") Integer pageSize
|
@RequestParam("pageSize") Integer pageSize
|
||||||
) {
|
) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
result = udfFuncService.queryUdfFuncListPaging(loginUser, searchVal, pageNo, pageSize);
|
result = udfFuncService.queryUdfFuncListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,11 +28,9 @@ import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_SCHEDULE_ERROR
|
|||||||
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
|
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.SchedulerService;
|
import org.apache.dolphinscheduler.api.service.SchedulerService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||||
@ -240,14 +238,13 @@ public class SchedulerController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
if (!result.checkResult()) {
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
return result;
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize);
|
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.FORCE_TASK_SUCCESS_ER
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
@ -109,16 +108,14 @@ public class TaskInstanceController extends BaseController {
|
|||||||
@RequestParam(value = "endDate", required = false) String endTime,
|
@RequestParam(value = "endDate", required = false) String endTime,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
|
if (!result.checkResult()) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
return result;
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
|
||||||
return returnDataListPaging(result);
|
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = taskInstanceService.queryTaskListPaging(
|
result = taskInstanceService.queryTaskListPaging(
|
||||||
loginUser, projectName, processInstanceId, processInstanceName, taskName, executorName, startTime, endTime, searchVal, stateType, host, pageNo, pageSize);
|
loginUser, projectName, processInstanceId, processInstanceName, taskName, executorName, startTime, endTime, searchVal, stateType, host, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TENANT_ERROR;
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_OS_TENANT_CODE_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_OS_TENANT_CODE_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.TenantService;
|
import org.apache.dolphinscheduler.api.service.TenantService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
@ -114,13 +113,14 @@ public class TenantController extends BaseController {
|
|||||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize) {
|
@RequestParam("pageSize") Integer pageSize) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = tenantService.queryTenantList(loginUser, searchVal, pageNo, pageSize);
|
result = tenantService.queryTenantList(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,13 +137,14 @@ public class UsersController extends BaseController {
|
|||||||
@RequestParam("pageNo") Integer pageNo,
|
@RequestParam("pageNo") Integer pageNo,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
@RequestParam(value = "searchVal", required = false) String searchVal) {
|
@RequestParam(value = "searchVal", required = false) String searchVal) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = usersService.queryUserList(loginUser, searchVal, pageNo, pageSize);
|
result = usersService.queryUserList(loginUser, searchVal, pageNo, pageSize);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -435,7 +436,7 @@ public class UsersController extends BaseController {
|
|||||||
* @param repeatPassword repeat password
|
* @param repeatPassword repeat password
|
||||||
* @param email user email
|
* @param email user email
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value="registerUser",notes = "REGISTER_USER_NOTES")
|
@ApiOperation(value = "registerUser",notes = "REGISTER_USER_NOTES")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"),
|
@ApiImplicitParam(name = "userName", value = "USER_NAME", required = true, type = "String"),
|
||||||
@ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type = "String"),
|
@ApiImplicitParam(name = "userPassword", value = "USER_PASSWORD", required = true, type = "String"),
|
||||||
@ -463,7 +464,7 @@ public class UsersController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param userName user name
|
* @param userName user name
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value="activateUser",notes = "ACTIVATE_USER_NOTES")
|
@ApiOperation(value = "activateUser",notes = "ACTIVATE_USER_NOTES")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "userName", value = "USER_NAME", type = "String"),
|
@ApiImplicitParam(name = "userName", value = "USER_NAME", type = "String"),
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,6 @@ import static org.apache.dolphinscheduler.api.enums.Status.QUERY_WORKER_GROUP_FA
|
|||||||
import static org.apache.dolphinscheduler.api.enums.Status.SAVE_ERROR;
|
import static org.apache.dolphinscheduler.api.enums.Status.SAVE_ERROR;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
import org.apache.dolphinscheduler.api.exceptions.ApiException;
|
||||||
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
@ -112,13 +111,14 @@ public class WorkerGroupController extends BaseController {
|
|||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
@RequestParam(value = "searchVal", required = false) String searchVal
|
@RequestParam(value = "searchVal", required = false) String searchVal
|
||||||
) {
|
) {
|
||||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
Result result = checkPageParams(pageNo, pageSize);
|
||||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
if (!result.checkResult()) {
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||||
result = workerGroupService.queryAllGroupPaging(loginUser, pageNo, pageSize, searchVal);
|
result = workerGroupService.queryAllGroupPaging(loginUser, pageNo, pageSize, searchVal);
|
||||||
return returnDataListPaging(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -35,7 +36,7 @@ public interface AccessTokenService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return token list for page number and page size
|
* @return token list for page number and page size
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create token
|
* create token
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -42,7 +43,7 @@ public interface AlertGroupService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return alert group list page
|
* @return alert group list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create alert group
|
* create alert group
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -85,5 +86,5 @@ public interface AlertPluginInstanceService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return plugins
|
* @return plugins
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryPluginPage(int pageIndex,int pageSize);
|
Result queryPluginPage(int pageIndex, int pageSize);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public interface DataSourceService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return data source list page
|
* @return data source list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query data resource list
|
* query data resource list
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
@ -76,12 +77,12 @@ public interface ProcessDefinitionService {
|
|||||||
* @param userId user id
|
* @param userId user id
|
||||||
* @return process definition page
|
* @return process definition page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryProcessDefinitionListPaging(User loginUser,
|
Result queryProcessDefinitionListPaging(User loginUser,
|
||||||
String projectName,
|
String projectName,
|
||||||
String searchVal,
|
String searchVal,
|
||||||
Integer pageNo,
|
Integer pageNo,
|
||||||
Integer pageSize,
|
Integer pageSize,
|
||||||
Integer userId);
|
Integer userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query datail of process definition
|
* query datail of process definition
|
||||||
@ -285,7 +286,7 @@ public interface ProcessDefinitionService {
|
|||||||
* @param processDefinitionCode process definition code
|
* @param processDefinitionCode process definition code
|
||||||
* @return the pagination process definition versions info of the certain process definition
|
* @return the pagination process definition versions info of the certain process definition
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryProcessDefinitionVersions(User loginUser, String projectName,
|
Result queryProcessDefinitionVersions(User loginUser, String projectName,
|
||||||
int pageNo, int pageSize, long processDefinitionCode);
|
int pageNo, int pageSize, long processDefinitionCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,6 +300,7 @@ public interface ProcessDefinitionService {
|
|||||||
*/
|
*/
|
||||||
Map<String, Object> deleteByProcessDefinitionIdAndVersion(User loginUser, String projectName,
|
Map<String, Object> deleteByProcessDefinitionIdAndVersion(User loginUser, String projectName,
|
||||||
int processDefinitionId, long version);
|
int processDefinitionId, long version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check has associated process definition
|
* check has associated process definition
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.DependResult;
|
import org.apache.dolphinscheduler.common.enums.DependResult;
|
||||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||||
@ -65,10 +66,10 @@ public interface ProcessInstanceService {
|
|||||||
* @param endDate end time
|
* @param endDate end time
|
||||||
* @return process instance list
|
* @return process instance list
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
Result queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
||||||
String startDate, String endDate,
|
String startDate, String endDate,
|
||||||
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
||||||
Integer pageNo, Integer pageSize);
|
Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query task list by process instance id
|
* query task list by process instance id
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.dao.entity.Project;
|
import org.apache.dolphinscheduler.dao.entity.Project;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
@ -57,6 +58,8 @@ public interface ProjectService {
|
|||||||
|
|
||||||
boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result);
|
boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result);
|
||||||
|
|
||||||
|
boolean hasProjectAndPerm(User loginUser, Project project, Result result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* admin can view all projects
|
* admin can view all projects
|
||||||
*
|
*
|
||||||
@ -66,7 +69,7 @@ public interface ProjectService {
|
|||||||
* @param pageNo page number
|
* @param pageNo page number
|
||||||
* @return project list which the login user have permission to see
|
* @return project list which the login user have permission to see
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal);
|
Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete project by id
|
* delete project by id
|
||||||
|
@ -44,7 +44,7 @@ public interface QueueService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return queue list
|
* @return queue list
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create queue
|
* create queue
|
||||||
|
@ -97,7 +97,7 @@ public interface ResourcesService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return resource list page
|
* @return resource list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query resource list
|
* query resource list
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||||
@ -105,7 +106,7 @@ public interface SchedulerService {
|
|||||||
* @param searchVal search value
|
* @param searchVal search value
|
||||||
* @return schedule list page
|
* @return schedule list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize);
|
Result querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query schedule list
|
* query schedule list
|
||||||
|
@ -27,29 +27,29 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*/
|
*/
|
||||||
public interface SessionService {
|
public interface SessionService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get user session from request
|
* get user session from request
|
||||||
*
|
*
|
||||||
* @param request request
|
* @param request request
|
||||||
* @return session
|
* @return session
|
||||||
*/
|
*/
|
||||||
Session getSession(HttpServletRequest request);
|
Session getSession(HttpServletRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create session
|
* create session
|
||||||
*
|
*
|
||||||
* @param user user
|
* @param user user
|
||||||
* @param ip ip
|
* @param ip ip
|
||||||
* @return session string
|
* @return session string
|
||||||
*/
|
*/
|
||||||
String createSession(User user, String ip);
|
String createSession(User user, String ip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sign out
|
* sign out
|
||||||
* remove ip restrictions
|
* remove ip restrictions
|
||||||
*
|
*
|
||||||
* @param ip no use
|
* @param ip no use
|
||||||
* @param loginUser login user
|
* @param loginUser login user
|
||||||
*/
|
*/
|
||||||
void signOut(String ip, User loginUser);
|
void signOut(String ip, User loginUser);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
@ -43,10 +44,10 @@ public interface TaskInstanceService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return task list page
|
* @return task list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryTaskListPaging(User loginUser, String projectName,
|
Result queryTaskListPaging(User loginUser, String projectName,
|
||||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||||
Integer pageNo, Integer pageSize);
|
Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* change one task instance's state from failure to forced success
|
* change one task instance's state from failure to forced success
|
||||||
|
@ -51,7 +51,7 @@ public interface TenantService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return tenant list page
|
* @return tenant list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateProcessInstance tenant
|
* updateProcessInstance tenant
|
||||||
|
@ -89,7 +89,7 @@ public interface UdfFuncService {
|
|||||||
* @param searchVal search value
|
* @param searchVal search value
|
||||||
* @return udf function list page
|
* @return udf function list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query udf list
|
* query udf list
|
||||||
|
@ -112,7 +112,7 @@ public interface UsersService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return user list page
|
* @return user list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
Result queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updateProcessInstance user
|
* updateProcessInstance user
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service;
|
package org.apache.dolphinscheduler.api.service;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -46,7 +47,7 @@ public interface WorkerGroupService {
|
|||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
* @return worker group list page
|
* @return worker group list page
|
||||||
*/
|
*/
|
||||||
Map<String, Object> queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal);
|
Result queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* query all worker group
|
* query all worker group
|
||||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||||
@ -61,9 +62,8 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
* @return token list for page number and page size
|
* @return token list for page number and page size
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
|
|
||||||
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
Page<AccessToken> page = new Page<>(pageNo, pageSize);
|
Page<AccessToken> page = new Page<>(pageNo, pageSize);
|
||||||
int userId = loginUser.getId();
|
int userId = loginUser.getId();
|
||||||
@ -71,11 +71,10 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
userId = 0;
|
userId = 0;
|
||||||
}
|
}
|
||||||
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId);
|
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId);
|
||||||
pageInfo.setTotalCount((int) accessTokenList.getTotal());
|
pageInfo.setTotal((int) accessTokenList.getTotal());
|
||||||
pageInfo.setLists(accessTokenList.getRecords());
|
pageInfo.setTotalList(accessTokenList.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,11 +86,12 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
* @param token token string
|
* @param token token string
|
||||||
* @return create result code
|
* @return create result code
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:WhitespaceAround")
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
|
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
if (!hasPerm(loginUser,userId)){
|
if (!hasPerm(loginUser,userId)) {
|
||||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
|
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
if (!hasPerm(loginUser,userId)){
|
if (!hasPerm(loginUser,userId)) {
|
||||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -156,9 +156,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
|
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (!hasPerm(loginUser,accessToken.getUserId())) {
|
||||||
|
|
||||||
if (!hasPerm(loginUser,accessToken.getUserId())){
|
|
||||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -180,7 +178,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
|
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
if (!hasPerm(loginUser,userId)){
|
if (!hasPerm(loginUser,userId)) {
|
||||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
import org.apache.dolphinscheduler.api.service.AlertGroupService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
|
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||||
@ -79,10 +80,11 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
|
|||||||
* @return alert group list page
|
* @return alert group list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
if (isNotAdmin(loginUser, result)) {
|
if (!isAdmin(loginUser)) {
|
||||||
|
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,11 +92,10 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
|
|||||||
IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage(
|
IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage(
|
||||||
page, searchVal);
|
page, searchVal);
|
||||||
PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) alertGroupIPage.getTotal());
|
pageInfo.setTotal((int) alertGroupIPage.getTotal());
|
||||||
pageInfo.setLists(alertGroupIPage.getRecords());
|
pageInfo.setTotalList(alertGroupIPage.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service.impl;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
|
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO;
|
import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
|
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
|
||||||
@ -187,15 +188,15 @@ public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements A
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryPluginPage(int pageIndex, int pageSize) {
|
public Result queryPluginPage(int pageIndex, int pageSize) {
|
||||||
IPage<AlertPluginInstance> pluginInstanceIPage = new Page<>(pageIndex, pageSize);
|
IPage<AlertPluginInstance> pluginInstanceIPage = new Page<>(pageIndex, pageSize);
|
||||||
pluginInstanceIPage = alertPluginInstanceMapper.selectPage(pluginInstanceIPage, null);
|
pluginInstanceIPage = alertPluginInstanceMapper.selectPage(pluginInstanceIPage, null);
|
||||||
|
|
||||||
PageInfo<AlertPluginInstanceVO> pageInfo = new PageInfo<>(pageIndex, pageSize);
|
PageInfo<AlertPluginInstanceVO> pageInfo = new PageInfo<>(pageIndex, pageSize);
|
||||||
pageInfo.setTotalCount((int) pluginInstanceIPage.getTotal());
|
pageInfo.setTotal((int) pluginInstanceIPage.getTotal());
|
||||||
pageInfo.setLists(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
|
pageInfo.setTotalList(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -217,8 +217,8 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||||||
* @return data source list page
|
* @return data source list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
IPage<DataSource> dataSourceList;
|
IPage<DataSource> dataSourceList;
|
||||||
Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize);
|
Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize);
|
||||||
|
|
||||||
@ -231,9 +231,9 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||||||
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
|
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
|
||||||
handlePasswd(dataSources);
|
handlePasswd(dataSources);
|
||||||
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
|
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
|
||||||
pageInfo.setLists(dataSources);
|
pageInfo.setTotalList(dataSources);
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -308,7 +308,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||||||
* check connection
|
* check connection
|
||||||
*
|
*
|
||||||
* @param type data source type
|
* @param type data source type
|
||||||
* @param parameter data source parameters
|
* @param connectionParam data source parameters
|
||||||
* @return true if connect successfully, otherwise false
|
* @return true if connect successfully, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,14 +22,13 @@ import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
|||||||
import org.apache.dolphinscheduler.api.service.LoggerService;
|
import org.apache.dolphinscheduler.api.service.LoggerService;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.ArrayUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||||
import org.apache.dolphinscheduler.remote.utils.Host;
|
import org.apache.dolphinscheduler.remote.utils.Host;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClientService;
|
import org.apache.dolphinscheduler.service.log.LogClientService;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.dolphinscheduler.api.service.impl;
|
package org.apache.dolphinscheduler.api.service.impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.MonitorService;
|
import org.apache.dolphinscheduler.api.service.MonitorService;
|
||||||
import org.apache.dolphinscheduler.api.utils.RegistryCenterUtils;
|
import org.apache.dolphinscheduler.api.utils.RegistryCenterUtils;
|
||||||
@ -33,6 +27,13 @@ import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
|||||||
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.dao.entity.ZookeeperRecord;
|
import org.apache.dolphinscheduler.dao.entity.ZookeeperRecord;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import org.apache.dolphinscheduler.api.service.SchedulerService;
|
|||||||
import org.apache.dolphinscheduler.api.utils.CheckUtils;
|
import org.apache.dolphinscheduler.api.utils.CheckUtils;
|
||||||
import org.apache.dolphinscheduler.api.utils.FileUtils;
|
import org.apache.dolphinscheduler.api.utils.FileUtils;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
|
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
@ -107,7 +108,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process definition service impl
|
* process definition service impl
|
||||||
@ -267,15 +268,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|||||||
* @return process definition page
|
* @return process definition page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryProcessDefinitionListPaging(User loginUser, String projectName, String searchVal, Integer pageNo, Integer pageSize, Integer userId) {
|
public Result queryProcessDefinitionListPaging(User loginUser, String projectName, String searchVal, Integer pageNo, Integer pageSize, Integer userId) {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
Project project = projectMapper.queryByName(projectName);
|
Project project = projectMapper.queryByName(projectName);
|
||||||
|
|
||||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||||
if (resultStatus != Status.SUCCESS) {
|
if (resultStatus != Status.SUCCESS) {
|
||||||
return checkResult;
|
putMsg(result,resultStatus);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize);
|
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize);
|
||||||
@ -293,11 +295,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
processDefinitionIPage.setRecords(records);
|
processDefinitionIPage.setRecords(records);
|
||||||
|
|
||||||
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) processDefinitionIPage.getTotal());
|
pageInfo.setTotal((int) processDefinitionIPage.getTotal());
|
||||||
pageInfo.setLists(records);
|
pageInfo.setTotalList(processDefinitionIPage.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -1820,9 +1821,9 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|||||||
* @return the pagination process definition versions info of the certain process definition
|
* @return the pagination process definition versions info of the certain process definition
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, long processDefinitionCode) {
|
public Result queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, long processDefinitionCode) {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
|
|
||||||
// check the if pageNo or pageSize less than 1
|
// check the if pageNo or pageSize less than 1
|
||||||
if (pageNo <= 0 || pageSize <= 0) {
|
if (pageNo <= 0 || pageSize <= 0) {
|
||||||
@ -1839,7 +1840,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|||||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||||
if (resultStatus != Status.SUCCESS) {
|
if (resultStatus != Status.SUCCESS) {
|
||||||
return checkResult;
|
putMsg(result,resultStatus);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
|
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
|
||||||
@ -1851,12 +1853,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
|||||||
|
|
||||||
ProcessData processData = processService.genProcessData(processDefinition);
|
ProcessData processData = processService.genProcessData(processDefinition);
|
||||||
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
|
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
|
||||||
pageInfo.setLists(processDefinitionLogs);
|
pageInfo.setTotalList(processDefinitionLogs);
|
||||||
pageInfo.setTotalCount((int) processDefinitionVersionsPaging.getTotal());
|
pageInfo.setTotal((int) processDefinitionVersionsPaging.getTotal());
|
||||||
return ImmutableMap.of(
|
result.setData(pageInfo);
|
||||||
Constants.MSG, Status.SUCCESS.getMsg()
|
putMsg(result,Status.SUCCESS);
|
||||||
, Constants.STATUS, Status.SUCCESS
|
return result;
|
||||||
, Constants.DATA_LIST, pageInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,18 +235,19 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
|||||||
* @return process instance list
|
* @return process instance list
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
public Result queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
||||||
String startDate, String endDate,
|
String startDate, String endDate,
|
||||||
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
||||||
Integer pageNo, Integer pageSize) {
|
Integer pageNo, Integer pageSize) {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
Project project = projectMapper.queryByName(projectName);
|
Project project = projectMapper.queryByName(projectName);
|
||||||
|
|
||||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||||
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
|
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
|
||||||
if (resultEnum != Status.SUCCESS) {
|
if (resultEnum != Status.SUCCESS) {
|
||||||
return checkResult;
|
putMsg(result,resultEnum);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] statusArray = null;
|
int[] statusArray = null;
|
||||||
@ -256,8 +257,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
||||||
if (checkAndParseDateResult.get(Constants.STATUS) != Status.SUCCESS) {
|
resultEnum = (Status) checkAndParseDateResult.get(Constants.STATUS);
|
||||||
return checkAndParseDateResult;
|
if (resultEnum != Status.SUCCESS) {
|
||||||
|
putMsg(result,resultEnum);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME);
|
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME);
|
||||||
Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME);
|
Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME);
|
||||||
@ -269,8 +272,8 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
|||||||
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(processDefineId);
|
ProcessDefinition processDefinition = processDefineMapper.queryByDefineId(processDefineId);
|
||||||
|
|
||||||
IPage<ProcessInstance> processInstanceList = processInstanceMapper.queryProcessInstanceListPaging(page,
|
IPage<ProcessInstance> processInstanceList = processInstanceMapper.queryProcessInstanceListPaging(page,
|
||||||
project.getCode(), processDefinition == null ? 0L : processDefinition.getCode(), searchVal,
|
project.getCode(), processDefinition == null ? 0L : processDefinition.getCode(), searchVal,
|
||||||
executorId, statusArray, host, start, end);
|
executorId, statusArray, host, start, end);
|
||||||
|
|
||||||
List<ProcessInstance> processInstances = processInstanceList.getRecords();
|
List<ProcessInstance> processInstances = processInstanceList.getRecords();
|
||||||
List<Integer> userIds = CollectionUtils.transformToList(processInstances, ProcessInstance::getExecutorId);
|
List<Integer> userIds = CollectionUtils.transformToList(processInstances, ProcessInstance::getExecutorId);
|
||||||
@ -284,9 +287,9 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pageInfo.setTotalCount((int) processInstanceList.getTotal());
|
pageInfo.setTotal((int) processInstanceList.getTotal());
|
||||||
pageInfo.setLists(processInstances);
|
pageInfo.setTotalList(processInstances);
|
||||||
result.put(DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import static org.apache.dolphinscheduler.api.utils.CheckUtils.checkDesc;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
|
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
|
||||||
@ -97,7 +98,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
project = Project
|
project = Project
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.code(SnowFlakeUtils.getInstance().nextId())
|
.code(SnowFlakeUtils.getInstance().nextId())
|
||||||
@ -177,6 +178,19 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
|||||||
return checkResult;
|
return checkResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasProjectAndPerm(User loginUser, Project project, Result result) {
|
||||||
|
boolean checkResult = false;
|
||||||
|
if (project == null) {
|
||||||
|
putMsg(result, Status.PROJECT_NOT_FOUNT, "");
|
||||||
|
} else if (!checkReadPermission(loginUser, project)) {
|
||||||
|
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName());
|
||||||
|
} else {
|
||||||
|
checkResult = true;
|
||||||
|
}
|
||||||
|
return checkResult;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* admin can view all projects
|
* admin can view all projects
|
||||||
*
|
*
|
||||||
@ -187,8 +201,8 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
|||||||
* @return project list which the login user have permission to see
|
* @return project list which the login user have permission to see
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
|
public Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
PageInfo<Project> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Project> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
|
|
||||||
Page<Project> page = new Page<>(pageNo, pageSize);
|
Page<Project> page = new Page<>(pageNo, pageSize);
|
||||||
@ -202,12 +216,10 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
|||||||
project.setPerm(Constants.DEFAULT_ADMIN_PERMISSION);
|
project.setPerm(Constants.DEFAULT_ADMIN_PERMISSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageInfo.setTotalCount((int) projectIPage.getTotal());
|
pageInfo.setTotal((int) projectIPage.getTotal());
|
||||||
pageInfo.setLists(projectList);
|
pageInfo.setTotalList(projectList);
|
||||||
result.put(Constants.COUNT, (int) projectIPage.getTotal());
|
result.setData(pageInfo);
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +86,10 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
|
|||||||
* @return queue list
|
* @return queue list
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
if (isNotAdmin(loginUser, result)) {
|
if (!isAdmin(loginUser)) {
|
||||||
|
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,9 +99,9 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
|
|||||||
|
|
||||||
Integer count = (int) queueList.getTotal();
|
Integer count = (int) queueList.getTotal();
|
||||||
PageInfo<Queue> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Queue> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount(count);
|
pageInfo.setTotal(count);
|
||||||
pageInfo.setLists(queueList.getRecords());
|
pageInfo.setTotalList(queueList.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -512,9 +512,9 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||||||
* @return resource list page
|
* @return resource list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
|
|
||||||
HashMap<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
Page<Resource> page = new Page<>(pageNo, pageSize);
|
Page<Resource> page = new Page<>(pageNo, pageSize);
|
||||||
int userId = loginUser.getId();
|
int userId = loginUser.getId();
|
||||||
if (isAdmin(loginUser)) {
|
if (isAdmin(loginUser)) {
|
||||||
@ -533,9 +533,9 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||||||
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds);
|
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds);
|
||||||
|
|
||||||
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int)resourceIPage.getTotal());
|
pageInfo.setTotal((int)resourceIPage.getTotal());
|
||||||
pageInfo.setLists(resourceIPage.getRecords());
|
pageInfo.setTotalList(resourceIPage.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result,Status.SUCCESS);
|
putMsg(result,Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.service.MonitorService;
|
|||||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||||
import org.apache.dolphinscheduler.api.service.SchedulerService;
|
import org.apache.dolphinscheduler.api.service.SchedulerService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||||
@ -415,9 +416,9 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|||||||
* @return schedule list page
|
* @return schedule list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
|
|
||||||
HashMap<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
|
|
||||||
Project project = projectMapper.queryByName(projectName);
|
Project project = projectMapper.queryByName(projectName);
|
||||||
|
|
||||||
@ -438,11 +439,10 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
|||||||
);
|
);
|
||||||
|
|
||||||
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) scheduleIPage.getTotal());
|
pageInfo.setTotal((int) scheduleIPage.getTotal());
|
||||||
pageInfo.setLists(scheduleIPage.getRecords());
|
pageInfo.setTotalList(scheduleIPage.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
|
|||||||
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
import org.apache.dolphinscheduler.api.service.TaskInstanceService;
|
||||||
import org.apache.dolphinscheduler.api.service.UsersService;
|
import org.apache.dolphinscheduler.api.service.UsersService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||||
@ -88,35 +89,33 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
|
|||||||
* @return task list page
|
* @return task list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryTaskListPaging(User loginUser, String projectName,
|
public Result queryTaskListPaging(User loginUser, String projectName,
|
||||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||||
Integer pageNo, Integer pageSize) {
|
Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
Project project = projectMapper.queryByName(projectName);
|
Project project = projectMapper.queryByName(projectName);
|
||||||
|
|
||||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||||
Status status = (Status) checkResult.get(Constants.STATUS);
|
Status status = (Status) checkResult.get(Constants.STATUS);
|
||||||
if (status != Status.SUCCESS) {
|
if (status != Status.SUCCESS) {
|
||||||
return checkResult;
|
putMsg(result,status);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] statusArray = null;
|
int[] statusArray = null;
|
||||||
if (stateType != null) {
|
if (stateType != null) {
|
||||||
statusArray = new int[]{stateType.ordinal()};
|
statusArray = new int[]{stateType.ordinal()};
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
||||||
if (checkAndParseDateResult.get(Constants.STATUS) != Status.SUCCESS) {
|
status = (Status) checkAndParseDateResult.get(Constants.STATUS);
|
||||||
return checkAndParseDateResult;
|
if (status != Status.SUCCESS) {
|
||||||
|
putMsg(result,status);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME);
|
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME);
|
||||||
Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME);
|
Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME);
|
||||||
|
|
||||||
Page<TaskInstance> page = new Page<>(pageNo, pageSize);
|
Page<TaskInstance> page = new Page<>(pageNo, pageSize);
|
||||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
int executorId = usersService.getUserIdByName(executorName);
|
int executorId = usersService.getUserIdByName(executorName);
|
||||||
|
|
||||||
IPage<TaskInstance> taskInstanceIPage = taskInstanceMapper.queryTaskInstanceListPaging(
|
IPage<TaskInstance> taskInstanceIPage = taskInstanceMapper.queryTaskInstanceListPaging(
|
||||||
page, project.getCode(), processInstanceId, processInstanceName, searchVal, taskName, executorId, statusArray, host, start, end
|
page, project.getCode(), processInstanceId, processInstanceName, searchVal, taskName, executorId, statusArray, host, start, end
|
||||||
);
|
);
|
||||||
@ -132,11 +131,10 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
|
|||||||
taskInstance.setExecutorName(executor.getUserName());
|
taskInstance.setExecutorName(executor.getUserName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageInfo.setTotalCount((int) taskInstanceIPage.getTotal());
|
pageInfo.setTotal((int) taskInstanceIPage.getTotal());
|
||||||
pageInfo.setLists(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet));
|
pageInfo.setTotalList(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet));
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,19 +131,20 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
|||||||
* @return tenant list page
|
* @return tenant list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
if (isNotAdmin(loginUser, result)) {
|
if (!isAdmin(loginUser)) {
|
||||||
|
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Page<Tenant> page = new Page<>(pageNo, pageSize);
|
Page<Tenant> page = new Page<>(pageNo, pageSize);
|
||||||
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, searchVal);
|
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, searchVal);
|
||||||
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) tenantIPage.getTotal());
|
pageInfo.setTotal((int) tenantIPage.getTotal());
|
||||||
pageInfo.setLists(tenantIPage.getRecords());
|
pageInfo.setTotalList(tenantIPage.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
|
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
|
@ -246,13 +246,13 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
|
|||||||
* @return udf function list page
|
* @return udf function list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
PageInfo<UdfFunc> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<UdfFunc> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
IPage<UdfFunc> udfFuncList = getUdfFuncsPage(loginUser, searchVal, pageSize, pageNo);
|
IPage<UdfFunc> udfFuncList = getUdfFuncsPage(loginUser, searchVal, pageSize, pageNo);
|
||||||
pageInfo.setTotalCount((int)udfFuncList.getTotal());
|
pageInfo.setTotal((int)udfFuncList.getTotal());
|
||||||
pageInfo.setLists(udfFuncList.getRecords());
|
pageInfo.setTotalList(udfFuncList.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -318,10 +318,10 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||||||
* @return user list page
|
* @return user list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
public Result queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
|
if (!isAdmin(loginUser)) {
|
||||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,9 +330,9 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||||||
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal);
|
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal);
|
||||||
|
|
||||||
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount((int) scheduleList.getTotal());
|
pageInfo.setTotal((int) scheduleList.getTotal());
|
||||||
pageInfo.setLists(scheduleList.getRecords());
|
pageInfo.setTotalList(scheduleList.getRecords());
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
|
|||||||
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
import org.apache.dolphinscheduler.api.service.WorkerGroupService;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
import org.apache.dolphinscheduler.api.utils.RegistryCenterUtils;
|
import org.apache.dolphinscheduler.api.utils.RegistryCenterUtils;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.NodeType;
|
import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||||
@ -169,14 +170,15 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
|
|||||||
* @return worker group list page
|
* @return worker group list page
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal) {
|
public Result queryAllGroupPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal) {
|
||||||
// list from index
|
// list from index
|
||||||
int fromIndex = (pageNo - 1) * pageSize;
|
int fromIndex = (pageNo - 1) * pageSize;
|
||||||
// list to index
|
// list to index
|
||||||
int toIndex = (pageNo - 1) * pageSize + pageSize;
|
int toIndex = (pageNo - 1) * pageSize + pageSize;
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
if (isNotAdmin(loginUser, result)) {
|
if (!isAdmin(loginUser)) {
|
||||||
|
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,10 +207,10 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageInfo<WorkerGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
PageInfo<WorkerGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||||
pageInfo.setTotalCount(resultDataList.size());
|
pageInfo.setTotal(resultDataList.size());
|
||||||
pageInfo.setLists(resultDataList);
|
pageInfo.setTotalList(resultDataList);
|
||||||
|
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.api.utils;
|
package org.apache.dolphinscheduler.api.utils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,13 +27,17 @@ import java.util.List;
|
|||||||
public class PageInfo<T> {
|
public class PageInfo<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* totalList
|
||||||
*/
|
*/
|
||||||
private List<T> lists;
|
private List<T> totalList;
|
||||||
/**
|
/**
|
||||||
* total count
|
* total
|
||||||
*/
|
*/
|
||||||
private Integer totalCount = 0;
|
private Integer total = 0;
|
||||||
|
/**
|
||||||
|
* total Page
|
||||||
|
*/
|
||||||
|
private Integer totalPage;
|
||||||
/**
|
/**
|
||||||
* page size
|
* page size
|
||||||
*/
|
*/
|
||||||
@ -46,13 +51,13 @@ public class PageInfo<T> {
|
|||||||
*/
|
*/
|
||||||
private Integer pageNo;
|
private Integer pageNo;
|
||||||
|
|
||||||
public PageInfo(Integer currentPage,Integer pageSize){
|
public PageInfo(Integer currentPage, Integer pageSize) {
|
||||||
if(currentPage==null){
|
if (currentPage == null) {
|
||||||
currentPage=1;
|
currentPage = 1;
|
||||||
}
|
}
|
||||||
this.pageNo=(currentPage-1)*pageSize;
|
this.pageNo = (currentPage - 1) * pageSize;
|
||||||
this.pageSize=pageSize;
|
this.pageSize = pageSize;
|
||||||
this.currentPage=currentPage;
|
this.currentPage = currentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getStart() {
|
public Integer getStart() {
|
||||||
@ -63,37 +68,42 @@ public class PageInfo<T> {
|
|||||||
this.pageNo = start;
|
this.pageNo = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<T> getTotalList() {
|
||||||
|
return totalList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalList(List<T> totalList) {
|
||||||
|
this.totalList = totalList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotal() {
|
||||||
|
if (total == null) {
|
||||||
|
total = 0;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getTotalPage() {
|
public Integer getTotalPage() {
|
||||||
if (pageSize==null||pageSize == 0) {
|
if (pageSize == null || pageSize == 0) {
|
||||||
pageSize = 7;
|
pageSize = 7;
|
||||||
}
|
}
|
||||||
if (this.totalCount % this.pageSize == 0) {
|
this.totalPage =
|
||||||
return (this.totalCount / this.pageSize)==0?1:(this.totalCount / this.pageSize);
|
(this.total % this.pageSize) == 0
|
||||||
}
|
? ((this.total / this.pageSize) == 0 ? 1 : (this.total / this.pageSize))
|
||||||
return (this.totalCount / this.pageSize + 1);
|
: (this.total / this.pageSize + 1);
|
||||||
|
return this.totalPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> getLists() {
|
public void setTotalPage(Integer totalPage) {
|
||||||
return lists;
|
this.totalPage = totalPage;
|
||||||
}
|
|
||||||
|
|
||||||
public void setLists(List<T> lists) {
|
|
||||||
this.lists = lists;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTotalCount() {
|
|
||||||
if (totalCount==null) {
|
|
||||||
totalCount = 0;
|
|
||||||
}
|
|
||||||
return totalCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalCount(Integer totalCount) {
|
|
||||||
this.totalCount = totalCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageSize() {
|
public Integer getPageSize() {
|
||||||
if (pageSize==null||pageSize == 0) {
|
if (pageSize == null || pageSize == 0) {
|
||||||
pageSize = 7;
|
pageSize = 7;
|
||||||
}
|
}
|
||||||
return pageSize;
|
return pageSize;
|
||||||
@ -103,15 +113,14 @@ public class PageInfo<T> {
|
|||||||
this.pageSize = pageSize;
|
this.pageSize = pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCurrentPage() {
|
||||||
|
if (currentPage == null || currentPage <= 0) {
|
||||||
|
this.currentPage = 1;
|
||||||
|
}
|
||||||
|
return currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCurrentPage(Integer currentPage) {
|
public void setCurrentPage(Integer currentPage) {
|
||||||
this.currentPage = currentPage;
|
this.currentPage = currentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCurrentPage() {
|
|
||||||
if (currentPage==null||currentPage <= 0) {
|
|
||||||
this.currentPage = 1;
|
|
||||||
}
|
|
||||||
return this.currentPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -14,6 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.api.utils;
|
package org.apache.dolphinscheduler.api.utils;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
@ -129,7 +130,6 @@ public class Result<T> {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Status{"
|
return "Status{"
|
||||||
@ -139,4 +139,8 @@ public class Result<T> {
|
|||||||
+ ", data=" + data
|
+ ", data=" + data
|
||||||
+ '}';
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean checkResult() {
|
||||||
|
return this.code == Status.SUCCESS.getCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.common.enums.UserType;
|
|||||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -38,7 +38,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* access token controller test
|
* access token controller test
|
||||||
*/
|
*/
|
||||||
public class AccessTokenControllerTest extends AbstractControllerTest{
|
public class AccessTokenControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* alert group controller test
|
* alert group controller test
|
||||||
*/
|
*/
|
||||||
public class AlertGroupControllerTest extends AbstractControllerTest{
|
public class AlertGroupControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AlertGroupController.class);
|
private static final Logger logger = LoggerFactory.getLogger(AlertGroupController.class);
|
||||||
|
|
||||||
@ -110,7 +110,6 @@ public class AlertGroupControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyGroupName() throws Exception {
|
public void testVerifyGroupName() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
|
@ -21,7 +21,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* data analysis controller test
|
* data analysis controller test
|
||||||
*/
|
*/
|
||||||
public class DataAnalysisControllerTest extends AbstractControllerTest{
|
public class DataAnalysisControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class);
|
||||||
|
|
||||||
@ -113,7 +112,6 @@ public class DataAnalysisControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCountQueueState() throws Exception {
|
public void testCountQueueState() throws Exception {
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlDatasourceParamDTO;
|
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlDatasourceParamDTO;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
@ -42,7 +41,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* data source controller test
|
* data source controller test
|
||||||
*/
|
*/
|
||||||
public class DataSourceControllerTest extends AbstractControllerTest{
|
public class DataSourceControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(DataSourceControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(DataSourceControllerTest.class);
|
||||||
|
|
||||||
@ -70,7 +69,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDataSource() throws Exception {
|
public void testUpdateDataSource() throws Exception {
|
||||||
@ -97,8 +95,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testQueryDataSource() throws Exception {
|
public void testQueryDataSource() throws Exception {
|
||||||
@ -115,7 +111,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryDataSourceList() throws Exception {
|
public void testQueryDataSourceList() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -131,7 +126,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryDataSourceListPaging() throws Exception {
|
public void testQueryDataSourceListPaging() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -149,7 +143,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testConnectDataSource() throws Exception {
|
public void testConnectDataSource() throws Exception {
|
||||||
@ -173,7 +166,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testConnectionTest() throws Exception {
|
public void testConnectionTest() throws Exception {
|
||||||
@ -190,8 +182,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyDataSourceName() throws Exception {
|
public void testVerifyDataSourceName() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -207,7 +197,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthedDatasource() throws Exception {
|
public void testAuthedDatasource() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -223,7 +212,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnauthDatasource() throws Exception {
|
public void testUnauthDatasource() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -239,7 +227,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetKerberosStartupState() throws Exception {
|
public void testGetKerberosStartupState() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/datasources/kerberos-startup-state")
|
MvcResult mvcResult = mockMvc.perform(get("/datasources/kerberos-startup-state")
|
||||||
@ -252,8 +239,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws Exception {
|
public void testDelete() throws Exception {
|
||||||
|
@ -22,7 +22,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.ExecuteType;
|
import org.apache.dolphinscheduler.api.enums.ExecuteType;
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
import org.apache.dolphinscheduler.common.enums.WarningType;
|
import org.apache.dolphinscheduler.common.enums.WarningType;
|
||||||
|
@ -21,7 +21,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
|
||||||
@ -63,7 +62,6 @@ public class LoggerControllerTest extends AbstractControllerTest {
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDownloadTaskLog() throws Exception {
|
public void testDownloadTaskLog() throws Exception {
|
||||||
|
|
||||||
@ -74,9 +72,8 @@ public class LoggerControllerTest extends AbstractControllerTest {
|
|||||||
.header("sessionId", sessionId)
|
.header("sessionId", sessionId)
|
||||||
.params(paramsMap))
|
.params(paramsMap))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
// .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
/*.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))*/
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||||
Assert.assertTrue(result != null && result.isSuccess());
|
Assert.assertTrue(result != null && result.isSuccess());
|
||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
|
@ -21,7 +21,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* login controller test
|
* login controller test
|
||||||
*/
|
*/
|
||||||
public class LoginControllerTest extends AbstractControllerTest{
|
public class LoginControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(LoginControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(LoginControllerTest.class);
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/master/list")
|
MvcResult mvcResult = mockMvc.perform(get("/monitor/master/list")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
/* .param("type", ResourceType.FILE.name())*/ )
|
/* .param("type", ResourceType.FILE.name())*/)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
@ -60,7 +59,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/worker/list")
|
MvcResult mvcResult = mockMvc.perform(get("/monitor/worker/list")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
/* .param("type", ResourceType.FILE.name())*/ )
|
/* .param("type", ResourceType.FILE.name())*/)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
@ -75,7 +74,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
|||||||
public void testQueryDatabaseState() throws Exception {
|
public void testQueryDatabaseState() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/database")
|
MvcResult mvcResult = mockMvc.perform(get("/monitor/database")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
/* .param("type", ResourceType.FILE.name())*/ )
|
/* .param("type", ResourceType.FILE.name())*/)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
@ -90,7 +89,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
|||||||
public void testQueryZookeeperState() throws Exception {
|
public void testQueryZookeeperState() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/zookeeper/list")
|
MvcResult mvcResult = mockMvc.perform(get("/monitor/zookeeper/list")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
/* .param("type", ResourceType.FILE.name())*/ )
|
/* .param("type", ResourceType.FILE.name())*/)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
@ -105,6 +105,15 @@ public class ProcessDefinitionControllerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void putMsg(Result result, Status status, Object... statusParams) {
|
||||||
|
result.setCode(status.getCode());
|
||||||
|
if (statusParams != null && statusParams.length > 0) {
|
||||||
|
result.setMsg(MessageFormat.format(status.getMsg(), statusParams));
|
||||||
|
} else {
|
||||||
|
result.setMsg(status.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyProcessDefinitionName() throws Exception {
|
public void testVerifyProcessDefinitionName() throws Exception {
|
||||||
|
|
||||||
@ -355,9 +364,9 @@ public class ProcessDefinitionControllerTest {
|
|||||||
String searchVal = "";
|
String searchVal = "";
|
||||||
int userId = 1;
|
int userId = 1;
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
result.put(Constants.DATA_LIST, new PageInfo<Resource>(1, 10));
|
result.setData(new PageInfo<Resource>(1, 10));
|
||||||
|
|
||||||
Mockito.when(processDefinitionService.queryProcessDefinitionListPaging(user, projectName, searchVal, pageNo, pageSize, userId)).thenReturn(result);
|
Mockito.when(processDefinitionService.queryProcessDefinitionListPaging(user, projectName, searchVal, pageNo, pageSize, userId)).thenReturn(result);
|
||||||
Result response = processDefinitionController.queryProcessDefinitionListPaging(user, projectName, pageNo, searchVal, userId, pageSize);
|
Result response = processDefinitionController.queryProcessDefinitionListPaging(user, projectName, pageNo, searchVal, userId, pageSize);
|
||||||
@ -378,9 +387,9 @@ public class ProcessDefinitionControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testQueryProcessDefinitionVersions() {
|
public void testQueryProcessDefinitionVersions() {
|
||||||
String projectName = "test";
|
String projectName = "test";
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Result resultMap = new Result();
|
||||||
putMsg(resultMap, Status.SUCCESS);
|
putMsg(resultMap, Status.SUCCESS);
|
||||||
resultMap.put(Constants.DATA_LIST, new PageInfo<ProcessDefinitionLog>(1, 10));
|
resultMap.setData(new PageInfo<ProcessDefinitionLog>(1, 10));
|
||||||
Mockito.when(processDefinitionService.queryProcessDefinitionVersions(
|
Mockito.when(processDefinitionService.queryProcessDefinitionVersions(
|
||||||
user
|
user
|
||||||
, projectName
|
, projectName
|
||||||
|
@ -78,7 +78,9 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProcessInstance() throws Exception {
|
public void testUpdateProcessInstance() throws Exception {
|
||||||
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}";
|
String json = "{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":"
|
||||||
|
+ "\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\","
|
||||||
|
+ "\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}";
|
||||||
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}";
|
String locations = "{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}";
|
||||||
|
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -115,7 +117,6 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
|||||||
Assert.assertTrue(result.isSuccess());
|
Assert.assertTrue(result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQuerySubProcessInstanceByTaskId() throws Exception {
|
public void testQuerySubProcessInstanceByTaskId() throws Exception {
|
||||||
|
|
||||||
@ -146,7 +147,6 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
|||||||
Assert.assertTrue(result.isStatus(Status.PROCESS_INSTANCE_NOT_SUB_PROCESS_INSTANCE));
|
Assert.assertTrue(result.isStatus(Status.PROCESS_INSTANCE_NOT_SUB_PROCESS_INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testViewVariables() throws Exception {
|
public void testViewVariables() throws Exception {
|
||||||
|
|
||||||
@ -162,7 +162,6 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
|||||||
Assert.assertTrue(result.isSuccess());
|
Assert.assertTrue(result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteProcessInstanceById() throws Exception {
|
public void testDeleteProcessInstanceById() throws Exception {
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* resources controller test
|
* resources controller test
|
||||||
*/
|
*/
|
||||||
public class ResourcesControllerTest extends AbstractControllerTest{
|
public class ResourcesControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ResourcesControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ResourcesControllerTest.class);
|
||||||
|
|
||||||
@ -60,7 +60,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryResourceListPaging() throws Exception {
|
public void testQueryResourceListPaging() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -82,7 +81,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyResourceName() throws Exception {
|
public void testVerifyResourceName() throws Exception {
|
||||||
|
|
||||||
@ -111,7 +109,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
paramsMap.add("skipLineNum","2");
|
paramsMap.add("skipLineNum","2");
|
||||||
paramsMap.add("limit","100");
|
paramsMap.add("limit","100");
|
||||||
|
|
||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/resources/view")
|
MvcResult mvcResult = mockMvc.perform(get("/resources/view")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
.params(paramsMap))
|
.params(paramsMap))
|
||||||
@ -135,7 +132,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
paramsMap.add("description","test");
|
paramsMap.add("description","test");
|
||||||
paramsMap.add("content","echo 1111");
|
paramsMap.add("content","echo 1111");
|
||||||
|
|
||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/resources/online-create")
|
MvcResult mvcResult = mockMvc.perform(post("/resources/online-create")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
.params(paramsMap))
|
.params(paramsMap))
|
||||||
@ -156,7 +152,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
paramsMap.add("id", "1");
|
paramsMap.add("id", "1");
|
||||||
paramsMap.add("content","echo test_1111");
|
paramsMap.add("content","echo test_1111");
|
||||||
|
|
||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/resources/update-content")
|
MvcResult mvcResult = mockMvc.perform(post("/resources/update-content")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
.params(paramsMap))
|
.params(paramsMap))
|
||||||
@ -189,7 +184,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUdfFunc() throws Exception {
|
public void testCreateUdfFunc() throws Exception {
|
||||||
|
|
||||||
@ -202,7 +196,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
paramsMap.add("description", "description");
|
paramsMap.add("description", "description");
|
||||||
paramsMap.add("resourceId", "1");
|
paramsMap.add("resourceId", "1");
|
||||||
|
|
||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/resources/udf-func/create")
|
MvcResult mvcResult = mockMvc.perform(post("/resources/udf-func/create")
|
||||||
.header(SESSION_ID, sessionId)
|
.header(SESSION_ID, sessionId)
|
||||||
.params(paramsMap))
|
.params(paramsMap))
|
||||||
@ -235,7 +228,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateUdfFunc() throws Exception {
|
public void testUpdateUdfFunc() throws Exception {
|
||||||
|
|
||||||
@ -262,7 +254,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryUdfFuncList() throws Exception {
|
public void testQueryUdfFuncList() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -283,8 +274,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryResourceList() throws Exception {
|
public void testQueryResourceList() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -303,7 +292,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyUdfFuncName() throws Exception {
|
public void testVerifyUdfFuncName() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -340,7 +328,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnauthorizedFile() throws Exception {
|
public void testUnauthorizedFile() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -359,7 +346,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthorizedUDFFunction() throws Exception {
|
public void testAuthorizedUDFFunction() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -396,7 +382,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteUdfFunc() throws Exception {
|
public void testDeleteUdfFunc() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -415,7 +400,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteResource() throws Exception {
|
public void testDeleteResource() throws Exception {
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||||
@ -41,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* scheduler controller test
|
* scheduler controller test
|
||||||
*/
|
*/
|
||||||
public class SchedulerControllerTest extends AbstractControllerTest{
|
public class SchedulerControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
|
||||||
|
|
||||||
@ -70,7 +69,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateSchedule() throws Exception {
|
public void testUpdateSchedule() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -113,7 +111,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOffline() throws Exception {
|
public void testOffline() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -131,7 +128,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryScheduleListPaging() throws Exception {
|
public void testQueryScheduleListPaging() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -152,7 +148,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryScheduleList() throws Exception {
|
public void testQueryScheduleList() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/list","cxc_1113")
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/list","cxc_1113")
|
||||||
@ -166,7 +161,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreviewSchedule() throws Exception {
|
public void testPreviewSchedule() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
|
||||||
|
@ -64,12 +64,13 @@ public class TaskInstanceControllerTest extends AbstractControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testQueryTaskListPaging() {
|
public void testQueryTaskListPaging() {
|
||||||
|
|
||||||
Map<String,Object> result = new HashMap<>();
|
Result result = new Result();
|
||||||
Integer pageNo = 1;
|
Integer pageNo = 1;
|
||||||
Integer pageSize = 20;
|
Integer pageSize = 20;
|
||||||
PageInfo pageInfo = new PageInfo<TaskInstance>(pageNo, pageSize);
|
PageInfo pageInfo = new PageInfo<TaskInstance>(pageNo, pageSize);
|
||||||
result.put(Constants.DATA_LIST, pageInfo);
|
result.setData(pageInfo);
|
||||||
result.put(Constants.STATUS, Status.SUCCESS);
|
result.setCode(Status.SUCCESS.getCode());
|
||||||
|
result.setMsg(Status.SUCCESS.getMsg());
|
||||||
|
|
||||||
when(taskInstanceService.queryTaskListPaging(any(), eq(""), eq(1), eq(""), eq(""), eq(""),any(), any(),
|
when(taskInstanceService.queryTaskListPaging(any(), eq(""), eq(1), eq(""), eq(""), eq(""),any(), any(),
|
||||||
eq(""), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(result);
|
eq(""), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(result);
|
||||||
|
@ -38,7 +38,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* tenant controller test
|
* tenant controller test
|
||||||
*/
|
*/
|
||||||
public class TenantControllerTest extends AbstractControllerTest{
|
public class TenantControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(TenantControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(TenantControllerTest.class);
|
||||||
|
|
||||||
@ -102,7 +102,6 @@ public class TenantControllerTest extends AbstractControllerTest{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyTenantCode() throws Exception {
|
public void testVerifyTenantCode() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
|
@ -22,7 +22,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
|||||||
/**
|
/**
|
||||||
* users controller test
|
* users controller test
|
||||||
*/
|
*/
|
||||||
public class UsersControllerTest extends AbstractControllerTest{
|
public class UsersControllerTest extends AbstractControllerTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(UsersControllerTest.class);
|
private static Logger logger = LoggerFactory.getLogger(UsersControllerTest.class);
|
||||||
|
|
||||||
@ -126,8 +125,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGrantUDFFunc() throws Exception {
|
public void testGrantUDFFunc() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -146,7 +143,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGrantDataSource() throws Exception {
|
public void testGrantDataSource() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -195,7 +191,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthorizedUser() throws Exception {
|
public void testAuthorizedUser() throws Exception {
|
||||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||||
@ -230,7 +225,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
|||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyUserName() throws Exception {
|
public void testVerifyUserName() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(get("/users/verify-user-name")
|
MvcResult mvcResult = mockMvc.perform(get("/users/verify-user-name")
|
||||||
|
@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.AccessTokenServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.AccessTokenServiceImpl;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||||
@ -66,18 +67,16 @@ public class AccessTokenServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testQueryAccessTokenList() {
|
public void testQueryAccessTokenList() {
|
||||||
|
|
||||||
IPage<AccessToken> tokenPage = new Page<>();
|
IPage<AccessToken> tokenPage = new Page<>();
|
||||||
tokenPage.setRecords(getList());
|
tokenPage.setRecords(getList());
|
||||||
tokenPage.setTotal(1L);
|
tokenPage.setTotal(1L);
|
||||||
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
|
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
Map<String, Object> result = accessTokenService.queryAccessTokenList(user, "zhangsan", 1, 10);
|
Result result = accessTokenService.queryAccessTokenList(user, "zhangsan", 1, 10);
|
||||||
|
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.getData();
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertTrue(pageInfo.getTotal() > 0);
|
||||||
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.get(Constants.DATA_LIST);
|
|
||||||
Assert.assertTrue(pageInfo.getTotalCount() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -134,8 +133,7 @@ public class AccessTokenServiceTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private User getLoginUser() {
|
||||||
private User getLoginUser(){
|
|
||||||
User loginUser = new User();
|
User loginUser = new User();
|
||||||
loginUser.setId(1);
|
loginUser.setId(1);
|
||||||
loginUser.setUserType(UserType.ADMIN_USER);
|
loginUser.setUserType(UserType.ADMIN_USER);
|
||||||
@ -165,7 +163,6 @@ public class AccessTokenServiceTest {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get dateStr
|
* get dateStr
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.AlertGroupServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.AlertGroupServiceImpl;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||||
@ -82,15 +83,15 @@ public class AlertGroupServiceTest {
|
|||||||
Mockito.when(alertGroupMapper.queryAlertGroupPage(any(Page.class), eq(groupName))).thenReturn(page);
|
Mockito.when(alertGroupMapper.queryAlertGroupPage(any(Page.class), eq(groupName))).thenReturn(page);
|
||||||
User user = new User();
|
User user = new User();
|
||||||
// no operate
|
// no operate
|
||||||
Map<String, Object> result = alertGroupService.listPaging(user, groupName, 1, 10);
|
Result result = alertGroupService.listPaging(user, groupName, 1, 10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), (int) result.getCode());
|
||||||
//success
|
//success
|
||||||
user.setUserType(UserType.ADMIN_USER);
|
user.setUserType(UserType.ADMIN_USER);
|
||||||
result = alertGroupService.listPaging(user, groupName, 1, 10);
|
result = alertGroupService.listPaging(user, groupName, 1, 10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
PageInfo<AlertGroup> pageInfo = (PageInfo<AlertGroup>) result.get(Constants.DATA_LIST);
|
PageInfo<AlertGroup> pageInfo = (PageInfo<AlertGroup>) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ public class BaseServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAdmin(){
|
public void testIsAdmin() {
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUserType(UserType.ADMIN_USER);
|
user.setUserType(UserType.ADMIN_USER);
|
||||||
//ADMIN_USER
|
//ADMIN_USER
|
||||||
boolean isAdmin = baseService.isAdmin(user);
|
boolean isAdmin = baseService.isAdmin(user);
|
||||||
Assert.assertTrue(isAdmin);
|
Assert.assertTrue(isAdmin);
|
||||||
//GENERAL_USER
|
//GENERAL_USER
|
||||||
user.setUserType(UserType.GENERAL_USER);
|
user.setUserType(UserType.GENERAL_USER);
|
||||||
@ -75,10 +75,8 @@ public class BaseServiceTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPutMsg(){
|
public void testPutMsg() {
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
baseService.putMsg(result, Status.SUCCESS);
|
baseService.putMsg(result, Status.SUCCESS);
|
||||||
@ -87,8 +85,9 @@ public class BaseServiceTest {
|
|||||||
baseService.putMsg(result, Status.PROJECT_NOT_FOUNT,"test");
|
baseService.putMsg(result, Status.PROJECT_NOT_FOUNT,"test");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPutMsgTwo(){
|
public void testPutMsgTwo() {
|
||||||
|
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
baseService.putMsg(result, Status.SUCCESS);
|
baseService.putMsg(result, Status.SUCCESS);
|
||||||
@ -96,8 +95,9 @@ public class BaseServiceTest {
|
|||||||
//has params
|
//has params
|
||||||
baseService.putMsg(result,Status.PROJECT_NOT_FOUNT,"test");
|
baseService.putMsg(result,Status.PROJECT_NOT_FOUNT,"test");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateTenantDirIfNotExists(){
|
public void testCreateTenantDirIfNotExists() {
|
||||||
|
|
||||||
PowerMockito.mockStatic(HadoopUtils.class);
|
PowerMockito.mockStatic(HadoopUtils.class);
|
||||||
PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
|
PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
|
||||||
@ -111,8 +111,9 @@ public class BaseServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasPerm(){
|
public void testHasPerm() {
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setId(1);
|
user.setId(1);
|
||||||
|
@ -108,7 +108,6 @@ public class DataAnalysisServiceTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
|
|
||||||
@ -127,12 +126,11 @@ public class DataAnalysisServiceTest {
|
|||||||
Map<String, Object> result = dataAnalysisService.countTaskStateByProject(user, 2, startDate, endDate);
|
Map<String, Object> result = dataAnalysisService.countTaskStateByProject(user, 2, startDate, endDate);
|
||||||
Assert.assertTrue(result.isEmpty());
|
Assert.assertTrue(result.isEmpty());
|
||||||
|
|
||||||
|
|
||||||
//SUCCESS
|
//SUCCESS
|
||||||
Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
||||||
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
|
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
|
||||||
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
||||||
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
|
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), (Map<String, Object>)Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
result = dataAnalysisService.countTaskStateByProject(user, 1, startDate, endDate);
|
result = dataAnalysisService.countTaskStateByProject(user, 1, startDate, endDate);
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||||
@ -220,7 +218,7 @@ public class DataAnalysisServiceTest {
|
|||||||
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
||||||
Mockito.when(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
Mockito.when(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
||||||
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
|
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
|
||||||
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
|
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), (Map<String, Object>)Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
result = dataAnalysisService.countProcessInstanceStateByProject(user, 1, startDate, endDate);
|
result = dataAnalysisService.countProcessInstanceStateByProject(user, 1, startDate, endDate);
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||||
@ -251,7 +249,7 @@ public class DataAnalysisServiceTest {
|
|||||||
Mockito.when(errorCommandMapper.countCommandState(DateUtils.getScheduleDate(startDate),
|
Mockito.when(errorCommandMapper.countCommandState(DateUtils.getScheduleDate(startDate),
|
||||||
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
|
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
|
||||||
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
Mockito.when(projectMapper.selectById(Mockito.any())).thenReturn(getProject("test"));
|
||||||
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
|
Mockito.when(projectService.hasProjectAndPerm(Mockito.any(), Mockito.any(), (Map<String, Object>)Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
result = dataAnalysisService.countCommandState(user, 1, startDate, endDate);
|
result = dataAnalysisService.countCommandState(user, 1, startDate, endDate);
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||||
|
@ -180,8 +180,8 @@ public class DataSourceServiceTest {
|
|||||||
String searchVal = "";
|
String searchVal = "";
|
||||||
int pageNo = 1;
|
int pageNo = 1;
|
||||||
int pageSize = 10;
|
int pageSize = 10;
|
||||||
Map<String, Object> success = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
Result result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||||
Assert.assertEquals(Status.SUCCESS, success.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(),(int)result.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -55,7 +55,7 @@ public class MonitorServiceTest {
|
|||||||
private MonitorDBDao monitorDBDao;
|
private MonitorDBDao monitorDBDao;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryDatabaseState(){
|
public void testQueryDatabaseState() {
|
||||||
|
|
||||||
Mockito.when(monitorDBDao.queryDatabaseState()).thenReturn(getList());
|
Mockito.when(monitorDBDao.queryDatabaseState()).thenReturn(getList());
|
||||||
Map<String,Object> result = monitorService.queryDatabaseState(null);
|
Map<String,Object> result = monitorService.queryDatabaseState(null);
|
||||||
@ -64,41 +64,43 @@ public class MonitorServiceTest {
|
|||||||
List<MonitorRecord> monitorRecordList = (List<MonitorRecord>) result.get(Constants.DATA_LIST);
|
List<MonitorRecord> monitorRecordList = (List<MonitorRecord>) result.get(Constants.DATA_LIST);
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(monitorRecordList));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(monitorRecordList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryMaster(){
|
public void testQueryMaster() {
|
||||||
//TODO need zk
|
//TODO need zk
|
||||||
// Map<String,Object> result = monitorService.queryMaster(null);
|
/*Map<String,Object> result = monitorService.queryMaster(null);*/
|
||||||
// logger.info(result.toString());
|
/*logger.info(result.toString());*/
|
||||||
// Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
|
/*Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));*/
|
||||||
}
|
|
||||||
@Test
|
|
||||||
public void testQueryZookeeperState(){
|
|
||||||
//TODO need zk
|
|
||||||
// Map<String,Object> result = monitorService.queryZookeeperState(null);
|
|
||||||
// logger.info(result.toString());
|
|
||||||
// Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServerListFromZK(){
|
public void testQueryZookeeperState() {
|
||||||
//TODO need zk
|
//TODO need zk
|
||||||
// List<Server> serverList = monitorService.getServerListFromZK(true);
|
/*Map<String,Object> result = monitorService.queryZookeeperState(null);*/
|
||||||
// logger.info(serverList.toString());
|
/*logger.info(result.toString());*/
|
||||||
|
/*Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MonitorRecord> getList(){
|
@Test
|
||||||
|
public void testGetServerListFromZK() {
|
||||||
|
//TODO need zk
|
||||||
|
/*List<Server> serverList = monitorService.getServerListFromZK(true);*/
|
||||||
|
/*logger.info(serverList.toString());*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MonitorRecord> getList() {
|
||||||
List<MonitorRecord> monitorRecordList = new ArrayList<>();
|
List<MonitorRecord> monitorRecordList = new ArrayList<>();
|
||||||
monitorRecordList.add(getEntity());
|
monitorRecordList.add(getEntity());
|
||||||
return monitorRecordList;
|
return monitorRecordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MonitorRecord getEntity(){
|
private MonitorRecord getEntity() {
|
||||||
MonitorRecord monitorRecord = new MonitorRecord();
|
MonitorRecord monitorRecord = new MonitorRecord();
|
||||||
monitorRecord.setDbType(DbType.MYSQL);
|
monitorRecord.setDbType(DbType.MYSQL);
|
||||||
return monitorRecord;
|
return monitorRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Server> getServerList(){
|
private List<Server> getServerList() {
|
||||||
List<Server> servers = new ArrayList<>();
|
List<Server> servers = new ArrayList<>();
|
||||||
servers.add(new Server());
|
servers.add(new Server());
|
||||||
return servers;
|
return servers;
|
||||||
|
@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.api.dto.ProcessMeta;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.ProcessDefinitionServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.ProcessDefinitionServiceImpl;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||||
@ -313,8 +314,8 @@ public class ProcessDefinitionServiceTest {
|
|||||||
|
|
||||||
//project not found
|
//project not found
|
||||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
|
||||||
Map<String, Object> map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, "project_test1", "", 1, 5, 0);
|
Result map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, "project_test1", "", 1, 5, 0);
|
||||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS));
|
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int)map.getCode());
|
||||||
|
|
||||||
putMsg(result, Status.SUCCESS, projectName);
|
putMsg(result, Status.SUCCESS, projectName);
|
||||||
loginUser.setId(1);
|
loginUser.setId(1);
|
||||||
@ -328,10 +329,10 @@ public class ProcessDefinitionServiceTest {
|
|||||||
, Mockito.eq(project.getCode())
|
, Mockito.eq(project.getCode())
|
||||||
, Mockito.anyBoolean())).thenReturn(page);
|
, Mockito.anyBoolean())).thenReturn(page);
|
||||||
|
|
||||||
Map<String, Object> map1 = processDefinitionService.queryProcessDefinitionListPaging(
|
Result map1 = processDefinitionService.queryProcessDefinitionListPaging(
|
||||||
loginUser, projectName, "", 1, 10, loginUser.getId());
|
loginUser, projectName, "", 1, 10, loginUser.getId());
|
||||||
|
|
||||||
Assert.assertEquals(Status.SUCCESS, map1.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getMsg(), map1.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -124,10 +124,10 @@ public class ProcessInstanceServiceTest {
|
|||||||
//project auth fail
|
//project auth fail
|
||||||
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
||||||
when(projectService.checkProjectAndAuth(loginUser, null, projectName)).thenReturn(result);
|
when(projectService.checkProjectAndAuth(loginUser, null, projectName)).thenReturn(result);
|
||||||
Map<String, Object> proejctAuthFailRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 46, "2020-01-01 00:00:00",
|
Result proejctAuthFailRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 46, "2020-01-01 00:00:00",
|
||||||
"2020-01-02 00:00:00", "", "test_user", ExecutionStatus.SUBMITTED_SUCCESS,
|
"2020-01-02 00:00:00", "", "test_user", ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(),(int) proejctAuthFailRes.getCode());
|
||||||
|
|
||||||
Date start = DateUtils.getScheduleDate("2020-01-01 00:00:00");
|
Date start = DateUtils.getScheduleDate("2020-01-01 00:00:00");
|
||||||
Date end = DateUtils.getScheduleDate("2020-01-02 00:00:00");
|
Date end = DateUtils.getScheduleDate("2020-01-02 00:00:00");
|
||||||
@ -147,10 +147,10 @@ public class ProcessInstanceServiceTest {
|
|||||||
, Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
|
, Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
|
||||||
eq("192.168.xx.xx"), Mockito.any(), Mockito.any())).thenReturn(pageReturn);
|
eq("192.168.xx.xx"), Mockito.any(), Mockito.any())).thenReturn(pageReturn);
|
||||||
|
|
||||||
Map<String, Object> dataParameterRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "20200101 00:00:00",
|
Result dataParameterRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "20200101 00:00:00",
|
||||||
"20200102 00:00:00", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
"20200102 00:00:00", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, dataParameterRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(),(int) dataParameterRes.getCode());
|
||||||
|
|
||||||
//project auth success
|
//project auth success
|
||||||
putMsg(result, Status.SUCCESS, projectName);
|
putMsg(result, Status.SUCCESS, projectName);
|
||||||
@ -162,10 +162,10 @@ public class ProcessInstanceServiceTest {
|
|||||||
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(-1), Mockito.any(),
|
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(-1), Mockito.any(),
|
||||||
eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
||||||
when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser);
|
when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser);
|
||||||
Map<String, Object> successRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
Result successRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
||||||
"2020-01-02 00:00:00", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
"2020-01-02 00:00:00", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)successRes.getCode());
|
||||||
|
|
||||||
// data parameter empty
|
// data parameter empty
|
||||||
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(-1), Mockito.any(),
|
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(-1), Mockito.any(),
|
||||||
@ -173,23 +173,23 @@ public class ProcessInstanceServiceTest {
|
|||||||
successRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "",
|
successRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "",
|
||||||
"", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
"", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)successRes.getCode());
|
||||||
|
|
||||||
//executor null
|
//executor null
|
||||||
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
||||||
when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(-1);
|
when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(-1);
|
||||||
Map<String, Object> executorExistRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
Result executorExistRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
||||||
"2020-01-02 00:00:00", "", "admin", ExecutionStatus.SUBMITTED_SUCCESS,
|
"2020-01-02 00:00:00", "", "admin", ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.SUCCESS, executorExistRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)executorExistRes.getCode());
|
||||||
|
|
||||||
//executor name empty
|
//executor name empty
|
||||||
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(0), Mockito.any(),
|
when(processInstanceMapper.queryProcessInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1L), eq(""), eq(0), Mockito.any(),
|
||||||
eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
||||||
Map<String, Object> executorEmptyRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
Result executorEmptyRes = processInstanceService.queryProcessInstanceList(loginUser, projectName, 1, "2020-01-01 00:00:00",
|
||||||
"2020-01-02 00:00:00", "", "", ExecutionStatus.SUBMITTED_SUCCESS,
|
"2020-01-02 00:00:00", "", "", ExecutionStatus.SUBMITTED_SUCCESS,
|
||||||
"192.168.xx.xx", 1, 10);
|
"192.168.xx.xx", 1, 10);
|
||||||
Assert.assertEquals(Status.SUCCESS, executorEmptyRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)executorEmptyRes.getCode());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
||||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||||
@ -190,18 +191,18 @@ public class ProjectServiceTest {
|
|||||||
User loginUser = getLoginUser();
|
User loginUser = getLoginUser();
|
||||||
|
|
||||||
// project owner
|
// project owner
|
||||||
Map<String, Object> result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
Result result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
PageInfo<Project> pageInfo = (PageInfo<Project>) result.get(Constants.DATA_LIST);
|
PageInfo<Project> pageInfo = (PageInfo<Project>) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
|
|
||||||
//admin
|
//admin
|
||||||
Mockito.when(projectMapper.queryProjectListPaging(Mockito.any(Page.class), Mockito.eq(0), Mockito.eq(projectName))).thenReturn(page);
|
Mockito.when(projectMapper.queryProjectListPaging(Mockito.any(Page.class), Mockito.eq(0), Mockito.eq(projectName))).thenReturn(page);
|
||||||
loginUser.setUserType(UserType.ADMIN_USER);
|
loginUser.setUserType(UserType.ADMIN_USER);
|
||||||
result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
pageInfo = (PageInfo<Project>) result.get(Constants.DATA_LIST);
|
pageInfo = (PageInfo<Project>) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -402,7 +403,6 @@ public class ProjectServiceTest {
|
|||||||
return Collections.singletonList(1);
|
return Collections.singletonList(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getDesc() {
|
private String getDesc() {
|
||||||
return "projectUserMapper.deleteProjectRelation(projectId,userId)projectUserMappe"
|
return "projectUserMapper.deleteProjectRelation(projectId,userId)projectUserMappe"
|
||||||
+ ".deleteProjectRelation(projectId,userId)projectUserMappe"
|
+ ".deleteProjectRelation(projectId,userId)projectUserMappe"
|
||||||
|
@ -85,6 +85,7 @@ public class QueueServiceTest {
|
|||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(queueList));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(queueList));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryListPage() {
|
public void testQueryListPage() {
|
||||||
|
|
||||||
@ -92,11 +93,12 @@ public class QueueServiceTest {
|
|||||||
page.setTotal(1L);
|
page.setTotal(1L);
|
||||||
page.setRecords(getQueueList());
|
page.setRecords(getQueueList());
|
||||||
Mockito.when(queueMapper.queryQueuePaging(Mockito.any(Page.class), Mockito.eq(queueName))).thenReturn(page);
|
Mockito.when(queueMapper.queryQueuePaging(Mockito.any(Page.class), Mockito.eq(queueName))).thenReturn(page);
|
||||||
Map<String, Object> result = queueService.queryList(getLoginUser(),queueName,1,10);
|
Result result = queueService.queryList(getLoginUser(),queueName,1,10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.get(Constants.DATA_LIST);
|
PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateQueue() {
|
public void testCreateQueue() {
|
||||||
|
|
||||||
@ -196,7 +198,6 @@ public class QueueServiceTest {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get queue
|
* get queue
|
||||||
* @return
|
* @return
|
||||||
|
@ -269,11 +269,11 @@ public class ResourcesServiceTest {
|
|||||||
|
|
||||||
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class),
|
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class),
|
||||||
Mockito.eq(0), Mockito.eq(-1), Mockito.eq(0), Mockito.eq("test"), Mockito.any())).thenReturn(resourcePage);
|
Mockito.eq(0), Mockito.eq(-1), Mockito.eq(0), Mockito.eq("test"), Mockito.any())).thenReturn(resourcePage);
|
||||||
Map<String, Object> result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10);
|
Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)result.getCode());
|
||||||
PageInfo pageInfo = (PageInfo) result.get(Constants.DATA_LIST);
|
PageInfo pageInfo = (PageInfo) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class SessionServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private SessionMapper sessionMapper;
|
private SessionMapper sessionMapper;
|
||||||
|
|
||||||
private String sessionId ="aaaaaaaaaaaaaaaaaa";
|
private String sessionId = "aaaaaaaaaaaaaaaaaa";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@ -73,8 +73,7 @@ public class SessionServiceTest {
|
|||||||
* create session
|
* create session
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetSession(){
|
public void testGetSession() {
|
||||||
|
|
||||||
|
|
||||||
Mockito.when(sessionMapper.selectById(sessionId)).thenReturn(getSession());
|
Mockito.when(sessionMapper.selectById(sessionId)).thenReturn(getSession());
|
||||||
// get sessionId from header
|
// get sessionId from header
|
||||||
@ -96,32 +95,29 @@ public class SessionServiceTest {
|
|||||||
Assert.assertNotNull(session);
|
Assert.assertNotNull(session);
|
||||||
logger.info("session ip {}",session.getIp());
|
logger.info("session ip {}",session.getIp());
|
||||||
Assert.assertEquals(session.getIp(),"127.0.0.1");
|
Assert.assertEquals(session.getIp(),"127.0.0.1");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create session
|
* create session
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSession(){
|
public void testCreateSession() {
|
||||||
|
|
||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUserType(UserType.GENERAL_USER);
|
user.setUserType(UserType.GENERAL_USER);
|
||||||
user.setId(1);
|
user.setId(1);
|
||||||
Mockito.when(sessionMapper.queryByUserId(1)).thenReturn(getSessions());
|
Mockito.when(sessionMapper.queryByUserId(1)).thenReturn(getSessions());
|
||||||
String sessionId = sessionService.createSession(user, ip);
|
String sessionId = sessionService.createSession(user, ip);
|
||||||
logger.info("createSessionId is "+sessionId);
|
logger.info("createSessionId is " + sessionId);
|
||||||
Assert.assertTrue(StringUtils.isNotEmpty(sessionId));
|
Assert.assertTrue(StringUtils.isNotEmpty(sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sign out
|
* sign out
|
||||||
* remove ip restrictions
|
* remove ip restrictions
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSignOut(){
|
public void testSignOut() {
|
||||||
|
|
||||||
int userId = 88888888;
|
int userId = 88888888;
|
||||||
String ip = "127.0.0.1";
|
String ip = "127.0.0.1";
|
||||||
User user = new User();
|
User user = new User();
|
||||||
@ -129,12 +125,11 @@ public class SessionServiceTest {
|
|||||||
|
|
||||||
Mockito.when(sessionMapper.queryByUserIdAndIp(userId,ip)).thenReturn(getSession());
|
Mockito.when(sessionMapper.queryByUserIdAndIp(userId,ip)).thenReturn(getSession());
|
||||||
|
|
||||||
sessionService.signOut(ip ,user);
|
sessionService.signOut(ip,user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Session getSession(){
|
private Session getSession() {
|
||||||
|
|
||||||
Session session = new Session();
|
Session session = new Session();
|
||||||
session.setId(sessionId);
|
session.setId(sessionId);
|
||||||
session.setIp("127.0.0.1");
|
session.setIp("127.0.0.1");
|
||||||
@ -143,11 +138,9 @@ public class SessionServiceTest {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Session> getSessions(){
|
private List<Session> getSessions() {
|
||||||
List<Session> sessionList = new ArrayList<>();
|
List<Session> sessionList = new ArrayList<>();
|
||||||
sessionList.add(getSession());
|
sessionList.add(getSession());
|
||||||
return sessionList;
|
return sessionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
|||||||
import org.apache.dolphinscheduler.api.enums.Status;
|
import org.apache.dolphinscheduler.api.enums.Status;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
||||||
import org.apache.dolphinscheduler.api.service.impl.TaskInstanceServiceImpl;
|
import org.apache.dolphinscheduler.api.service.impl.TaskInstanceServiceImpl;
|
||||||
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.Constants;
|
import org.apache.dolphinscheduler.common.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
@ -90,18 +91,18 @@ public class TaskInstanceServiceTest {
|
|||||||
//project auth fail
|
//project auth fail
|
||||||
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
||||||
when(projectService.checkProjectAndAuth(loginUser, null, projectName)).thenReturn(result);
|
when(projectService.checkProjectAndAuth(loginUser, null, projectName)).thenReturn(result);
|
||||||
Map<String, Object> proejctAuthFailRes = taskInstanceService.queryTaskListPaging(loginUser, "project_test1", 0, "", "",
|
Result proejctAuthFailRes = taskInstanceService.queryTaskListPaging(loginUser, "project_test1", 0, "", "",
|
||||||
"test_user", "2019-02-26 19:48:00", "2019-02-26 19:48:22", "", null, "", 1, 20);
|
"test_user", "2019-02-26 19:48:00", "2019-02-26 19:48:22", "", null, "", 1, 20);
|
||||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int)proejctAuthFailRes.getCode());
|
||||||
|
|
||||||
// data parameter check
|
// data parameter check
|
||||||
putMsg(result, Status.SUCCESS, projectName);
|
putMsg(result, Status.SUCCESS, projectName);
|
||||||
Project project = getProject(projectName);
|
Project project = getProject(projectName);
|
||||||
when(projectMapper.queryByName(Mockito.anyString())).thenReturn(project);
|
when(projectMapper.queryByName(Mockito.anyString())).thenReturn(project);
|
||||||
when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
|
when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
|
||||||
Map<String, Object> dataParameterRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result dataParameterRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"test_user", "20200101 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"test_user", "20200101 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, dataParameterRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int)dataParameterRes.getCode());
|
||||||
|
|
||||||
//project
|
//project
|
||||||
putMsg(result, Status.SUCCESS, projectName);
|
putMsg(result, Status.SUCCESS, projectName);
|
||||||
@ -122,40 +123,41 @@ public class TaskInstanceServiceTest {
|
|||||||
when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser);
|
when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser);
|
||||||
when(processService.findProcessInstanceDetailById(taskInstance.getProcessInstanceId())).thenReturn(processInstance);
|
when(processService.findProcessInstanceDetailById(taskInstance.getProcessInstanceId())).thenReturn(processInstance);
|
||||||
|
|
||||||
Map<String, Object> successRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
|
||||||
|
Result successRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)successRes.getCode());
|
||||||
|
|
||||||
//executor name empty
|
//executor name empty
|
||||||
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
||||||
eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
eq(0), Mockito.any(), eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
||||||
Map<String, Object> executorEmptyRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result executorEmptyRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.SUCCESS, executorEmptyRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int)executorEmptyRes.getCode());
|
||||||
|
|
||||||
//executor null
|
//executor null
|
||||||
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
||||||
when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(-1);
|
when(usersService.getUserIdByName(loginUser.getUserName())).thenReturn(-1);
|
||||||
Map<String, Object> executorNullRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result executorNullRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"test_user", "2020-01-01 00:00:00", "2020-01-02 00:00:00", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.SUCCESS, executorNullRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(),(int)executorNullRes.getCode());
|
||||||
|
|
||||||
//start/end date null
|
//start/end date null
|
||||||
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
||||||
eq(0), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(pageReturn);
|
eq(0), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(pageReturn);
|
||||||
Map<String, Object> executorNullDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result executorNullDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"", null, null, "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"", null, null, "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.SUCCESS, executorNullDateRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(),(int) executorNullDateRes.getCode());
|
||||||
|
|
||||||
//start date error format
|
//start date error format
|
||||||
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
when(taskInstanceMapper.queryTaskInstanceListPaging(Mockito.any(Page.class), eq(project.getCode()), eq(1), eq(""), eq(""), eq(""),
|
||||||
eq(0), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(pageReturn);
|
eq(0), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(pageReturn);
|
||||||
Map<String, Object> executorErrorStartDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result executorErrorStartDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"", "error date", null, "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"", "error date", null, "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, executorErrorStartDateRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int)executorErrorStartDateRes.getCode());
|
||||||
Map<String, Object> executorErrorEndDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
Result executorErrorEndDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||||
"", null, "error date", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
"", null, "error date", "", ExecutionStatus.SUCCESS, "192.168.xx.xx", 1, 20);
|
||||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, executorErrorEndDateRes.get(Constants.STATUS));
|
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int)executorErrorEndDateRes.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,10 +112,10 @@ public class TenantServiceTest {
|
|||||||
page.setTotal(1L);
|
page.setTotal(1L);
|
||||||
Mockito.when(tenantMapper.queryTenantPaging(Mockito.any(Page.class), Mockito.eq("TenantServiceTest")))
|
Mockito.when(tenantMapper.queryTenantPaging(Mockito.any(Page.class), Mockito.eq("TenantServiceTest")))
|
||||||
.thenReturn(page);
|
.thenReturn(page);
|
||||||
Map<String, Object> result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10);
|
Result result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.get(Constants.DATA_LIST);
|
PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,27 +81,30 @@ public class UdfFuncServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUdfFunction(){
|
public void testCreateUdfFunction() {
|
||||||
|
|
||||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
||||||
//hdfs not start
|
//hdfs not start
|
||||||
Result result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
|
Result result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
|
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
|
||||||
//resource not exist
|
//resource not exist
|
||||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
|
||||||
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
|
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
|
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
|
||||||
// success
|
// success
|
||||||
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
|
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
|
||||||
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryUdfFuncDetail(){
|
public void testQueryUdfFuncDetail() {
|
||||||
|
|
||||||
PowerMockito.when(udfFuncMapper.selectById(1)).thenReturn(getUdfFunc());
|
PowerMockito.when(udfFuncMapper.selectById(1)).thenReturn(getUdfFunc());
|
||||||
//resource not exist
|
//resource not exist
|
||||||
@ -115,51 +118,55 @@ public class UdfFuncServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateUdfFunc(){
|
public void testUpdateUdfFunc() {
|
||||||
|
|
||||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
||||||
PowerMockito.when(udfFuncMapper.selectUdfById(1)).thenReturn(getUdfFunc());
|
PowerMockito.when(udfFuncMapper.selectUdfById(1)).thenReturn(getUdfFunc());
|
||||||
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
|
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
|
||||||
|
|
||||||
//UDF_FUNCTION_NOT_EXIST
|
//UDF_FUNCTION_NOT_EXIST
|
||||||
Map<String, Object> result = udfFuncService.updateUdfFunc(12, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
Map<String, Object> result = udfFuncService.updateUdfFunc(12, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.UDF_FUNCTION_NOT_EXIST,result.get(Constants.STATUS));
|
Assert.assertEquals(Status.UDF_FUNCTION_NOT_EXIST,result.get(Constants.STATUS));
|
||||||
|
|
||||||
//HDFS_NOT_STARTUP
|
//HDFS_NOT_STARTUP
|
||||||
result = udfFuncService.updateUdfFunc(1, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
result = udfFuncService.updateUdfFunc(1, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.HDFS_NOT_STARTUP,result.get(Constants.STATUS));
|
Assert.assertEquals(Status.HDFS_NOT_STARTUP,result.get(Constants.STATUS));
|
||||||
|
|
||||||
//RESOURCE_NOT_EXIST
|
//RESOURCE_NOT_EXIST
|
||||||
PowerMockito.when(udfFuncMapper.selectUdfById(11)).thenReturn(getUdfFunc());
|
PowerMockito.when(udfFuncMapper.selectUdfById(11)).thenReturn(getUdfFunc());
|
||||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
|
||||||
result = udfFuncService.updateUdfFunc(11, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 12);
|
result = udfFuncService.updateUdfFunc(11, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 12);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.RESOURCE_NOT_EXIST,result.get(Constants.STATUS));
|
Assert.assertEquals(Status.RESOURCE_NOT_EXIST,result.get(Constants.STATUS));
|
||||||
|
|
||||||
//success
|
//success
|
||||||
result = udfFuncService.updateUdfFunc(11, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String", "UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
result = udfFuncService.updateUdfFunc(11, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
|
||||||
|
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryUdfFuncListPaging(){
|
public void testQueryUdfFuncListPaging() {
|
||||||
|
|
||||||
IPage<UdfFunc> page = new Page<>(1,10);
|
IPage<UdfFunc> page = new Page<>(1,10);
|
||||||
page.setTotal(1L);
|
page.setTotal(1L);
|
||||||
page.setRecords(getList());
|
page.setRecords(getList());
|
||||||
Mockito.when(udfFuncMapper.queryUdfFuncPaging(Mockito.any(Page.class), Mockito.eq(0),Mockito.eq("test"))).thenReturn(page);
|
Mockito.when(udfFuncMapper.queryUdfFuncPaging(Mockito.any(Page.class), Mockito.eq(0),Mockito.eq("test"))).thenReturn(page);
|
||||||
Map<String, Object> result = udfFuncService.queryUdfFuncListPaging(getLoginUser(),"test",1,10);
|
Result result = udfFuncService.queryUdfFuncListPaging(getLoginUser(),"test",1,10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
PageInfo pageInfo = (PageInfo) result.get(Constants.DATA_LIST);
|
PageInfo pageInfo = (PageInfo) result.getData();
|
||||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueryUdfFuncList(){
|
public void testQueryUdfFuncList() {
|
||||||
User user = getLoginUser();
|
User user = getLoginUser();
|
||||||
user.setUserType(UserType.GENERAL_USER);
|
user.setUserType(UserType.GENERAL_USER);
|
||||||
Mockito.when(udfFuncMapper.getUdfFuncByType(user.getId(), UdfType.HIVE.ordinal())).thenReturn(getList());
|
Mockito.when(udfFuncMapper.getUdfFuncByType(user.getId(), UdfType.HIVE.ordinal())).thenReturn(getList());
|
||||||
@ -171,16 +178,16 @@ public class UdfFuncServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete(){
|
public void testDelete() {
|
||||||
Mockito.when(udfFuncMapper.deleteById(Mockito.anyInt())).thenReturn(1);
|
Mockito.when(udfFuncMapper.deleteById(Mockito.anyInt())).thenReturn(1);
|
||||||
Mockito.when(udfUserMapper.deleteByUdfFuncId(Mockito.anyInt())).thenReturn(1);
|
Mockito.when(udfUserMapper.deleteByUdfFuncId(Mockito.anyInt())).thenReturn(1);
|
||||||
Result result= udfFuncService.delete(122);
|
Result result = udfFuncService.delete(122);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVerifyUdfFuncByName(){
|
public void testVerifyUdfFuncByName() {
|
||||||
|
|
||||||
//success
|
//success
|
||||||
Mockito.when(udfFuncMapper.queryUdfByIdStr(null, "UdfFuncServiceTest")).thenReturn(getList());
|
Mockito.when(udfFuncMapper.queryUdfByIdStr(null, "UdfFuncServiceTest")).thenReturn(getList());
|
||||||
@ -197,7 +204,7 @@ public class UdfFuncServiceTest {
|
|||||||
* create admin user
|
* create admin user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private User getLoginUser(){
|
private User getLoginUser() {
|
||||||
|
|
||||||
User loginUser = new User();
|
User loginUser = new User();
|
||||||
loginUser.setUserType(UserType.ADMIN_USER);
|
loginUser.setUserType(UserType.ADMIN_USER);
|
||||||
@ -208,7 +215,7 @@ public class UdfFuncServiceTest {
|
|||||||
/**
|
/**
|
||||||
* get resourceId
|
* get resourceId
|
||||||
*/
|
*/
|
||||||
private Resource getResource(){
|
private Resource getResource() {
|
||||||
|
|
||||||
Resource resource = new Resource();
|
Resource resource = new Resource();
|
||||||
resource.setId(1);
|
resource.setId(1);
|
||||||
@ -216,16 +223,16 @@ public class UdfFuncServiceTest {
|
|||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<UdfFunc> getList() {
|
||||||
private List<UdfFunc> getList(){
|
|
||||||
List<UdfFunc> udfFuncList = new ArrayList<>();
|
List<UdfFunc> udfFuncList = new ArrayList<>();
|
||||||
udfFuncList.add(getUdfFunc());
|
udfFuncList.add(getUdfFunc());
|
||||||
return udfFuncList;
|
return udfFuncList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get UdfFunc id
|
* get UdfFunc id
|
||||||
*/
|
*/
|
||||||
private UdfFunc getUdfFunc(){
|
private UdfFunc getUdfFunc() {
|
||||||
UdfFunc udfFunc = new UdfFunc();
|
UdfFunc udfFunc = new UdfFunc();
|
||||||
udfFunc.setFuncName("UdfFuncServiceTest");
|
udfFunc.setFuncName("UdfFuncServiceTest");
|
||||||
udfFunc.setClassName("org.apache.dolphinscheduler.api.service.UdfFuncServiceTest");
|
udfFunc.setClassName("org.apache.dolphinscheduler.api.service.UdfFuncServiceTest");
|
||||||
|
@ -250,16 +250,16 @@ public class UsersServiceTest {
|
|||||||
when(userMapper.queryUserPaging(any(Page.class), eq("userTest"))).thenReturn(page);
|
when(userMapper.queryUserPaging(any(Page.class), eq("userTest"))).thenReturn(page);
|
||||||
|
|
||||||
//no operate
|
//no operate
|
||||||
Map<String, Object> result = usersService.queryUserList(user, "userTest", 1, 10);
|
Result result = usersService.queryUserList(user, "userTest", 1, 10);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getCode(), (int) result.getCode());
|
||||||
|
|
||||||
//success
|
//success
|
||||||
user.setUserType(UserType.ADMIN_USER);
|
user.setUserType(UserType.ADMIN_USER);
|
||||||
result = usersService.queryUserList(user, "userTest", 1, 10);
|
result = usersService.queryUserList(user, "userTest", 1, 10);
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
|
||||||
PageInfo<User> pageInfo = (PageInfo<User>) result.get(Constants.DATA_LIST);
|
PageInfo<User> pageInfo = (PageInfo<User>) result.getData();
|
||||||
Assert.assertTrue(pageInfo.getLists().size() > 0);
|
Assert.assertTrue(pageInfo.getTotalList().size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.common.utils;
|
||||||
|
|
||||||
|
public class ArrayUtils {
|
||||||
|
|
||||||
|
public static byte[] clone(byte[] array) {
|
||||||
|
return array == null ? null : (byte[])((byte[])array.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] addAll(byte[] array1, byte[] array2) {
|
||||||
|
if (array1 == null) {
|
||||||
|
return clone(array2);
|
||||||
|
} else if (array2 == null) {
|
||||||
|
return clone(array1);
|
||||||
|
} else {
|
||||||
|
byte[] joinedArray = new byte[array1.length + array2.length];
|
||||||
|
System.arraycopy(array1, 0, joinedArray, 0, array1.length);
|
||||||
|
System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);
|
||||||
|
return joinedArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -759,8 +759,8 @@
|
|||||||
pageSize: pageSize,
|
pageSize: pageSize,
|
||||||
processDefinitionCode: processDefinitionCode
|
processDefinitionCode: processDefinitionCode
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.versionData.processDefinitionVersions = res.data.lists
|
this.versionData.processDefinitionVersions = res.data.totalList
|
||||||
this.versionData.total = res.data.totalCount
|
this.versionData.total = res.data.total
|
||||||
this.versionData.pageSize = res.data.pageSize
|
this.versionData.pageSize = res.data.pageSize
|
||||||
this.versionData.pageNo = res.data.currentPage
|
this.versionData.pageNo = res.data.currentPage
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
@ -800,8 +800,8 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
processDefinitionCode: this.store.state.dag.code
|
processDefinitionCode: this.store.state.dag.code
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
let processDefinitionVersions = res.data.lists
|
let processDefinitionVersions = res.data.totalList
|
||||||
let total = res.data.totalCount
|
let total = res.data.total
|
||||||
let pageSize = res.data.pageSize
|
let pageSize = res.data.pageSize
|
||||||
let pageNo = res.data.currentPage
|
let pageNo = res.data.currentPage
|
||||||
this.versionData.processDefinition.id = this.urlParam.id
|
this.versionData.processDefinition.id = this.urlParam.id
|
||||||
|
@ -362,8 +362,8 @@
|
|||||||
pageSize: pageSize,
|
pageSize: pageSize,
|
||||||
processDefinitionCode: processDefinitionCode
|
processDefinitionCode: processDefinitionCode
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.versionData.processDefinitionVersions = res.data.lists
|
this.versionData.processDefinitionVersions = res.data.totalList
|
||||||
this.versionData.total = res.data.totalCount
|
this.versionData.total = res.data.total
|
||||||
this.versionData.pageSize = res.data.pageSize
|
this.versionData.pageSize = res.data.pageSize
|
||||||
this.versionData.pageNo = res.data.currentPage
|
this.versionData.pageNo = res.data.currentPage
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
@ -399,8 +399,8 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
processDefinitionCode: item.code
|
processDefinitionCode: item.code
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
let processDefinitionVersions = res.data.lists
|
let processDefinitionVersions = res.data.totalList
|
||||||
let total = res.data.totalCount
|
let total = res.data.total
|
||||||
let pageSize = res.data.pageSize
|
let pageSize = res.data.pageSize
|
||||||
let pageNo = res.data.currentPage
|
let pageNo = res.data.currentPage
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user