mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-04 21:28:00 +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 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.service.AccessTokenService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
@ -128,13 +127,13 @@ public class AccessTokenController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = alertGroupService.listPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
return returnDataListPaging(result);
|
||||
return alertGroupService.listPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,13 +226,11 @@ public class AlertPluginInstanceController extends BaseController {
|
||||
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
|
||||
return returnDataListPaging(result);
|
||||
return alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 org.apache.dolphinscheduler.api.enums.Status;
|
||||
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.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.Resource;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
@ -47,8 +45,8 @@ public class BaseController {
|
||||
* @param pageSize page size
|
||||
* @return check result code
|
||||
*/
|
||||
public Map<String, Object> checkPageParams(int pageNo, int pageSize) {
|
||||
Map<String, Object> result = new HashMap<>(4);
|
||||
public Result checkPageParams(int pageNo, int pageSize) {
|
||||
Result result = new Result();
|
||||
Status resultEnum = Status.SUCCESS;
|
||||
String msg = Status.SUCCESS.getMsg();
|
||||
if (pageNo <= 0) {
|
||||
@ -58,8 +56,8 @@ public class BaseController {
|
||||
resultEnum = Status.REQUEST_PARAMS_NOT_VALID_ERROR;
|
||||
msg = MessageFormat.format(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getMsg(), Constants.PAGE_SIZE);
|
||||
}
|
||||
result.put(Constants.STATUS, resultEnum);
|
||||
result.put(Constants.MSG, msg);
|
||||
result.setCode(resultEnum.getCode());
|
||||
result.setMsg(msg);
|
||||
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
|
||||
*
|
||||
|
@ -186,6 +186,4 @@ public class DataAnalysisController extends BaseController {
|
||||
Map<String, Object> result = dataAnalysisService.countQueueState(loginUser, projectId);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -179,13 +179,12 @@ public class DataSourceController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
return returnDataListPaging(result);
|
||||
return dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,10 +278,14 @@ public class ProcessDefinitionController extends BaseController {
|
||||
@RequestParam(value = "pageNo") int pageNo,
|
||||
@RequestParam(value = "pageSize") int pageSize,
|
||||
@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);
|
||||
|
||||
return returnDataList(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -460,13 +464,13 @@ public class ProcessDefinitionController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam(value = "userId", required = false, defaultValue = "0") Integer userId,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectName, searchVal, pageNo, pageSize, userId);
|
||||
return returnDataListPaging(result);
|
||||
return processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectName, searchVal, pageNo, pageSize, userId);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,14 +125,14 @@ public class ProcessInstanceController extends BaseController {
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = processInstanceService.queryProcessInstanceList(
|
||||
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
|
||||
|
||||
) {
|
||||
projectName=ParameterUtils.handleEscapes(projectName);
|
||||
Map<String,Object> result=processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectName, size, startTime, endTime);
|
||||
projectName = ParameterUtils.handleEscapes(projectName);
|
||||
Map<String,Object> result = processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectName, size, startTime, endTime);
|
||||
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 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.service.ProcessDefinitionService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
@ -171,13 +170,13 @@ public class ProjectController extends BaseController {
|
||||
@RequestParam("pageNo") Integer pageNo
|
||||
) {
|
||||
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(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();
|
||||
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 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.service.QueueService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
@ -100,14 +99,14 @@ public class QueueController extends BaseController {
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class ResourcesController extends BaseController {
|
||||
@RequestParam(value = "type") ResourceType type,
|
||||
@RequestParam(value = "name") String alias,
|
||||
@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);
|
||||
}
|
||||
|
||||
@ -240,14 +240,14 @@ public class ResourcesController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageSize") Integer pageSize
|
||||
) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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("pageSize") Integer pageSize
|
||||
) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
}
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
|
||||
}
|
||||
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 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.service.SchedulerService;
|
||||
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.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
@ -240,14 +238,13 @@ public class SchedulerController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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 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.service.TaskInstanceService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
@ -109,16 +108,14 @@ public class TaskInstanceController extends BaseController {
|
||||
@RequestParam(value = "endDate", required = false) String endTime,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
|
||||
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = taskInstanceService.queryTaskListPaging(
|
||||
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 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.service.TenantService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
@ -114,13 +113,14 @@ public class TenantController extends BaseController {
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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("pageSize") Integer pageSize,
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
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 email user email
|
||||
*/
|
||||
@ApiOperation(value="registerUser",notes = "REGISTER_USER_NOTES")
|
||||
@ApiOperation(value = "registerUser",notes = "REGISTER_USER_NOTES")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "userName", value = "USER_NAME", 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
|
||||
*/
|
||||
@ApiOperation(value="activateUser",notes = "ACTIVATE_USER_NOTES")
|
||||
@ApiOperation(value = "activateUser",notes = "ACTIVATE_USER_NOTES")
|
||||
@ApiImplicitParams({
|
||||
@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 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.service.WorkerGroupService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
@ -112,13 +111,14 @@ public class WorkerGroupController extends BaseController {
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam(value = "searchVal", required = false) String searchVal
|
||||
) {
|
||||
Map<String, Object> result = checkPageParams(pageNo, pageSize);
|
||||
if (result.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return returnDataListPaging(result);
|
||||
Result result = checkPageParams(pageNo, pageSize);
|
||||
if (!result.checkResult()) {
|
||||
return result;
|
||||
|
||||
}
|
||||
searchVal = ParameterUtils.handleEscapes(searchVal);
|
||||
result = workerGroupService.queryAllGroupPaging(loginUser, pageNo, pageSize, searchVal);
|
||||
return returnDataListPaging(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
@ -35,7 +36,7 @@ public interface AccessTokenService {
|
||||
* @param pageSize 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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
@ -42,7 +43,7 @@ public interface AlertGroupService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
@ -85,5 +86,5 @@ public interface AlertPluginInstanceService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
* @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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
import org.apache.dolphinscheduler.dao.entity.ProcessData;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
@ -76,12 +77,12 @@ public interface ProcessDefinitionService {
|
||||
* @param userId user id
|
||||
* @return process definition page
|
||||
*/
|
||||
Map<String, Object> queryProcessDefinitionListPaging(User loginUser,
|
||||
String projectName,
|
||||
String searchVal,
|
||||
Integer pageNo,
|
||||
Integer pageSize,
|
||||
Integer userId);
|
||||
Result queryProcessDefinitionListPaging(User loginUser,
|
||||
String projectName,
|
||||
String searchVal,
|
||||
Integer pageNo,
|
||||
Integer pageSize,
|
||||
Integer userId);
|
||||
|
||||
/**
|
||||
* query datail of process definition
|
||||
@ -285,7 +286,7 @@ public interface ProcessDefinitionService {
|
||||
* @param processDefinitionCode process definition code
|
||||
* @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);
|
||||
|
||||
/**
|
||||
@ -299,6 +300,7 @@ public interface ProcessDefinitionService {
|
||||
*/
|
||||
Map<String, Object> deleteByProcessDefinitionIdAndVersion(User loginUser, String projectName,
|
||||
int processDefinitionId, long version);
|
||||
|
||||
/**
|
||||
* check has associated process definition
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
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.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.enums.Flag;
|
||||
@ -65,10 +66,10 @@ public interface ProcessInstanceService {
|
||||
* @param endDate end time
|
||||
* @return process instance list
|
||||
*/
|
||||
Map<String, Object> queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
||||
String startDate, String endDate,
|
||||
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize);
|
||||
Result queryProcessInstanceList(User loginUser, String projectName, Integer processDefineId,
|
||||
String startDate, String endDate,
|
||||
String searchVal, String executorName, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* query task list by process instance id
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
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.User;
|
||||
|
||||
@ -57,6 +58,8 @@ public interface ProjectService {
|
||||
|
||||
boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result);
|
||||
|
||||
boolean hasProjectAndPerm(User loginUser, Project project, Result result);
|
||||
|
||||
/**
|
||||
* admin can view all projects
|
||||
*
|
||||
@ -66,7 +69,7 @@ public interface ProjectService {
|
||||
* @param pageNo page number
|
||||
* @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
|
||||
|
@ -44,7 +44,7 @@ public interface QueueService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -97,7 +97,7 @@ public interface ResourcesService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
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.Priority;
|
||||
import org.apache.dolphinscheduler.common.enums.ReleaseState;
|
||||
@ -105,7 +106,7 @@ public interface SchedulerService {
|
||||
* @param searchVal search value
|
||||
* @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
|
||||
|
@ -27,29 +27,29 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*/
|
||||
public interface SessionService {
|
||||
|
||||
/**
|
||||
* get user session from request
|
||||
*
|
||||
* @param request request
|
||||
* @return session
|
||||
*/
|
||||
Session getSession(HttpServletRequest request);
|
||||
/**
|
||||
* get user session from request
|
||||
*
|
||||
* @param request request
|
||||
* @return session
|
||||
*/
|
||||
Session getSession(HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* create session
|
||||
*
|
||||
* @param user user
|
||||
* @param ip ip
|
||||
* @return session string
|
||||
*/
|
||||
String createSession(User user, String ip);
|
||||
/**
|
||||
* create session
|
||||
*
|
||||
* @param user user
|
||||
* @param ip ip
|
||||
* @return session string
|
||||
*/
|
||||
String createSession(User user, String ip);
|
||||
|
||||
/**
|
||||
* sign out
|
||||
* remove ip restrictions
|
||||
*
|
||||
* @param ip no use
|
||||
* @param loginUser login user
|
||||
*/
|
||||
void signOut(String ip, User loginUser);
|
||||
/**
|
||||
* sign out
|
||||
* remove ip restrictions
|
||||
*
|
||||
* @param ip no use
|
||||
* @param loginUser login user
|
||||
*/
|
||||
void signOut(String ip, User loginUser);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
@ -43,10 +44,10 @@ public interface TaskInstanceService {
|
||||
* @param pageSize page size
|
||||
* @return task list page
|
||||
*/
|
||||
Map<String, Object> queryTaskListPaging(User loginUser, String projectName,
|
||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize);
|
||||
Result queryTaskListPaging(User loginUser, String projectName,
|
||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* change one task instance's state from failure to forced success
|
||||
|
@ -51,7 +51,7 @@ public interface TenantService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -89,7 +89,7 @@ public interface UdfFuncService {
|
||||
* @param searchVal search value
|
||||
* @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
|
||||
|
@ -112,7 +112,7 @@ public interface UsersService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.dolphinscheduler.api.service;
|
||||
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.dao.entity.User;
|
||||
|
||||
import java.util.Map;
|
||||
@ -46,7 +47,7 @@ public interface WorkerGroupService {
|
||||
* @param pageSize page size
|
||||
* @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
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service.impl;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.AccessTokenService;
|
||||
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.enums.UserType;
|
||||
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
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
public Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
Page<AccessToken> page = new Page<>(pageNo, pageSize);
|
||||
int userId = loginUser.getId();
|
||||
@ -71,11 +71,10 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
||||
userId = 0;
|
||||
}
|
||||
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId);
|
||||
pageInfo.setTotalCount((int) accessTokenList.getTotal());
|
||||
pageInfo.setLists(accessTokenList.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) accessTokenList.getTotal());
|
||||
pageInfo.setTotalList(accessTokenList.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -87,11 +86,12 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
||||
* @param token token string
|
||||
* @return create result code
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:WhitespaceAround")
|
||||
@Override
|
||||
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (!hasPerm(loginUser,userId)){
|
||||
if (!hasPerm(loginUser,userId)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
||||
@Override
|
||||
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!hasPerm(loginUser,userId)){
|
||||
if (!hasPerm(loginUser,userId)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
@ -156,9 +156,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
||||
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
if (!hasPerm(loginUser,accessToken.getUserId())){
|
||||
if (!hasPerm(loginUser,accessToken.getUserId())) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
@ -180,7 +178,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
||||
@Override
|
||||
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!hasPerm(loginUser,userId)){
|
||||
if (!hasPerm(loginUser,userId)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
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.service.AlertGroupService;
|
||||
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.utils.BooleanUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
@ -79,10 +80,11 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
|
||||
* @return alert group list page
|
||||
*/
|
||||
@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<>();
|
||||
if (isNotAdmin(loginUser, result)) {
|
||||
Result result = new Result();
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -90,11 +92,10 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
|
||||
IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage(
|
||||
page, searchVal);
|
||||
PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) alertGroupIPage.getTotal());
|
||||
pageInfo.setLists(alertGroupIPage.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) alertGroupIPage.getTotal());
|
||||
pageInfo.setTotalList(alertGroupIPage.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
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.service.AlertPluginInstanceService;
|
||||
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.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
|
||||
@ -187,15 +188,15 @@ public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements A
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryPluginPage(int pageIndex, int pageSize) {
|
||||
public Result queryPluginPage(int pageIndex, int pageSize) {
|
||||
IPage<AlertPluginInstance> pluginInstanceIPage = new Page<>(pageIndex, pageSize);
|
||||
pluginInstanceIPage = alertPluginInstanceMapper.selectPage(pluginInstanceIPage, null);
|
||||
|
||||
PageInfo<AlertPluginInstanceVO> pageInfo = new PageInfo<>(pageIndex, pageSize);
|
||||
pageInfo.setTotalCount((int) pluginInstanceIPage.getTotal());
|
||||
pageInfo.setLists(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) pluginInstanceIPage.getTotal());
|
||||
pageInfo.setTotalList(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
|
||||
Result result = new Result();
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
@ -217,8 +217,8 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
||||
* @return data source list page
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
IPage<DataSource> dataSourceList;
|
||||
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<>();
|
||||
handlePasswd(dataSources);
|
||||
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
|
||||
pageInfo.setLists(dataSources);
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
|
||||
pageInfo.setTotalList(dataSources);
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
@ -308,7 +308,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
||||
* check connection
|
||||
*
|
||||
* @param type data source type
|
||||
* @param parameter data source parameters
|
||||
* @param connectionParam data source parameters
|
||||
* @return true if connect successfully, otherwise false
|
||||
*/
|
||||
@Override
|
||||
|
@ -22,14 +22,13 @@ import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
||||
import org.apache.dolphinscheduler.api.service.LoggerService;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.Constants;
|
||||
import org.apache.dolphinscheduler.common.utils.ArrayUtils;
|
||||
import org.apache.dolphinscheduler.common.utils.StringUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||
import org.apache.dolphinscheduler.remote.utils.Host;
|
||||
import org.apache.dolphinscheduler.service.log.LogClientService;
|
||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -17,12 +17,6 @@
|
||||
|
||||
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.service.MonitorService;
|
||||
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.User;
|
||||
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.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.FileUtils;
|
||||
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.enums.AuthorizationType;
|
||||
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.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
|
||||
/**
|
||||
* process definition service impl
|
||||
@ -267,15 +268,16 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
* @return process definition page
|
||||
*/
|
||||
@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);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||
if (resultStatus != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
putMsg(result,resultStatus);
|
||||
return result;
|
||||
}
|
||||
|
||||
Page<ProcessDefinition> page = new Page<>(pageNo, pageSize);
|
||||
@ -293,11 +295,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
}
|
||||
|
||||
processDefinitionIPage.setRecords(records);
|
||||
|
||||
PageInfo<ProcessDefinition> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) processDefinitionIPage.getTotal());
|
||||
pageInfo.setLists(records);
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) processDefinitionIPage.getTotal());
|
||||
pageInfo.setTotalList(processDefinitionIPage.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
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
|
||||
*/
|
||||
@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
|
||||
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);
|
||||
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
|
||||
if (resultStatus != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
putMsg(result,resultStatus);
|
||||
return result;
|
||||
}
|
||||
|
||||
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
|
||||
@ -1851,12 +1853,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
|
||||
|
||||
ProcessData processData = processService.genProcessData(processDefinition);
|
||||
processDefinition.setProcessDefinitionJson(JSONUtils.toJsonString(processData));
|
||||
pageInfo.setLists(processDefinitionLogs);
|
||||
pageInfo.setTotalCount((int) processDefinitionVersionsPaging.getTotal());
|
||||
return ImmutableMap.of(
|
||||
Constants.MSG, Status.SUCCESS.getMsg()
|
||||
, Constants.STATUS, Status.SUCCESS
|
||||
, Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotalList(processDefinitionLogs);
|
||||
pageInfo.setTotal((int) processDefinitionVersionsPaging.getTotal());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result,Status.SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,18 +235,19 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
||||
* @return process instance list
|
||||
*/
|
||||
@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 searchVal, String executorName, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Result result = new Result();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
|
||||
if (resultEnum != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
putMsg(result,resultEnum);
|
||||
return result;
|
||||
}
|
||||
|
||||
int[] statusArray = null;
|
||||
@ -256,8 +257,10 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
|
||||
}
|
||||
|
||||
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
||||
if (checkAndParseDateResult.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return checkAndParseDateResult;
|
||||
resultEnum = (Status) checkAndParseDateResult.get(Constants.STATUS);
|
||||
if (resultEnum != Status.SUCCESS) {
|
||||
putMsg(result,resultEnum);
|
||||
return result;
|
||||
}
|
||||
Date start = (Date) checkAndParseDateResult.get(Constants.START_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);
|
||||
|
||||
IPage<ProcessInstance> processInstanceList = processInstanceMapper.queryProcessInstanceListPaging(page,
|
||||
project.getCode(), processDefinition == null ? 0L : processDefinition.getCode(), searchVal,
|
||||
executorId, statusArray, host, start, end);
|
||||
project.getCode(), processDefinition == null ? 0L : processDefinition.getCode(), searchVal,
|
||||
executorId, statusArray, host, start, end);
|
||||
|
||||
List<ProcessInstance> processInstances = processInstanceList.getRecords();
|
||||
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.setLists(processInstances);
|
||||
result.put(DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) processInstanceList.getTotal());
|
||||
pageInfo.setTotalList(processInstances);
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
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.service.ProjectService;
|
||||
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.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
|
||||
@ -97,7 +98,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
||||
Date now = new Date();
|
||||
|
||||
try {
|
||||
project = Project
|
||||
project = Project
|
||||
.newBuilder()
|
||||
.name(name)
|
||||
.code(SnowFlakeUtils.getInstance().nextId())
|
||||
@ -177,6 +178,19 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
||||
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
|
||||
*
|
||||
@ -187,8 +201,8 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
||||
* @return project list which the login user have permission to see
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
public Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
|
||||
Result result = new Result();
|
||||
PageInfo<Project> pageInfo = new PageInfo<>(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);
|
||||
}
|
||||
}
|
||||
pageInfo.setTotalCount((int) projectIPage.getTotal());
|
||||
pageInfo.setLists(projectList);
|
||||
result.put(Constants.COUNT, (int) projectIPage.getTotal());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) projectIPage.getTotal());
|
||||
pageInfo.setTotalList(projectList);
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -86,9 +86,10 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
|
||||
* @return queue list
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (isNotAdmin(loginUser, result)) {
|
||||
public Result queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -98,9 +99,9 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
|
||||
|
||||
Integer count = (int) queueList.getTotal();
|
||||
PageInfo<Queue> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount(count);
|
||||
pageInfo.setLists(queueList.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal(count);
|
||||
pageInfo.setTotalList(queueList.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
|
@ -512,9 +512,9 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
||||
* @return resource list page
|
||||
*/
|
||||
@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);
|
||||
int userId = loginUser.getId();
|
||||
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);
|
||||
|
||||
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int)resourceIPage.getTotal());
|
||||
pageInfo.setLists(resourceIPage.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int)resourceIPage.getTotal());
|
||||
pageInfo.setTotalList(resourceIPage.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result,Status.SUCCESS);
|
||||
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.SchedulerService;
|
||||
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.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
@ -415,9 +416,9 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
||||
* @return schedule list page
|
||||
*/
|
||||
@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);
|
||||
|
||||
@ -438,11 +439,10 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
||||
);
|
||||
|
||||
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) scheduleIPage.getTotal());
|
||||
pageInfo.setLists(scheduleIPage.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) scheduleIPage.getTotal());
|
||||
pageInfo.setTotalList(scheduleIPage.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
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.UsersService;
|
||||
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.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
@ -88,35 +89,33 @@ public class TaskInstanceServiceImpl extends BaseServiceImpl implements TaskInst
|
||||
* @return task list page
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryTaskListPaging(User loginUser, String projectName,
|
||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
public Result queryTaskListPaging(User loginUser, String projectName,
|
||||
Integer processInstanceId, String processInstanceName, String taskName, String executorName, String startDate,
|
||||
String endDate, String searchVal, ExecutionStatus stateType, String host,
|
||||
Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
|
||||
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
|
||||
Status status = (Status) checkResult.get(Constants.STATUS);
|
||||
if (status != Status.SUCCESS) {
|
||||
return checkResult;
|
||||
putMsg(result,status);
|
||||
return result;
|
||||
}
|
||||
|
||||
int[] statusArray = null;
|
||||
if (stateType != null) {
|
||||
statusArray = new int[]{stateType.ordinal()};
|
||||
}
|
||||
|
||||
Map<String, Object> checkAndParseDateResult = checkAndParseDateParameters(startDate, endDate);
|
||||
if (checkAndParseDateResult.get(Constants.STATUS) != Status.SUCCESS) {
|
||||
return checkAndParseDateResult;
|
||||
status = (Status) checkAndParseDateResult.get(Constants.STATUS);
|
||||
if (status != Status.SUCCESS) {
|
||||
putMsg(result,status);
|
||||
return result;
|
||||
}
|
||||
Date start = (Date) checkAndParseDateResult.get(Constants.START_TIME);
|
||||
Date end = (Date) checkAndParseDateResult.get(Constants.END_TIME);
|
||||
|
||||
Page<TaskInstance> page = new Page<>(pageNo, pageSize);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
int executorId = usersService.getUserIdByName(executorName);
|
||||
|
||||
IPage<TaskInstance> taskInstanceIPage = taskInstanceMapper.queryTaskInstanceListPaging(
|
||||
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());
|
||||
}
|
||||
}
|
||||
pageInfo.setTotalCount((int) taskInstanceIPage.getTotal());
|
||||
pageInfo.setLists(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet));
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) taskInstanceIPage.getTotal());
|
||||
pageInfo.setTotalList(CollectionUtils.getListByExclusion(taskInstanceIPage.getRecords(), exclusionSet));
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -131,19 +131,20 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
|
||||
* @return tenant list page
|
||||
*/
|
||||
@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<>();
|
||||
if (isNotAdmin(loginUser, result)) {
|
||||
Result result = new Result();
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
||||
Page<Tenant> page = new Page<>(pageNo, pageSize);
|
||||
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, searchVal);
|
||||
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) tenantIPage.getTotal());
|
||||
pageInfo.setLists(tenantIPage.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) tenantIPage.getTotal());
|
||||
pageInfo.setTotalList(tenantIPage.getRecords());
|
||||
result.setData(pageInfo);
|
||||
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
|
@ -246,13 +246,13 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
|
||||
* @return udf function list page
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
public Result queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
PageInfo<UdfFunc> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
IPage<UdfFunc> udfFuncList = getUdfFuncsPage(loginUser, searchVal, pageSize, pageNo);
|
||||
pageInfo.setTotalCount((int)udfFuncList.getTotal());
|
||||
pageInfo.setLists(udfFuncList.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int)udfFuncList.getTotal());
|
||||
pageInfo.setTotalList(udfFuncList.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
@ -318,10 +318,10 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
||||
* @return user list page
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
|
||||
public Result queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result result = new Result();
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -330,9 +330,9 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
||||
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal);
|
||||
|
||||
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount((int) scheduleList.getTotal());
|
||||
pageInfo.setLists(scheduleList.getRecords());
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
pageInfo.setTotal((int) scheduleList.getTotal());
|
||||
pageInfo.setTotalList(scheduleList.getRecords());
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
|
||||
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.utils.PageInfo;
|
||||
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.enums.NodeType;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
@ -169,14 +170,15 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
|
||||
* @return worker group list page
|
||||
*/
|
||||
@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
|
||||
int fromIndex = (pageNo - 1) * pageSize;
|
||||
// list to index
|
||||
int toIndex = (pageNo - 1) * pageSize + pageSize;
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (isNotAdmin(loginUser, result)) {
|
||||
Result result = new Result();
|
||||
if (!isAdmin(loginUser)) {
|
||||
putMsg(result,Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -205,10 +207,10 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
|
||||
}
|
||||
|
||||
PageInfo<WorkerGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
|
||||
pageInfo.setTotalCount(resultDataList.size());
|
||||
pageInfo.setLists(resultDataList);
|
||||
pageInfo.setTotal(resultDataList.size());
|
||||
pageInfo.setTotalList(resultDataList);
|
||||
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
result.setData(pageInfo);
|
||||
putMsg(result, Status.SUCCESS);
|
||||
return result;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.utils;
|
||||
|
||||
import java.util.List;
|
||||
@ -26,13 +27,17 @@ import java.util.List;
|
||||
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
|
||||
*/
|
||||
@ -46,13 +51,13 @@ public class PageInfo<T> {
|
||||
*/
|
||||
private Integer pageNo;
|
||||
|
||||
public PageInfo(Integer currentPage,Integer pageSize){
|
||||
if(currentPage==null){
|
||||
currentPage=1;
|
||||
public PageInfo(Integer currentPage, Integer pageSize) {
|
||||
if (currentPage == null) {
|
||||
currentPage = 1;
|
||||
}
|
||||
this.pageNo=(currentPage-1)*pageSize;
|
||||
this.pageSize=pageSize;
|
||||
this.currentPage=currentPage;
|
||||
this.pageNo = (currentPage - 1) * pageSize;
|
||||
this.pageSize = pageSize;
|
||||
this.currentPage = currentPage;
|
||||
}
|
||||
|
||||
public Integer getStart() {
|
||||
@ -63,37 +68,42 @@ public class PageInfo<T> {
|
||||
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() {
|
||||
if (pageSize==null||pageSize == 0) {
|
||||
if (pageSize == null || pageSize == 0) {
|
||||
pageSize = 7;
|
||||
}
|
||||
if (this.totalCount % this.pageSize == 0) {
|
||||
return (this.totalCount / this.pageSize)==0?1:(this.totalCount / this.pageSize);
|
||||
}
|
||||
return (this.totalCount / this.pageSize + 1);
|
||||
this.totalPage =
|
||||
(this.total % this.pageSize) == 0
|
||||
? ((this.total / this.pageSize) == 0 ? 1 : (this.total / this.pageSize))
|
||||
: (this.total / this.pageSize + 1);
|
||||
return this.totalPage;
|
||||
}
|
||||
|
||||
public List<T> getLists() {
|
||||
return lists;
|
||||
}
|
||||
|
||||
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 void setTotalPage(Integer totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
if (pageSize==null||pageSize == 0) {
|
||||
if (pageSize == null || pageSize == 0) {
|
||||
pageSize = 7;
|
||||
}
|
||||
return pageSize;
|
||||
@ -103,15 +113,14 @@ public class PageInfo<T> {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public Integer getCurrentPage() {
|
||||
if (currentPage == null || currentPage <= 0) {
|
||||
this.currentPage = 1;
|
||||
}
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public void setCurrentPage(Integer 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
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.dolphinscheduler.api.utils;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
@ -129,7 +130,6 @@ public class Result<T> {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Status{"
|
||||
@ -139,4 +139,8 @@ public class Result<T> {
|
||||
+ ", 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.dao.entity.User;
|
||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -38,7 +38,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* access token controller test
|
||||
*/
|
||||
public class AccessTokenControllerTest extends AbstractControllerTest{
|
||||
public class AccessTokenControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
|
||||
|
||||
|
@ -39,7 +39,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* alert group controller test
|
||||
*/
|
||||
public class AlertGroupControllerTest extends AbstractControllerTest{
|
||||
public class AlertGroupControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertGroupController.class);
|
||||
|
||||
@ -110,7 +110,6 @@ public class AlertGroupControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyGroupName() throws Exception {
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
@ -37,7 +36,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* data analysis controller test
|
||||
*/
|
||||
public class DataAnalysisControllerTest extends AbstractControllerTest{
|
||||
public class DataAnalysisControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DataAnalysisControllerTest.class);
|
||||
|
||||
@ -113,7 +112,6 @@ public class DataAnalysisControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.datasource.mysql.MysqlDatasourceParamDTO;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
@ -42,7 +41,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* data source controller test
|
||||
*/
|
||||
public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
public class DataSourceControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DataSourceControllerTest.class);
|
||||
|
||||
@ -70,7 +69,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testUpdateDataSource() throws Exception {
|
||||
@ -97,8 +95,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testQueryDataSource() throws Exception {
|
||||
@ -115,7 +111,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryDataSourceList() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -131,7 +126,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryDataSourceListPaging() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -149,7 +143,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testConnectDataSource() throws Exception {
|
||||
@ -173,7 +166,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testConnectionTest() throws Exception {
|
||||
@ -190,8 +182,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyDataSourceName() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -207,7 +197,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAuthedDatasource() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -223,7 +212,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnauthDatasource() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -239,7 +227,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetKerberosStartupState() throws Exception {
|
||||
MvcResult mvcResult = mockMvc.perform(get("/datasources/kerberos-startup-state")
|
||||
@ -252,8 +239,6 @@ public class DataSourceControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
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 org.apache.dolphinscheduler.api.enums.ExecuteType;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
@ -63,7 +62,6 @@ public class LoggerControllerTest extends AbstractControllerTest {
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDownloadTaskLog() throws Exception {
|
||||
|
||||
@ -74,9 +72,8 @@ public class LoggerControllerTest extends AbstractControllerTest {
|
||||
.header("sessionId", sessionId)
|
||||
.params(paramsMap))
|
||||
.andExpect(status().isOk())
|
||||
// .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
/*.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))*/
|
||||
.andReturn();
|
||||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||
Assert.assertTrue(result != null && result.isSuccess());
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
@ -37,7 +36,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* login controller test
|
||||
*/
|
||||
public class LoginControllerTest extends AbstractControllerTest{
|
||||
public class LoginControllerTest extends AbstractControllerTest {
|
||||
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
@ -44,7 +43,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/master/list")
|
||||
.header(SESSION_ID, sessionId)
|
||||
/* .param("type", ResourceType.FILE.name())*/ )
|
||||
/* .param("type", ResourceType.FILE.name())*/)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andReturn();
|
||||
@ -60,7 +59,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/worker/list")
|
||||
.header(SESSION_ID, sessionId)
|
||||
/* .param("type", ResourceType.FILE.name())*/ )
|
||||
/* .param("type", ResourceType.FILE.name())*/)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andReturn();
|
||||
@ -75,7 +74,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
||||
public void testQueryDatabaseState() throws Exception {
|
||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/database")
|
||||
.header(SESSION_ID, sessionId)
|
||||
/* .param("type", ResourceType.FILE.name())*/ )
|
||||
/* .param("type", ResourceType.FILE.name())*/)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andReturn();
|
||||
@ -90,7 +89,7 @@ public class MonitorControllerTest extends AbstractControllerTest {
|
||||
public void testQueryZookeeperState() throws Exception {
|
||||
MvcResult mvcResult = mockMvc.perform(get("/monitor/zookeeper/list")
|
||||
.header(SESSION_ID, sessionId)
|
||||
/* .param("type", ResourceType.FILE.name())*/ )
|
||||
/* .param("type", ResourceType.FILE.name())*/)
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.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
|
||||
public void testVerifyProcessDefinitionName() throws Exception {
|
||||
|
||||
@ -355,9 +364,9 @@ public class ProcessDefinitionControllerTest {
|
||||
String searchVal = "";
|
||||
int userId = 1;
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
Result result = new Result();
|
||||
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);
|
||||
Result response = processDefinitionController.queryProcessDefinitionListPaging(user, projectName, pageNo, searchVal, userId, pageSize);
|
||||
@ -378,9 +387,9 @@ public class ProcessDefinitionControllerTest {
|
||||
@Test
|
||||
public void testQueryProcessDefinitionVersions() {
|
||||
String projectName = "test";
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
Result resultMap = new Result();
|
||||
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(
|
||||
user
|
||||
, projectName
|
||||
|
@ -78,7 +78,9 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
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}}";
|
||||
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -115,7 +117,6 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testViewVariables() throws Exception {
|
||||
|
||||
@ -162,7 +162,6 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteProcessInstanceById() throws Exception {
|
||||
|
||||
|
@ -40,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* resources controller test
|
||||
*/
|
||||
public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
public class ResourcesControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourcesControllerTest.class);
|
||||
|
||||
@ -60,7 +60,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryResourceListPaging() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -82,7 +81,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyResourceName() throws Exception {
|
||||
|
||||
@ -111,7 +109,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
paramsMap.add("skipLineNum","2");
|
||||
paramsMap.add("limit","100");
|
||||
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get("/resources/view")
|
||||
.header(SESSION_ID, sessionId)
|
||||
.params(paramsMap))
|
||||
@ -135,7 +132,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
paramsMap.add("description","test");
|
||||
paramsMap.add("content","echo 1111");
|
||||
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/resources/online-create")
|
||||
.header(SESSION_ID, sessionId)
|
||||
.params(paramsMap))
|
||||
@ -156,7 +152,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
paramsMap.add("id", "1");
|
||||
paramsMap.add("content","echo test_1111");
|
||||
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/resources/update-content")
|
||||
.header(SESSION_ID, sessionId)
|
||||
.params(paramsMap))
|
||||
@ -189,7 +184,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateUdfFunc() throws Exception {
|
||||
|
||||
@ -202,7 +196,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
paramsMap.add("description", "description");
|
||||
paramsMap.add("resourceId", "1");
|
||||
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/resources/udf-func/create")
|
||||
.header(SESSION_ID, sessionId)
|
||||
.params(paramsMap))
|
||||
@ -235,7 +228,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateUdfFunc() throws Exception {
|
||||
|
||||
@ -262,7 +254,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryUdfFuncList() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -283,8 +274,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryResourceList() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -303,7 +292,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyUdfFuncName() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -340,7 +328,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnauthorizedFile() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -359,7 +346,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAuthorizedUDFFunction() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -396,7 +382,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteUdfFunc() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -415,7 +400,6 @@ public class ResourcesControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
import org.apache.dolphinscheduler.common.enums.Priority;
|
||||
@ -41,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* scheduler controller test
|
||||
*/
|
||||
public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
public class SchedulerControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SchedulerControllerTest.class);
|
||||
|
||||
@ -70,7 +69,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateSchedule() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -113,7 +111,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOffline() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -131,7 +128,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryScheduleListPaging() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -152,7 +148,6 @@ public class SchedulerControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueryScheduleList() throws Exception {
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPreviewSchedule() throws Exception {
|
||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
|
||||
|
@ -64,12 +64,13 @@ public class TaskInstanceControllerTest extends AbstractControllerTest {
|
||||
@Test
|
||||
public void testQueryTaskListPaging() {
|
||||
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
Result result = new Result();
|
||||
Integer pageNo = 1;
|
||||
Integer pageSize = 20;
|
||||
PageInfo pageInfo = new PageInfo<TaskInstance>(pageNo, pageSize);
|
||||
result.put(Constants.DATA_LIST, pageInfo);
|
||||
result.put(Constants.STATUS, Status.SUCCESS);
|
||||
result.setData(pageInfo);
|
||||
result.setCode(Status.SUCCESS.getCode());
|
||||
result.setMsg(Status.SUCCESS.getMsg());
|
||||
|
||||
when(taskInstanceService.queryTaskListPaging(any(), eq(""), eq(1), eq(""), eq(""), eq(""),any(), any(),
|
||||
eq(""), Mockito.any(), eq("192.168.xx.xx"), any(), any())).thenReturn(result);
|
||||
|
@ -38,7 +38,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* tenant controller test
|
||||
*/
|
||||
public class TenantControllerTest extends AbstractControllerTest{
|
||||
public class TenantControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TenantControllerTest.class);
|
||||
|
||||
@ -102,7 +102,6 @@ public class TenantControllerTest extends AbstractControllerTest{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyTenantCode() throws Exception {
|
||||
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.status;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
|
||||
@ -41,7 +40,7 @@ import org.springframework.util.MultiValueMap;
|
||||
/**
|
||||
* users controller test
|
||||
*/
|
||||
public class UsersControllerTest extends AbstractControllerTest{
|
||||
public class UsersControllerTest extends AbstractControllerTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UsersControllerTest.class);
|
||||
|
||||
@ -126,8 +125,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testGrantUDFFunc() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -146,7 +143,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGrantDataSource() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -195,7 +191,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAuthorizedUser() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -230,7 +225,6 @@ public class UsersControllerTest extends AbstractControllerTest{
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testVerifyUserName() throws Exception {
|
||||
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.service.impl.AccessTokenServiceImpl;
|
||||
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.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||
@ -66,18 +67,16 @@ public class AccessTokenServiceTest {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQueryAccessTokenList() {
|
||||
|
||||
IPage<AccessToken> tokenPage = new Page<>();
|
||||
tokenPage.setRecords(getList());
|
||||
tokenPage.setTotal(1L);
|
||||
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
|
||||
|
||||
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());
|
||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(pageInfo.getTotalCount() > 0);
|
||||
Assert.assertTrue(pageInfo.getTotal() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -134,8 +133,7 @@ public class AccessTokenServiceTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private User getLoginUser(){
|
||||
private User getLoginUser() {
|
||||
User loginUser = new User();
|
||||
loginUser.setId(1);
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
@ -165,7 +163,6 @@ public class AccessTokenServiceTest {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get dateStr
|
||||
*/
|
||||
|
@ -23,6 +23,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.AlertGroupServiceImpl;
|
||||
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.enums.UserType;
|
||||
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);
|
||||
User user = new User();
|
||||
// no operate
|
||||
Map<String, Object> result = alertGroupService.listPaging(user, groupName, 1, 10);
|
||||
Result result = alertGroupService.listPaging(user, groupName, 1, 10);
|
||||
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
|
||||
user.setUserType(UserType.ADMIN_USER);
|
||||
result = alertGroupService.listPaging(user, groupName, 1, 10);
|
||||
logger.info(result.toString());
|
||||
PageInfo<AlertGroup> pageInfo = (PageInfo<AlertGroup>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
PageInfo<AlertGroup> pageInfo = (PageInfo<AlertGroup>) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -61,12 +61,12 @@ public class BaseServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAdmin(){
|
||||
public void testIsAdmin() {
|
||||
|
||||
User user = new User();
|
||||
user.setUserType(UserType.ADMIN_USER);
|
||||
//ADMIN_USER
|
||||
boolean isAdmin = baseService.isAdmin(user);
|
||||
boolean isAdmin = baseService.isAdmin(user);
|
||||
Assert.assertTrue(isAdmin);
|
||||
//GENERAL_USER
|
||||
user.setUserType(UserType.GENERAL_USER);
|
||||
@ -75,10 +75,8 @@ public class BaseServiceTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testPutMsg(){
|
||||
public void testPutMsg() {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
baseService.putMsg(result, Status.SUCCESS);
|
||||
@ -87,8 +85,9 @@ public class BaseServiceTest {
|
||||
baseService.putMsg(result, Status.PROJECT_NOT_FOUNT,"test");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutMsgTwo(){
|
||||
public void testPutMsgTwo() {
|
||||
|
||||
Result result = new Result();
|
||||
baseService.putMsg(result, Status.SUCCESS);
|
||||
@ -96,8 +95,9 @@ public class BaseServiceTest {
|
||||
//has params
|
||||
baseService.putMsg(result,Status.PROJECT_NOT_FOUNT,"test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTenantDirIfNotExists(){
|
||||
public void testCreateTenantDirIfNotExists() {
|
||||
|
||||
PowerMockito.mockStatic(HadoopUtils.class);
|
||||
PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
|
||||
@ -111,8 +111,9 @@ public class BaseServiceTest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasPerm(){
|
||||
public void testHasPerm() {
|
||||
|
||||
User user = new User();
|
||||
user.setId(1);
|
||||
|
@ -108,7 +108,6 @@ public class DataAnalysisServiceTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
|
||||
@ -127,12 +126,11 @@ public class DataAnalysisServiceTest {
|
||||
Map<String, Object> result = dataAnalysisService.countTaskStateByProject(user, 2, startDate, endDate);
|
||||
Assert.assertTrue(result.isEmpty());
|
||||
|
||||
|
||||
//SUCCESS
|
||||
Mockito.when(taskInstanceMapper.countTaskInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
||||
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(getTaskInstanceStateCounts());
|
||||
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);
|
||||
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(processInstanceMapper.countInstanceStateByUser(DateUtils.getScheduleDate(startDate),
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||
@ -251,7 +249,7 @@ public class DataAnalysisServiceTest {
|
||||
Mockito.when(errorCommandMapper.countCommandState(DateUtils.getScheduleDate(startDate),
|
||||
DateUtils.getScheduleDate(endDate), new Long[]{1L})).thenReturn(commandCounts);
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||
|
@ -180,8 +180,8 @@ public class DataSourceServiceTest {
|
||||
String searchVal = "";
|
||||
int pageNo = 1;
|
||||
int pageSize = 10;
|
||||
Map<String, Object> success = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
Assert.assertEquals(Status.SUCCESS, success.get(Constants.STATUS));
|
||||
Result result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),(int)result.getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -55,7 +55,7 @@ public class MonitorServiceTest {
|
||||
private MonitorDBDao monitorDBDao;
|
||||
|
||||
@Test
|
||||
public void testQueryDatabaseState(){
|
||||
public void testQueryDatabaseState() {
|
||||
|
||||
Mockito.when(monitorDBDao.queryDatabaseState()).thenReturn(getList());
|
||||
Map<String,Object> result = monitorService.queryDatabaseState(null);
|
||||
@ -64,41 +64,43 @@ public class MonitorServiceTest {
|
||||
List<MonitorRecord> monitorRecordList = (List<MonitorRecord>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(monitorRecordList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryMaster(){
|
||||
public void testQueryMaster() {
|
||||
//TODO need zk
|
||||
// Map<String,Object> result = monitorService.queryMaster(null);
|
||||
// logger.info(result.toString());
|
||||
// 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));
|
||||
/*Map<String,Object> result = monitorService.queryMaster(null);*/
|
||||
/*logger.info(result.toString());*/
|
||||
/*Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetServerListFromZK(){
|
||||
public void testQueryZookeeperState() {
|
||||
//TODO need zk
|
||||
// List<Server> serverList = monitorService.getServerListFromZK(true);
|
||||
// logger.info(serverList.toString());
|
||||
/*Map<String,Object> result = monitorService.queryZookeeperState(null);*/
|
||||
/*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<>();
|
||||
monitorRecordList.add(getEntity());
|
||||
return monitorRecordList;
|
||||
}
|
||||
|
||||
private MonitorRecord getEntity(){
|
||||
private MonitorRecord getEntity() {
|
||||
MonitorRecord monitorRecord = new MonitorRecord();
|
||||
monitorRecord.setDbType(DbType.MYSQL);
|
||||
return monitorRecord;
|
||||
}
|
||||
|
||||
private List<Server> getServerList(){
|
||||
private List<Server> getServerList() {
|
||||
List<Server> servers = new ArrayList<>();
|
||||
servers.add(new Server());
|
||||
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.service.impl.ProcessDefinitionServiceImpl;
|
||||
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.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
|
||||
@ -313,8 +314,8 @@ public class ProcessDefinitionServiceTest {
|
||||
|
||||
//project not found
|
||||
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectName)).thenReturn(result);
|
||||
Map<String, Object> map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, "project_test1", "", 1, 5, 0);
|
||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS));
|
||||
Result map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, "project_test1", "", 1, 5, 0);
|
||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int)map.getCode());
|
||||
|
||||
putMsg(result, Status.SUCCESS, projectName);
|
||||
loginUser.setId(1);
|
||||
@ -328,10 +329,10 @@ public class ProcessDefinitionServiceTest {
|
||||
, Mockito.eq(project.getCode())
|
||||
, Mockito.anyBoolean())).thenReturn(page);
|
||||
|
||||
Map<String, Object> map1 = processDefinitionService.queryProcessDefinitionListPaging(
|
||||
Result map1 = processDefinitionService.queryProcessDefinitionListPaging(
|
||||
loginUser, projectName, "", 1, 10, loginUser.getId());
|
||||
|
||||
Assert.assertEquals(Status.SUCCESS, map1.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getMsg(), map1.getMsg());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -124,10 +124,10 @@ public class ProcessInstanceServiceTest {
|
||||
//project auth fail
|
||||
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
||||
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,
|
||||
"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 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(),
|
||||
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,
|
||||
"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
|
||||
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(),
|
||||
eq("192.168.xx.xx"), eq(start), eq(end))).thenReturn(pageReturn);
|
||||
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,
|
||||
"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
|
||||
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, "",
|
||||
"", "", loginUser.getUserName(), ExecutionStatus.SUBMITTED_SUCCESS,
|
||||
"192.168.xx.xx", 1, 10);
|
||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(), (int)successRes.getCode());
|
||||
|
||||
//executor null
|
||||
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
||||
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,
|
||||
"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
|
||||
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);
|
||||
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,
|
||||
"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.service.impl.ProjectServiceImpl;
|
||||
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.enums.UserType;
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
|
||||
@ -190,18 +191,18 @@ public class ProjectServiceTest {
|
||||
User loginUser = getLoginUser();
|
||||
|
||||
// project owner
|
||||
Map<String, Object> result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
||||
Result result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
||||
logger.info(result.toString());
|
||||
PageInfo<Project> pageInfo = (PageInfo<Project>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
PageInfo<Project> pageInfo = (PageInfo<Project>) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
|
||||
//admin
|
||||
Mockito.when(projectMapper.queryProjectListPaging(Mockito.any(Page.class), Mockito.eq(0), Mockito.eq(projectName))).thenReturn(page);
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
result = projectService.queryProjectListPaging(loginUser, 10, 1, projectName);
|
||||
logger.info(result.toString());
|
||||
pageInfo = (PageInfo<Project>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
pageInfo = (PageInfo<Project>) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -402,7 +403,6 @@ public class ProjectServiceTest {
|
||||
return Collections.singletonList(1);
|
||||
}
|
||||
|
||||
|
||||
private String getDesc() {
|
||||
return "projectUserMapper.deleteProjectRelation(projectId,userId)projectUserMappe"
|
||||
+ ".deleteProjectRelation(projectId,userId)projectUserMappe"
|
||||
|
@ -85,6 +85,7 @@ public class QueueServiceTest {
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(queueList));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryListPage() {
|
||||
|
||||
@ -92,11 +93,12 @@ public class QueueServiceTest {
|
||||
page.setTotal(1L);
|
||||
page.setRecords(getQueueList());
|
||||
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());
|
||||
PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
PageInfo<Queue> pageInfo = (PageInfo<Queue>) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateQueue() {
|
||||
|
||||
@ -196,7 +198,6 @@ public class QueueServiceTest {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get queue
|
||||
* @return
|
||||
|
@ -269,11 +269,11 @@ public class ResourcesServiceTest {
|
||||
|
||||
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class),
|
||||
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());
|
||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||
PageInfo pageInfo = (PageInfo) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(), (int)result.getCode());
|
||||
PageInfo pageInfo = (PageInfo) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class SessionServiceTest {
|
||||
@Mock
|
||||
private SessionMapper sessionMapper;
|
||||
|
||||
private String sessionId ="aaaaaaaaaaaaaaaaaa";
|
||||
private String sessionId = "aaaaaaaaaaaaaaaaaa";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -73,8 +73,7 @@ public class SessionServiceTest {
|
||||
* create session
|
||||
*/
|
||||
@Test
|
||||
public void testGetSession(){
|
||||
|
||||
public void testGetSession() {
|
||||
|
||||
Mockito.when(sessionMapper.selectById(sessionId)).thenReturn(getSession());
|
||||
// get sessionId from header
|
||||
@ -96,32 +95,29 @@ public class SessionServiceTest {
|
||||
Assert.assertNotNull(session);
|
||||
logger.info("session ip {}",session.getIp());
|
||||
Assert.assertEquals(session.getIp(),"127.0.0.1");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* create session
|
||||
*/
|
||||
@Test
|
||||
public void testCreateSession(){
|
||||
|
||||
public void testCreateSession() {
|
||||
String ip = "127.0.0.1";
|
||||
User user = new User();
|
||||
user.setUserType(UserType.GENERAL_USER);
|
||||
user.setId(1);
|
||||
Mockito.when(sessionMapper.queryByUserId(1)).thenReturn(getSessions());
|
||||
String sessionId = sessionService.createSession(user, ip);
|
||||
logger.info("createSessionId is "+sessionId);
|
||||
logger.info("createSessionId is " + sessionId);
|
||||
Assert.assertTrue(StringUtils.isNotEmpty(sessionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* sign out
|
||||
* remove ip restrictions
|
||||
*/
|
||||
@Test
|
||||
public void testSignOut(){
|
||||
|
||||
public void testSignOut() {
|
||||
int userId = 88888888;
|
||||
String ip = "127.0.0.1";
|
||||
User user = new User();
|
||||
@ -129,12 +125,11 @@ public class SessionServiceTest {
|
||||
|
||||
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.setId(sessionId);
|
||||
session.setIp("127.0.0.1");
|
||||
@ -143,11 +138,9 @@ public class SessionServiceTest {
|
||||
return session;
|
||||
}
|
||||
|
||||
private List<Session> getSessions(){
|
||||
private List<Session> getSessions() {
|
||||
List<Session> sessionList = new ArrayList<>();
|
||||
sessionList.add(getSession());
|
||||
sessionList.add(getSession());
|
||||
return sessionList;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl;
|
||||
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.enums.ExecutionStatus;
|
||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||
@ -90,18 +91,18 @@ public class TaskInstanceServiceTest {
|
||||
//project auth fail
|
||||
when(projectMapper.queryByName(projectName)).thenReturn(null);
|
||||
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);
|
||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int)proejctAuthFailRes.getCode());
|
||||
|
||||
// data parameter check
|
||||
putMsg(result, Status.SUCCESS, projectName);
|
||||
Project project = getProject(projectName);
|
||||
when(projectMapper.queryByName(Mockito.anyString())).thenReturn(project);
|
||||
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);
|
||||
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
|
||||
putMsg(result, Status.SUCCESS, projectName);
|
||||
@ -122,40 +123,41 @@ public class TaskInstanceServiceTest {
|
||||
when(usersService.queryUser(processInstance.getExecutorId())).thenReturn(loginUser);
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(), (int)successRes.getCode());
|
||||
|
||||
//executor name empty
|
||||
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);
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, executorEmptyRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(), (int)executorEmptyRes.getCode());
|
||||
|
||||
//executor null
|
||||
when(usersService.queryUser(loginUser.getId())).thenReturn(null);
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, executorNullRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),(int)executorNullRes.getCode());
|
||||
|
||||
//start/end date null
|
||||
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);
|
||||
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);
|
||||
Assert.assertEquals(Status.SUCCESS, executorNullDateRes.get(Constants.STATUS));
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(),(int) executorNullDateRes.getCode());
|
||||
|
||||
//start date error format
|
||||
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);
|
||||
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);
|
||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, executorErrorStartDateRes.get(Constants.STATUS));
|
||||
Map<String, Object> executorErrorEndDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), (int)executorErrorStartDateRes.getCode());
|
||||
Result executorErrorEndDateRes = taskInstanceService.queryTaskListPaging(loginUser, projectName, 1, "", "",
|
||||
"", 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);
|
||||
Mockito.when(tenantMapper.queryTenantPaging(Mockito.any(Page.class), Mockito.eq("TenantServiceTest")))
|
||||
.thenReturn(page);
|
||||
Map<String, Object> result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10);
|
||||
Result result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10);
|
||||
logger.info(result.toString());
|
||||
PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -81,27 +81,30 @@ public class UdfFuncServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateUdfFunction(){
|
||||
public void testCreateUdfFunction() {
|
||||
|
||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
||||
//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());
|
||||
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
|
||||
//resource not exist
|
||||
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());
|
||||
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
|
||||
// success
|
||||
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());
|
||||
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryUdfFuncDetail(){
|
||||
public void testQueryUdfFuncDetail() {
|
||||
|
||||
PowerMockito.when(udfFuncMapper.selectById(1)).thenReturn(getUdfFunc());
|
||||
//resource not exist
|
||||
@ -115,51 +118,55 @@ public class UdfFuncServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateUdfFunc(){
|
||||
public void testUpdateUdfFunc() {
|
||||
|
||||
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
|
||||
PowerMockito.when(udfFuncMapper.selectUdfById(1)).thenReturn(getUdfFunc());
|
||||
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
|
||||
|
||||
//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());
|
||||
Assert.assertEquals(Status.UDF_FUNCTION_NOT_EXIST,result.get(Constants.STATUS));
|
||||
|
||||
//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());
|
||||
Assert.assertEquals(Status.HDFS_NOT_STARTUP,result.get(Constants.STATUS));
|
||||
|
||||
//RESOURCE_NOT_EXIST
|
||||
PowerMockito.when(udfFuncMapper.selectUdfById(11)).thenReturn(getUdfFunc());
|
||||
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());
|
||||
Assert.assertEquals(Status.RESOURCE_NOT_EXIST,result.get(Constants.STATUS));
|
||||
|
||||
//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());
|
||||
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryUdfFuncListPaging(){
|
||||
public void testQueryUdfFuncListPaging() {
|
||||
|
||||
IPage<UdfFunc> page = new Page<>(1,10);
|
||||
page.setTotal(1L);
|
||||
page.setRecords(getList());
|
||||
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());
|
||||
PageInfo pageInfo = (PageInfo) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
|
||||
PageInfo pageInfo = (PageInfo) result.getData();
|
||||
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryUdfFuncList(){
|
||||
public void testQueryUdfFuncList() {
|
||||
User user = getLoginUser();
|
||||
user.setUserType(UserType.GENERAL_USER);
|
||||
Mockito.when(udfFuncMapper.getUdfFuncByType(user.getId(), UdfType.HIVE.ordinal())).thenReturn(getList());
|
||||
@ -171,16 +178,16 @@ public class UdfFuncServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete(){
|
||||
public void testDelete() {
|
||||
Mockito.when(udfFuncMapper.deleteById(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());
|
||||
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyUdfFuncByName(){
|
||||
public void testVerifyUdfFuncByName() {
|
||||
|
||||
//success
|
||||
Mockito.when(udfFuncMapper.queryUdfByIdStr(null, "UdfFuncServiceTest")).thenReturn(getList());
|
||||
@ -197,7 +204,7 @@ public class UdfFuncServiceTest {
|
||||
* create admin user
|
||||
* @return
|
||||
*/
|
||||
private User getLoginUser(){
|
||||
private User getLoginUser() {
|
||||
|
||||
User loginUser = new User();
|
||||
loginUser.setUserType(UserType.ADMIN_USER);
|
||||
@ -208,7 +215,7 @@ public class UdfFuncServiceTest {
|
||||
/**
|
||||
* get resourceId
|
||||
*/
|
||||
private Resource getResource(){
|
||||
private Resource getResource() {
|
||||
|
||||
Resource resource = new Resource();
|
||||
resource.setId(1);
|
||||
@ -216,16 +223,16 @@ public class UdfFuncServiceTest {
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
||||
private List<UdfFunc> getList(){
|
||||
private List<UdfFunc> getList() {
|
||||
List<UdfFunc> udfFuncList = new ArrayList<>();
|
||||
udfFuncList.add(getUdfFunc());
|
||||
return udfFuncList;
|
||||
}
|
||||
|
||||
/**
|
||||
* get UdfFunc id
|
||||
*/
|
||||
private UdfFunc getUdfFunc(){
|
||||
private UdfFunc getUdfFunc() {
|
||||
UdfFunc udfFunc = new UdfFunc();
|
||||
udfFunc.setFuncName("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);
|
||||
|
||||
//no operate
|
||||
Map<String, Object> result = usersService.queryUserList(user, "userTest", 1, 10);
|
||||
Result result = usersService.queryUserList(user, "userTest", 1, 10);
|
||||
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
|
||||
user.setUserType(UserType.ADMIN_USER);
|
||||
result = usersService.queryUserList(user, "userTest", 1, 10);
|
||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||
PageInfo<User> pageInfo = (PageInfo<User>) result.get(Constants.DATA_LIST);
|
||||
Assert.assertTrue(pageInfo.getLists().size() > 0);
|
||||
Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
|
||||
PageInfo<User> pageInfo = (PageInfo<User>) result.getData();
|
||||
Assert.assertTrue(pageInfo.getTotalList().size() > 0);
|
||||
}
|
||||
|
||||
@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,
|
||||
processDefinitionCode: processDefinitionCode
|
||||
}).then(res => {
|
||||
this.versionData.processDefinitionVersions = res.data.lists
|
||||
this.versionData.total = res.data.totalCount
|
||||
this.versionData.processDefinitionVersions = res.data.totalList
|
||||
this.versionData.total = res.data.total
|
||||
this.versionData.pageSize = res.data.pageSize
|
||||
this.versionData.pageNo = res.data.currentPage
|
||||
}).catch(e => {
|
||||
@ -800,8 +800,8 @@
|
||||
pageSize: 10,
|
||||
processDefinitionCode: this.store.state.dag.code
|
||||
}).then(res => {
|
||||
let processDefinitionVersions = res.data.lists
|
||||
let total = res.data.totalCount
|
||||
let processDefinitionVersions = res.data.totalList
|
||||
let total = res.data.total
|
||||
let pageSize = res.data.pageSize
|
||||
let pageNo = res.data.currentPage
|
||||
this.versionData.processDefinition.id = this.urlParam.id
|
||||
|
@ -362,8 +362,8 @@
|
||||
pageSize: pageSize,
|
||||
processDefinitionCode: processDefinitionCode
|
||||
}).then(res => {
|
||||
this.versionData.processDefinitionVersions = res.data.lists
|
||||
this.versionData.total = res.data.totalCount
|
||||
this.versionData.processDefinitionVersions = res.data.totalList
|
||||
this.versionData.total = res.data.total
|
||||
this.versionData.pageSize = res.data.pageSize
|
||||
this.versionData.pageNo = res.data.currentPage
|
||||
}).catch(e => {
|
||||
@ -399,8 +399,8 @@
|
||||
pageSize: 10,
|
||||
processDefinitionCode: item.code
|
||||
}).then(res => {
|
||||
let processDefinitionVersions = res.data.lists
|
||||
let total = res.data.totalCount
|
||||
let processDefinitionVersions = res.data.totalList
|
||||
let total = res.data.total
|
||||
let pageSize = res.data.pageSize
|
||||
let pageNo = res.data.currentPage
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user