Browse Source

[Fix-7340] Improve the prompt content for deleting a project that didn't exist. (#7449)

* improve the prompt
3.0.0/version-upgrade
calvin 3 years ago committed by GitHub
parent
commit
6cad119806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
  2. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  3. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
  4. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java
  5. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java
  6. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/StatusTest.java
  7. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/BaseServiceTest.java
  8. 8
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java
  9. 34
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
  10. 30
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java
  11. 10
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java
  12. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java
  13. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

@ -46,7 +46,7 @@ public enum Status {
DATASOURCE_EXIST(10015, "data source name already exists", "数据源名称已存在"), DATASOURCE_EXIST(10015, "data source name already exists", "数据源名称已存在"),
DATASOURCE_CONNECT_FAILED(10016, "data source connection failed", "建立数据源连接失败"), DATASOURCE_CONNECT_FAILED(10016, "data source connection failed", "建立数据源连接失败"),
TENANT_NOT_EXIST(10017, "tenant not exists", "租户不存在"), TENANT_NOT_EXIST(10017, "tenant not exists", "租户不存在"),
PROJECT_NOT_FOUNT(10018, "project {0} not found ", "项目[{0}]不存在"), PROJECT_NOT_FOUND(10018, "project {0} not found ", "项目[{0}]不存在"),
PROJECT_ALREADY_EXISTS(10019, "project {0} already exists", "项目名称[{0}]已存在"), PROJECT_ALREADY_EXISTS(10019, "project {0} already exists", "项目名称[{0}]已存在"),
TASK_INSTANCE_NOT_EXISTS(10020, "task instance {0} does not exist", "任务实例[{0}]不存在"), TASK_INSTANCE_NOT_EXISTS(10020, "task instance {0} does not exist", "任务实例[{0}]不存在"),
TASK_INSTANCE_NOT_SUB_WORKFLOW_INSTANCE(10021, "task instance {0} is not sub process instance", "任务实例[{0}]不是子流程实例"), TASK_INSTANCE_NOT_SUB_WORKFLOW_INSTANCE(10021, "task instance {0} is not sub process instance", "任务实例[{0}]不是子流程实例"),
@ -214,6 +214,7 @@ public enum Status {
CURRENT_LOGIN_USER_TENANT_NOT_EXIST(10181, "the tenant of the currently login user is not specified", "未指定当前登录用户的租户"), CURRENT_LOGIN_USER_TENANT_NOT_EXIST(10181, "the tenant of the currently login user is not specified", "未指定当前登录用户的租户"),
REVOKE_PROJECT_ERROR(10182, "revoke project error", "撤销项目授权错误"), REVOKE_PROJECT_ERROR(10182, "revoke project error", "撤销项目授权错误"),
QUERY_AUTHORIZED_USER(10183, "query authorized user error", "查询拥有项目权限的用户错误"), QUERY_AUTHORIZED_USER(10183, "query authorized user error", "查询拥有项目权限的用户错误"),
PROJECT_NOT_EXIST(10190, "This project was not found. Please refresh page.", "该项目不存在,请刷新页面"),
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"), UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"),
UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"), UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"),

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -166,7 +166,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, long projectCode) { public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, long projectCode) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_EXIST);
} else if (!checkReadPermission(loginUser, project)) { } else if (!checkReadPermission(loginUser, project)) {
// check read permission // check read permission
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), projectCode); putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), projectCode);
@ -180,7 +180,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result) { public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result) {
boolean checkResult = false; boolean checkResult = false;
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, ""); putMsg(result, Status.PROJECT_NOT_FOUND, "");
} else if (!checkReadPermission(loginUser, project)) { } else if (!checkReadPermission(loginUser, project)) {
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getCode()); putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getCode());
} else { } else {
@ -193,7 +193,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
public boolean hasProjectAndPerm(User loginUser, Project project, Result result) { public boolean hasProjectAndPerm(User loginUser, Project project, Result result) {
boolean checkResult = false; boolean checkResult = false;
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, ""); putMsg(result, Status.PROJECT_NOT_FOUND, "");
} else if (!checkReadPermission(loginUser, project)) { } else if (!checkReadPermission(loginUser, project)) {
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName()); putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName());
} else { } else {

5
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

@ -59,7 +59,6 @@ import org.apache.commons.lang.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -602,7 +601,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
// 2. check if project is existed // 2. check if project is existed
Project project = this.projectMapper.queryByCode(projectCode); Project project = this.projectMapper.queryByCode(projectCode);
if (project == null) { if (project == null) {
this.putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
return result; return result;
} }
@ -653,7 +652,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
// 3. check if project is existed // 3. check if project is existed
Project project = this.projectMapper.queryByCode(projectCode); Project project = this.projectMapper.queryByCode(projectCode);
if (project == null) { if (project == null) {
this.putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); this.putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
return result; return result;
} }

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkFlowLineageServiceImpl.java

