|
|
|
@ -24,7 +24,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.utils.Result; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
|
import org.apache.dolphinscheduler.common.enums.NodeType; |
|
|
|
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.WorkerGroup; |
|
|
|
@ -50,6 +49,7 @@ import org.springframework.util.MultiValueMap;
|
|
|
|
|
* worker group controller test |
|
|
|
|
*/ |
|
|
|
|
public class WorkerGroupControllerTest extends AbstractControllerTest { |
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(WorkerGroupControllerTest.class); |
|
|
|
|
|
|
|
|
|
@MockBean(name = "workerGroupMapper") |
|
|
|
@ -69,10 +69,10 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|
|
|
|
Mockito.when(registryClient.getServerMaps(NodeType.WORKER)).thenReturn(serverMaps); |
|
|
|
|
|
|
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
|
paramsMap.add("name","cxc_work_group"); |
|
|
|
|
paramsMap.add("addrList","192.168.0.1,192.168.0.2"); |
|
|
|
|
paramsMap.add("description",""); |
|
|
|
|
paramsMap.add("otherParamsJson",""); |
|
|
|
|
paramsMap.add("name", "cxc_work_group"); |
|
|
|
|
paramsMap.add("addrList", "192.168.0.1,192.168.0.2"); |
|
|
|
|
paramsMap.add("description", ""); |
|
|
|
|
paramsMap.add("otherParamsJson", ""); |
|
|
|
|
MvcResult mvcResult = mockMvc.perform(post("/worker-groups") |
|
|
|
|
.header("sessionId", sessionId) |
|
|
|
|
.params(paramsMap)) |
|
|
|
@ -87,9 +87,9 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|
|
|
|
@Test |
|
|
|
|
public void testQueryAllWorkerGroupsPaging() throws Exception { |
|
|
|
|
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
|
|
|
|
paramsMap.add("pageNo","2"); |
|
|
|
|
paramsMap.add("searchVal","cxc"); |
|
|
|
|
paramsMap.add("pageSize","2"); |
|
|
|
|
paramsMap.add("pageNo", "2"); |
|
|
|
|
paramsMap.add("searchVal", "cxc"); |
|
|
|
|
paramsMap.add("pageSize", "2"); |
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/worker-groups") |
|
|
|
|
.header("sessionId", sessionId) |
|
|
|
|
.params(paramsMap)) |
|
|
|
@ -118,7 +118,7 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|
|
|
|
@Test |
|
|
|
|
public void queryWorkerAddressList() throws Exception { |
|
|
|
|
MvcResult mvcResult = mockMvc.perform(get("/worker-groups/worker-address-list") |
|
|
|
|
.header("sessionId", sessionId)) |
|
|
|
|
.header("sessionId", sessionId)) |
|
|
|
|
.andExpect(status().isOk()) |
|
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) |
|
|
|
|
.andReturn(); |
|
|
|
@ -133,7 +133,8 @@ public class WorkerGroupControllerTest extends AbstractControllerTest {
|
|
|
|
|
workerGroup.setId(12); |
|
|
|
|
workerGroup.setName("测试"); |
|
|
|
|
Mockito.when(workerGroupMapper.selectById(12)).thenReturn(workerGroup); |
|
|
|
|
Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus("测试", org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES)) |
|
|
|
|
Mockito.when(processInstanceMapper.queryByWorkerGroupNameAndStatus("测试", |
|
|
|
|
org.apache.dolphinscheduler.service.utils.Constants.NOT_TERMINATED_STATES)) |
|
|
|
|
.thenReturn(null); |
|
|
|
|
Mockito.when(workerGroupMapper.deleteById(12)).thenReturn(1); |
|
|
|
|
Mockito.when(processInstanceMapper.updateProcessInstanceByWorkerGroupName("测试", "")).thenReturn(1); |
|
|
|
|