mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-05 05:38:30 +08:00
[Fix-5511]: the updateSchedule interface, projectName -> projectCode (#5761)
* fix: createSchedule interface, process definition id -> process definition code * fix: add junit * fix junit * fix: projectName -> projectCode * fix UT * Optimize variable type * fix: the updateSchedule interface, projectName -> projectCode * fix comment Co-authored-by: wen-hemin <wenhemin@apache.com>
This commit is contained in:
parent
d382a7ba8c
commit
cfa22d7c89
@ -76,7 +76,6 @@ public class SchedulerController extends BaseController {
|
||||
@Autowired
|
||||
private SchedulerService schedulerService;
|
||||
|
||||
|
||||
/**
|
||||
* create schedule
|
||||
*
|
||||
@ -125,7 +124,7 @@ public class SchedulerController extends BaseController {
|
||||
* updateProcessInstance schedule
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param projectCode project code
|
||||
* @param id scheduler id
|
||||
* @param schedule scheduler
|
||||
* @param warningType warning type
|
||||
@ -149,7 +148,7 @@ public class SchedulerController extends BaseController {
|
||||
@ApiException(UPDATE_SCHEDULE_ERROR)
|
||||
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
|
||||
public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
|
||||
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
|
||||
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
|
||||
@RequestParam(value = "id") Integer id,
|
||||
@RequestParam(value = "schedule") String schedule,
|
||||
@RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
|
||||
@ -158,8 +157,8 @@ public class SchedulerController extends BaseController {
|
||||
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
|
||||
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
|
||||
|
||||
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule,
|
||||
warningType, warningGroupId, failureStrategy, null, processInstancePriority, workerGroup);
|
||||
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectCode, id, schedule,
|
||||
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
|
||||
return returnDataList(result);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public interface SchedulerService {
|
||||
* updateProcessInstance schedule
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param projectCode project code
|
||||
* @param id scheduler id
|
||||
* @param scheduleExpression scheduler
|
||||
* @param warningType warning type
|
||||
@ -66,17 +66,15 @@ public interface SchedulerService {
|
||||
* @param failureStrategy failure strategy
|
||||
* @param workerGroup worker group
|
||||
* @param processInstancePriority process instance priority
|
||||
* @param scheduleStatus schedule status
|
||||
* @return update result code
|
||||
*/
|
||||
Map<String, Object> updateSchedule(User loginUser,
|
||||
String projectName,
|
||||
long projectCode,
|
||||
Integer id,
|
||||
String scheduleExpression,
|
||||
WarningType warningType,
|
||||
int warningGroupId,
|
||||
FailureStrategy failureStrategy,
|
||||
ReleaseState scheduleStatus,
|
||||
Priority processInstancePriority,
|
||||
String workerGroup);
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
||||
* updateProcessInstance schedule
|
||||
*
|
||||
* @param loginUser login user
|
||||
* @param projectName project name
|
||||
* @param projectCode project code
|
||||
* @param id scheduler id
|
||||
* @param scheduleExpression scheduler
|
||||
* @param warningType warning type
|
||||
@ -203,18 +203,17 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
||||
@Override
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Map<String, Object> updateSchedule(User loginUser,
|
||||
String projectName,
|
||||
long projectCode,
|
||||
Integer id,
|
||||
String scheduleExpression,
|
||||
WarningType warningType,
|
||||
int warningGroupId,
|
||||
FailureStrategy failureStrategy,
|
||||
ReleaseState scheduleStatus,
|
||||
Priority processInstancePriority,
|
||||
String workerGroup) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
Project project = projectMapper.queryByName(projectName);
|
||||
Project project = projectMapper.queryByCode(projectCode);
|
||||
|
||||
// check project auth
|
||||
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
|
||||
@ -273,9 +272,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
|
||||
schedule.setFailureStrategy(failureStrategy);
|
||||
}
|
||||
|
||||
if (scheduleStatus != null) {
|
||||
schedule.setReleaseState(scheduleStatus);
|
||||
}
|
||||
schedule.setWorkerGroup(workerGroup);
|
||||
schedule.setUpdateTime(now);
|
||||
schedule.setProcessInstancePriority(processInstancePriority);
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.controller;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer;
|
||||
@ -93,6 +94,13 @@ public class AbstractControllerTest {
|
||||
Assert.assertTrue(StringUtils.isNotEmpty(session));
|
||||
}
|
||||
|
||||
public Map<String, Object> successResult() {
|
||||
Map<String, Object> serviceResult = new HashMap<>();
|
||||
putMsg(serviceResult, Status.SUCCESS);
|
||||
serviceResult.put(Constants.DATA_LIST, "{}");
|
||||
return serviceResult;
|
||||
}
|
||||
|
||||
public void putMsg(Map<String, Object> result, Status status, Object... statusParams) {
|
||||
result.put(Constants.STATUS, status);
|
||||
if (statusParams != null && statusParams.length > 0) {
|
||||
|
@ -23,13 +23,9 @@ 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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
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.WarningType;
|
||||
@ -69,13 +65,9 @@ public class SchedulerControllerTest extends AbstractControllerTest {
|
||||
paramsMap.add("workerGroupId","1");
|
||||
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
|
||||
|
||||
Map<String, Object> serviceResult = new HashMap<>();
|
||||
putMsg(serviceResult, Status.SUCCESS);
|
||||
serviceResult.put(Constants.DATA_LIST, 1);
|
||||
|
||||
Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class),
|
||||
isA(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class),
|
||||
isA(Priority.class), isA(String.class))).thenReturn(serviceResult);
|
||||
isA(Priority.class), isA(String.class))).thenReturn(successResult());
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123)
|
||||
.header(SESSION_ID, sessionId)
|
||||
@ -89,7 +81,6 @@ public class SchedulerControllerTest extends AbstractControllerTest {
|
||||
logger.info(mvcResult.getResponse().getContentAsString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testUpdateSchedule() throws Exception {
|
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
|
||||
@ -103,7 +94,11 @@ public class SchedulerControllerTest extends AbstractControllerTest {
|
||||
paramsMap.add("workerGroupId","1");
|
||||
paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH));
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/update","cxc_1113")
|
||||
Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class),
|
||||
isA(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class),
|
||||
isA(Priority.class), isA(String.class))).thenReturn(successResult());
|
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123)
|
||||
.header(SESSION_ID, sessionId)
|
||||
.params(paramsMap))
|
||||
.andExpect(status().isOk())
|
||||
|
@ -616,7 +616,7 @@ export default {
|
||||
*/
|
||||
updateSchedule ({ state }, payload) {
|
||||
return new Promise((resolve, reject) => {
|
||||
io.post(`projects/${state.projectName}/schedule/update`, payload, res => {
|
||||
io.post(`projects/${state.projectCode}/schedule/update`, payload, res => {
|
||||
resolve(res)
|
||||
}).catch(e => {
|
||||
reject(e)
|
||||
|
Loading…
Reference in New Issue
Block a user