@ -70,7 +70,7 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode); Project project = projectMapper.queryByCode(projectCode);
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
return result; return result;
} }
List<WorkFlowLineage> workFlowLineageList = workFlowLineageMapper.queryWorkFlowLineageByName(projectCode, workFlowName); List<WorkFlowLineage> workFlowLineageList = workFlowLineageMapper.queryWorkFlowLineageByName(projectCode, workFlowName);
@ -84,7 +84,7 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode); Project project = projectMapper.queryByCode(projectCode);
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
return result; return result;
} }
Map<Long, WorkFlowLineage> workFlowLineagesMap = new HashMap<>(); Map<Long, WorkFlowLineage> workFlowLineagesMap = new HashMap<>();
@ -133,7 +133,7 @@ public class WorkFlowLineageServiceImpl extends BaseServiceImpl implements WorkF
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByCode(projectCode); Project project = projectMapper.queryByCode(projectCode);
if (project == null) { if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
return result; return result;
} }
List<ProcessLineage> processLineages = workFlowLineageMapper.queryProcessLineage(projectCode); List<ProcessLineage> processLineages = workFlowLineageMapper.queryProcessLineage(projectCode);

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java

@ -85,7 +85,7 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
@Test @Test
public void testQueryTaskListByProcessId() throws Exception { public void testQueryTaskListByProcessId() throws Exception {
Map<String, Object> mockResult = new HashMap<>(); Map<String, Object> mockResult = new HashMap<>();
mockResult.put(Constants.STATUS, Status.PROJECT_NOT_FOUNT); mockResult.put(Constants.STATUS, Status.PROJECT_NOT_FOUND);
PowerMockito.when(processInstanceService.queryTaskListByProcessId(Mockito.any(), Mockito.anyLong(), Mockito.any())) PowerMockito.when(processInstanceService.queryTaskListByProcessId(Mockito.any(), Mockito.anyLong(), Mockito.any()))
.thenReturn(mockResult); .thenReturn(mockResult);
@ -97,7 +97,7 @@ public class ProcessInstanceControllerTest extends AbstractControllerTest {
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertNotNull(result); Assert.assertNotNull(result);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), result.getCode().intValue()); Assert.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), result.getCode().intValue());
} }
@Test @Test

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/enums/StatusTest.java

@ -51,6 +51,6 @@ public class StatusTest {
// SUCCESS // SUCCESS
optional = Status.findStatusBy(10018); optional = Status.findStatusBy(10018);
Assert.assertTrue(optional.isPresent()); Assert.assertTrue(optional.isPresent());
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, optional.get()); Assert.assertEquals(Status.PROJECT_NOT_FOUND, optional.get());
} }
} }

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/BaseServiceTest.java

@ -82,7 +82,7 @@ public class BaseServiceTest {
baseService.putMsg(result, Status.SUCCESS); baseService.putMsg(result, Status.SUCCESS);
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS));
//has params //has params
baseService.putMsg(result, Status.PROJECT_NOT_FOUNT,"test"); baseService.putMsg(result, Status.PROJECT_NOT_FOUND,"test");
} }
@ -93,7 +93,7 @@ public class BaseServiceTest {
baseService.putMsg(result, Status.SUCCESS); baseService.putMsg(result, Status.SUCCESS);
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg()); Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg());
//has params //has params
baseService.putMsg(result,Status.PROJECT_NOT_FOUNT,"test"); baseService.putMsg(result,Status.PROJECT_NOT_FOUND,"test");
} }
@Test @Test

8
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

