|
|
@ -23,14 +23,19 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
import org.apache.dolphinscheduler.api.service.SchedulerService; |
|
|
|
import org.apache.dolphinscheduler.api.service.SchedulerService; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
|
|
|
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Priority; |
|
|
|
import org.apache.dolphinscheduler.common.enums.Priority; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ReleaseState; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.WarningType; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.Resource; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.User; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
@ -68,7 +73,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class), |
|
|
|
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(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class), |
|
|
|
isA(Priority.class), isA(String.class))).thenReturn(successResult()); |
|
|
|
isA(Priority.class), isA(String.class))).thenReturn(success()); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123) |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
@ -97,7 +102,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class), |
|
|
|
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(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class), |
|
|
|
isA(Priority.class), isA(String.class))).thenReturn(successResult()); |
|
|
|
isA(Priority.class), isA(String.class))).thenReturn(success()); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123) |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
@ -117,7 +122,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { |
|
|
|
paramsMap.add("id","37"); |
|
|
|
paramsMap.add("id","37"); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), |
|
|
|
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), |
|
|
|
isA(ReleaseState.class))).thenReturn(successResult()); |
|
|
|
isA(ReleaseState.class))).thenReturn(success()); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/online",123) |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/online",123) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
@ -137,7 +142,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { |
|
|
|
paramsMap.add("id","28"); |
|
|
|
paramsMap.add("id","28"); |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), |
|
|
|
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), |
|
|
|
isA(ReleaseState.class))).thenReturn(successResult()); |
|
|
|
isA(ReleaseState.class))).thenReturn(success()); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/offline",123) |
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/offline",123) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
@ -151,16 +156,22 @@ public class SchedulerControllerTest extends AbstractControllerTest { |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
logger.info(mvcResult.getResponse().getContentAsString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryScheduleListPaging() throws Exception { |
|
|
|
public void testQueryScheduleListPaging() throws Exception { |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
paramsMap.add("processDefinitionId","40"); |
|
|
|
paramsMap.add("processDefinitionCode","40"); |
|
|
|
paramsMap.add("searchVal","test"); |
|
|
|
paramsMap.add("searchVal","test"); |
|
|
|
paramsMap.add("pageNo","1"); |
|
|
|
paramsMap.add("pageNo","1"); |
|
|
|
paramsMap.add("pageSize","30"); |
|
|
|
paramsMap.add("pageSize","30"); |
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/list-paging","cxc_1113") |
|
|
|
Map<String, Object> mockResult = success(); |
|
|
|
|
|
|
|
PageInfo<Resource> pageInfo = new PageInfo<>(1, 10); |
|
|
|
|
|
|
|
mockResult.put(Constants.DATA_LIST, pageInfo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(schedulerService.querySchedule(isA(User.class), isA(Long.class), isA(Long.class), |
|
|
|
|
|
|
|
isA(String.class), isA(Integer.class), isA(Integer.class))).thenReturn(mockResult); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectCode}/schedule/list-paging",123) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.header(SESSION_ID, sessionId) |
|
|
|
.params(paramsMap)) |
|
|
|
.params(paramsMap)) |
|
|
|
.andExpect(status().isOk()) |
|
|
|
.andExpect(status().isOk()) |
|
|
|