Browse Source

[Feature-5498][JsonSplit-api] fix some ut (#6121)

* fix some ut

* fix some ut

* fix some ut

Co-authored-by: JinyLeeChina <297062848@qq.com>
2.0.7-release
JinyLeeChina 3 years ago committed by GitHub
parent
commit
baa8f30c2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
  2. 3
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/QueueControllerTest.java
  3. 9
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java
  4. 5
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TenantControllerTest.java

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java

@ -222,9 +222,8 @@ public class SchedulerController extends BaseController {
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100")
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20")
})
@GetMapping()
@ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR)
@ -263,8 +262,7 @@ public class SchedulerController extends BaseController {
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("id") Integer id
) {
@PathVariable("id") Integer id) {
Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectCode, id);
return returnDataList(result);
}
@ -302,8 +300,7 @@ public class SchedulerController extends BaseController {
@ApiException(PREVIEW_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@RequestParam(value = "schedule") String schedule
) {
@RequestParam(value = "schedule") String schedule) {
Map<String, Object> result = schedulerService.previewSchedule(loginUser, schedule);
return returnDataList(result);
}

3
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/QueueControllerTest.java

@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.api.controller;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -104,7 +105,7 @@ public class QueueControllerTest extends AbstractControllerTest {
paramsMap.add("queue","queue2");
paramsMap.add("queueName","root.queue2");
MvcResult mvcResult = mockMvc.perform(post("/queues/{id}")
MvcResult mvcResult = mockMvc.perform(put("/queues/{id}", 1)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isCreated())

9
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java

@ -21,6 +21,7 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -103,7 +104,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
isA(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class),
isA(Priority.class), isA(String.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedules/{id}",123)
MvcResult mvcResult = mockMvc.perform(put("/projects/{projectCode}/schedules/{id}",123, 37)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
@ -123,7 +124,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class),
isA(ReleaseState.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedules/{id}/online",123)
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedules/{id}/online",123, 37)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
@ -143,7 +144,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class),
isA(ReleaseState.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedules/{id}/offline",123)
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedules/{id}/offline",123, 28)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
@ -221,7 +222,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
Mockito.when(schedulerService.deleteScheduleById(isA(User.class), isA(Long.class), isA(Integer.class)))
.thenReturn(success());
MvcResult mvcResult = mockMvc.perform(delete("/projects/{projectCode}/schedules/{id}",123)
MvcResult mvcResult = mockMvc.perform(delete("/projects/{projectCode}/schedules/{id}",123, 37)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())

5
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/TenantControllerTest.java

@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.controller;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -90,7 +91,7 @@ public class TenantControllerTest extends AbstractControllerTest {
paramsMap.add("queueId","1");
paramsMap.add("description","tenant description");
MvcResult mvcResult = mockMvc.perform(post("/tenants/{id}")
MvcResult mvcResult = mockMvc.perform(put("/tenants/{id}", 9)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
@ -159,7 +160,7 @@ public class TenantControllerTest extends AbstractControllerTest {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("id","64");
MvcResult mvcResult = mockMvc.perform(delete("/tenants/{id}")
MvcResult mvcResult = mockMvc.perform(delete("/tenants/{id}", 64)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())

Loading…
Cancel
Save