@ -146,10 +146,10 @@ public class DataAnalysisServiceTest {
// checkProject false // checkProject false
Map<String, Object> failResult = new HashMap<>(); Map<String, Object> failResult = new HashMap<>();
putMsg(failResult, Status.PROJECT_NOT_FOUNT, 1); putMsg(failResult, Status.PROJECT_NOT_FOUND, 1);
Mockito.when(projectService.checkProjectAndAuth(any(), any(), anyLong())).thenReturn(failResult); Mockito.when(projectService.checkProjectAndAuth(any(), any(), anyLong())).thenReturn(failResult);
failResult = dataAnalysisServiceImpl.countTaskStateByProject(user, 1, startDate, endDate); failResult = dataAnalysisServiceImpl.countTaskStateByProject(user, 1, startDate, endDate);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, failResult.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, failResult.get(Constants.STATUS));
} }
@Test @Test
@ -220,10 +220,10 @@ public class DataAnalysisServiceTest {
//checkProject false //checkProject false
Map<String, Object> failResult = new HashMap<>(); Map<String, Object> failResult = new HashMap<>();
putMsg(failResult, Status.PROJECT_NOT_FOUNT, 1); putMsg(failResult, Status.PROJECT_NOT_FOUND, 1);
Mockito.when(projectService.checkProjectAndAuth(any(), any(), anyLong())).thenReturn(failResult); Mockito.when(projectService.checkProjectAndAuth(any(), any(), anyLong())).thenReturn(failResult);
failResult = dataAnalysisServiceImpl.countProcessInstanceStateByProject(user, 1, startDate, endDate); failResult = dataAnalysisServiceImpl.countProcessInstanceStateByProject(user, 1, startDate, endDate);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, failResult.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, failResult.get(Constants.STATUS));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS, null); putMsg(result, Status.SUCCESS, null);

34
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java

@ -127,12 +127,12 @@ public class ProcessDefinitionServiceTest {
loginUser.setUserType(UserType.GENERAL_USER); loginUser.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project not found //project not found
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.queryProcessDefinitionList(loginUser, projectCode); Map<String, Object> map = processDefinitionService.queryProcessDefinitionList(loginUser, projectCode);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
//project check auth success //project check auth success
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -157,12 +157,12 @@ public class ProcessDefinitionServiceTest {
loginUser.setUserType(UserType.GENERAL_USER); loginUser.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project not found //project not found
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Result map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectCode, "", 1, 5, 0); Result map = processDefinitionService.queryProcessDefinitionListPaging(loginUser, projectCode, "", 1, 5, 0);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int) map.getCode()); Assert.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), (int) map.getCode());
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
loginUser.setId(1); loginUser.setId(1);
@ -196,12 +196,12 @@ public class ProcessDefinitionServiceTest {
tenant.setId(1); tenant.setId(1);
tenant.setTenantCode("root"); tenant.setTenantCode("root");
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project check auth fail //project check auth fail
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.queryProcessDefinitionByCode(loginUser, 1L, 1L); Map<String, Object> map = processDefinitionService.queryProcessDefinitionByCode(loginUser, 1L, 1L);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
//project check auth success, instance not exist //project check auth success, instance not exist
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -233,12 +233,12 @@ public class ProcessDefinitionServiceTest {
loginUser.setUserType(UserType.GENERAL_USER); loginUser.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project check auth fail //project check auth fail
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.queryProcessDefinitionByName(loginUser, projectCode, "test_def"); Map<String, Object> map = processDefinitionService.queryProcessDefinitionByName(loginUser, projectCode, "test_def");
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
//project check auth success, instance not exist //project check auth success, instance not exist
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -273,11 +273,11 @@ public class ProcessDefinitionServiceTest {
Assert.assertEquals(Status.PROCESS_DEFINITION_CODES_IS_EMPTY, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROCESS_DEFINITION_CODES_IS_EMPTY, map.get(Constants.STATUS));
// project check auth fail // project check auth fail
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map1 = processDefinitionService.batchCopyProcessDefinition( Map<String, Object> map1 = processDefinitionService.batchCopyProcessDefinition(
loginUser, projectCode, String.valueOf(project.getId()), 2L); loginUser, projectCode, String.valueOf(project.getId()), 2L);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map1.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map1.get(Constants.STATUS));
// project check auth success, target project name not equal project name, check auth target project fail // project check auth success, target project name not equal project name, check auth target project fail
projectCode = 2L; projectCode = 2L;
@ -344,10 +344,10 @@ public class ProcessDefinitionServiceTest {
//project check auth fail //project check auth fail
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.deleteProcessDefinitionByCode(loginUser, projectCode, 6L); Map<String, Object> map = processDefinitionService.deleteProcessDefinitionByCode(loginUser, projectCode, 6L);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
//project check auth success, instance not exist //project check auth success, instance not exist
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -420,11 +420,11 @@ public class ProcessDefinitionServiceTest {
//project check auth fail //project check auth fail
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.releaseProcessDefinition(loginUser, projectCode, Map<String, Object> map = processDefinitionService.releaseProcessDefinition(loginUser, projectCode,
6, ReleaseState.OFFLINE); 6, ReleaseState.OFFLINE);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
// project check auth success, processs definition online // project check auth success, processs definition online
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -464,11 +464,11 @@ public class ProcessDefinitionServiceTest {
//project check auth fail //project check auth fail
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(loginUser, Map<String, Object> map = processDefinitionService.verifyProcessDefinitionName(loginUser,
projectCode, "test_pdf"); projectCode, "test_pdf");
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, map.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, map.get(Constants.STATUS));
//project check auth success, process not exist //project check auth success, process not exist
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -630,7 +630,7 @@ public class ProcessDefinitionServiceTest {
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT); putMsg(result, Status.PROJECT_NOT_FOUND);
Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); Mockito.when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);

30
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java

@ -134,7 +134,7 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
@ -142,7 +142,7 @@ public class ProcessInstanceServiceTest {
Result proejctAuthFailRes = processInstanceService.queryProcessInstanceList(loginUser, projectCode, 46, "2020-01-01 00:00:00", Result proejctAuthFailRes = processInstanceService.queryProcessInstanceList(loginUser, projectCode, 46, "2020-01-01 00:00:00",
"2020-01-02 00:00:00", "", "test_user", ExecutionStatus.SUBMITTED_SUCCESS, "2020-01-02 00:00:00", "", "test_user", ExecutionStatus.SUBMITTED_SUCCESS,
"192.168.xx.xx", 1, 10); "192.168.xx.xx", 1, 10);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int) proejctAuthFailRes.getCode()); Assert.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), (int) proejctAuthFailRes.getCode());
Date start = DateUtils.getScheduleDate("2020-01-01 00:00:00"); Date start = DateUtils.getScheduleDate("2020-01-01 00:00:00");
Date end = DateUtils.getScheduleDate("2020-01-02 00:00:00"); Date end = DateUtils.getScheduleDate("2020-01-02 00:00:00");
@ -215,7 +215,7 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
int size = 10; int size = 10;
String startTime = "2020-01-01 00:00:00"; String startTime = "2020-01-01 00:00:00";
String endTime = "2020-08-02 00:00:00"; String endTime = "2020-08-02 00:00:00";
@ -226,7 +226,7 @@ public class ProcessInstanceServiceTest {
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectCode, size, startTime, endTime); Map<String, Object> proejctAuthFailRes = processInstanceService.queryTopNLongestRunningProcessInstance(loginUser, projectCode, size, startTime, endTime);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//project auth success //project auth success
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -247,13 +247,13 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.queryProcessInstanceById(loginUser, projectCode, 1); Map<String, Object> proejctAuthFailRes = processInstanceService.queryProcessInstanceById(loginUser, projectCode, 1);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//project auth success //project auth success
ProcessInstance processInstance = getProcessInstance(); ProcessInstance processInstance = getProcessInstance();
@ -284,13 +284,13 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.queryTaskListByProcessId(loginUser, projectCode, 1); Map<String, Object> proejctAuthFailRes = processInstanceService.queryTaskListByProcessId(loginUser, projectCode, 1);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//project auth success //project auth success
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -330,13 +330,13 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.querySubProcessInstanceByTaskId(loginUser, projectCode, 1); Map<String, Object> proejctAuthFailRes = processInstanceService.querySubProcessInstanceByTaskId(loginUser, projectCode, 1);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//task null //task null
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -382,14 +382,14 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, Map<String, Object> proejctAuthFailRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1,
shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, ""); shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, "");
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//process instance null //process instance null
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -446,13 +446,13 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Map<String, Object> proejctAuthFailRes = processInstanceService.queryParentInstanceBySubId(loginUser, projectCode, 1); Map<String, Object> proejctAuthFailRes = processInstanceService.queryParentInstanceBySubId(loginUser, projectCode, 1);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, proejctAuthFailRes.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, proejctAuthFailRes.get(Constants.STATUS));
//process instance null //process instance null
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
@ -490,7 +490,7 @@ public class ProcessInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//process instance null //process instance null
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);

10
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java

@ -113,7 +113,7 @@ public class ProjectServiceTest {
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, null, projectCode); Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, null, projectCode);
logger.info(result.toString()); logger.info(result.toString());
Status status = (Status) result.get(Constants.STATUS); Status status = (Status) result.get(Constants.STATUS);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_EXIST, result.get(Constants.STATUS));
Project project = getProject(); Project project = getProject();
//USER_NO_OPERATION_PROJECT_PERM //USER_NO_OPERATION_PROJECT_PERM
@ -131,7 +131,7 @@ public class ProjectServiceTest {
Map<String, Object> result2 = new HashMap<>(); Map<String, Object> result2 = new HashMap<>();
result2 = projectService.checkProjectAndAuth(loginUser, null, projectCode); result2 = projectService.checkProjectAndAuth(loginUser, null, projectCode);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result2.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_EXIST, result2.get(Constants.STATUS));
Project project1 = getProject(); Project project1 = getProject();
// USER_NO_OPERATION_PROJECT_PERM // USER_NO_OPERATION_PROJECT_PERM
@ -198,7 +198,7 @@ public class ProjectServiceTest {
//PROJECT_NOT_FOUNT //PROJECT_NOT_FOUNT
Map<String, Object> result = projectService.deleteProject(loginUser, 11L); Map<String, Object> result = projectService.deleteProject(loginUser, 11L);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_EXIST, result.get(Constants.STATUS));
loginUser.setId(2); loginUser.setId(2);
//USER_NO_OPERATION_PROJECT_PERM //USER_NO_OPERATION_PROJECT_PERM
result = projectService.deleteProject(loginUser, 1L); result = projectService.deleteProject(loginUser, 1L);
@ -231,7 +231,7 @@ public class ProjectServiceTest {
// PROJECT_NOT_FOUNT // PROJECT_NOT_FOUNT
Map<String, Object> result = projectService.update(loginUser, 1L, projectName, "desc", "testUser"); Map<String, Object> result = projectService.update(loginUser, 1L, projectName, "desc", "testUser");
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, result.get(Constants.STATUS));
//PROJECT_ALREADY_EXISTS //PROJECT_ALREADY_EXISTS
result = projectService.update(loginUser, 2L, projectName, "desc", userName); result = projectService.update(loginUser, 2L, projectName, "desc", userName);
@ -283,7 +283,7 @@ public class ProjectServiceTest {
// Failure 1: PROJECT_NOT_FOUND // Failure 1: PROJECT_NOT_FOUND
Map<String, Object> result = this.projectService.queryAuthorizedUser(loginUser, 3682329499136L); Map<String, Object> result = this.projectService.queryAuthorizedUser(loginUser, 3682329499136L);
logger.info("FAILURE 1: {}", result.toString()); logger.info("FAILURE 1: {}", result.toString());
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, result.get(Constants.STATUS));
// Failure 2: USER_NO_OPERATION_PROJECT_PERM // Failure 2: USER_NO_OPERATION_PROJECT_PERM
loginUser.setId(100); loginUser.setId(100);

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskInstanceServiceTest.java

@ -92,14 +92,14 @@ public class TaskInstanceServiceTest {
User loginUser = getAdminUser(); User loginUser = getAdminUser();
Project project = getProject(projectCode); Project project = getProject(projectCode);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.PROJECT_NOT_FOUNT, projectCode); putMsg(result, Status.PROJECT_NOT_FOUND, projectCode);
//project auth fail //project auth fail
when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectMapper.queryByCode(projectCode)).thenReturn(project);
when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result); when(projectService.checkProjectAndAuth(loginUser, project, projectCode)).thenReturn(result);
Result projectAuthFailRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 0, "", "", Result projectAuthFailRes = taskInstanceService.queryTaskListPaging(loginUser, projectCode, 0, "", "",
"test_user", "2019-02-26 19:48:00", "2019-02-26 19:48:22", "", null, "", 1, 20); "test_user", "2019-02-26 19:48:00", "2019-02-26 19:48:22", "", null, "", 1, 20);
Assert.assertEquals(Status.PROJECT_NOT_FOUNT.getCode(), (int)projectAuthFailRes.getCode()); Assert.assertEquals(Status.PROJECT_NOT_FOUND.getCode(), (int)projectAuthFailRes.getCode());
// data parameter check // data parameter check
putMsg(result, Status.SUCCESS, projectCode); putMsg(result, Status.SUCCESS, projectCode);

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java

@ -357,7 +357,7 @@ public class UsersServiceTest {
// ERROR: PROJECT_NOT_FOUNT // ERROR: PROJECT_NOT_FOUNT
result = this.usersService.grantProjectByCode(loginUser, authorizer, 999); result = this.usersService.grantProjectByCode(loginUser, authorizer, 999);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.PROJECT_NOT_FOUNT, result.get(Constants.STATUS)); Assert.assertEquals(Status.PROJECT_NOT_FOUND, result.get(Constants.STATUS));
// ERROR: USER_NO_OPERATION_PERM // ERROR: USER_NO_OPERATION_PERM
loginUser.setId(999); loginUser.setId(999);

Loading…
Cancel
Save