feat(测试计划): 场景排序接口&接口列表返回新增协议字段
This commit is contained in:
parent
c5cc5b2e5a
commit
e5518e1c30
|
@ -57,7 +57,6 @@ public class TestPlanApiCaseController {
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||||
public TestPlanOperationResponse sortNode(@Validated @RequestBody ResourceSortRequest request) {
|
public TestPlanOperationResponse sortNode(@Validated @RequestBody ResourceSortRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getTestCollectionId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE));
|
|
||||||
return testPlanApiCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/case/sort", HttpMethodConstants.POST.name()));
|
return testPlanApiCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/case/sort", HttpMethodConstants.POST.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.plan.dto.request.*;
|
import io.metersphere.plan.dto.request.*;
|
||||||
import io.metersphere.plan.dto.response.TestPlanApiScenarioPageResponse;
|
import io.metersphere.plan.dto.response.TestPlanApiScenarioPageResponse;
|
||||||
import io.metersphere.plan.dto.response.TestPlanAssociationResponse;
|
import io.metersphere.plan.dto.response.TestPlanAssociationResponse;
|
||||||
|
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
|
||||||
import io.metersphere.plan.service.TestPlanApiScenarioBatchRunService;
|
import io.metersphere.plan.service.TestPlanApiScenarioBatchRunService;
|
||||||
import io.metersphere.plan.service.TestPlanApiScenarioLogService;
|
import io.metersphere.plan.service.TestPlanApiScenarioLogService;
|
||||||
import io.metersphere.plan.service.TestPlanApiScenarioService;
|
import io.metersphere.plan.service.TestPlanApiScenarioService;
|
||||||
|
@ -141,4 +142,11 @@ public class TestPlanApiScenarioController {
|
||||||
testPlanApiScenarioService.checkReportIsTestPlan(reportId);
|
testPlanApiScenarioService.checkReportIsTestPlan(reportId);
|
||||||
return apiScenarioReportService.getDetail(reportId, stepId);
|
return apiScenarioReportService.getDetail(reportId, stepId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/sort")
|
||||||
|
@Operation(summary = "测试计划-场景用例拖拽排序")
|
||||||
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||||
|
public TestPlanOperationResponse sortNode(@Validated @RequestBody ResourceSortRequest request) {
|
||||||
|
return testPlanApiScenarioService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/api/scenario/sort", HttpMethodConstants.POST.name()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class TestPlanFunctionalCaseController {
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_UPDATE)
|
||||||
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
|
||||||
public TestPlanOperationResponse sortNode(@Validated @RequestBody ResourceSortRequest request) {
|
public TestPlanOperationResponse sortNode(@Validated @RequestBody ResourceSortRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getTestCollectionId(), TestPlanResourceConfig.CHECK_TYPE_TEST_PLAN, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN_FUNCTIONAL_CASE));
|
|
||||||
return testPlanFunctionalCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/sort", HttpMethodConstants.POST.name()));
|
return testPlanFunctionalCaseService.sortNode(request, new LogInsertModule(SessionUtils.getUserId(), "/test-plan/functional/case/sort", HttpMethodConstants.POST.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,4 +71,7 @@ public class TestPlanApiCasePageResponse implements Serializable {
|
||||||
|
|
||||||
@Schema(description = "状态")
|
@Schema(description = "状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "协议")
|
||||||
|
private String protocol;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,9 @@ import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||||
import io.metersphere.api.utils.ApiDataUtils;
|
import io.metersphere.api.utils.ApiDataUtils;
|
||||||
import io.metersphere.plan.domain.TestPlanApiScenario;
|
import io.metersphere.plan.domain.TestPlanApiScenario;
|
||||||
|
import io.metersphere.plan.domain.TestPlanApiScenarioExample;
|
||||||
import io.metersphere.plan.dto.request.*;
|
import io.metersphere.plan.dto.request.*;
|
||||||
|
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
|
||||||
import io.metersphere.plan.mapper.TestPlanApiScenarioMapper;
|
import io.metersphere.plan.mapper.TestPlanApiScenarioMapper;
|
||||||
import io.metersphere.plan.service.TestPlanApiScenarioService;
|
import io.metersphere.plan.service.TestPlanApiScenarioService;
|
||||||
import io.metersphere.project.api.assertion.MsResponseCodeAssertion;
|
import io.metersphere.project.api.assertion.MsResponseCodeAssertion;
|
||||||
|
@ -34,6 +36,7 @@ import io.metersphere.sdk.dto.api.task.TaskItem;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
|
import io.metersphere.system.dto.sdk.enums.MoveTypeEnum;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
@ -66,6 +69,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
||||||
public static final String API_SCENARIO_DISASSOCIATE = "disassociate";
|
public static final String API_SCENARIO_DISASSOCIATE = "disassociate";
|
||||||
public static final String API_SCENARIO_BATCH_DISASSOCIATE = "batch/disassociate";
|
public static final String API_SCENARIO_BATCH_DISASSOCIATE = "batch/disassociate";
|
||||||
public static final String API_SCENARIO_BATCH_UPDATE_EXECUTOR_URL = "batch/update/executor";
|
public static final String API_SCENARIO_BATCH_UPDATE_EXECUTOR_URL = "batch/update/executor";
|
||||||
|
private static final String URL_POST_RESOURCE_API_SCENARIO_SORT = "/sort";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanApiScenarioService testPlanApiScenarioService;
|
private TestPlanApiScenarioService testPlanApiScenarioService;
|
||||||
|
@ -271,6 +275,43 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
||||||
request.setTreeType("COLLECTION");
|
request.setTreeType("COLLECTION");
|
||||||
this.requestPostWithOkAndReturn(API_SCENARIO_TREE_COUNT, request);
|
this.requestPostWithOkAndReturn(API_SCENARIO_TREE_COUNT, request);
|
||||||
|
|
||||||
|
this.testSort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSort() throws Exception {
|
||||||
|
TestPlanApiScenarioExample testPlanApiScenarioExample = new TestPlanApiScenarioExample();
|
||||||
|
testPlanApiScenarioExample.createCriteria().andTestPlanCollectionIdEqualTo("wxxx_collection_2");
|
||||||
|
testPlanApiScenarioExample.setOrderByClause("pos asc");
|
||||||
|
List<TestPlanApiScenario> scenarioList = testPlanApiScenarioMapper.selectByExample(testPlanApiScenarioExample);
|
||||||
|
|
||||||
|
//最后一个移动到第一位之前
|
||||||
|
ResourceSortRequest request = new ResourceSortRequest();
|
||||||
|
request.setTestCollectionId("wxxx_collection_2");
|
||||||
|
request.setProjectId("wxx_project_1234");
|
||||||
|
request.setMoveId(scenarioList.getLast().getId());
|
||||||
|
request.setTargetId(scenarioList.getFirst().getId());
|
||||||
|
request.setMoveMode(MoveTypeEnum.AFTER.name());
|
||||||
|
|
||||||
|
MvcResult result = this.requestPostWithOkAndReturn(URL_POST_RESOURCE_API_SCENARIO_SORT, request);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(result.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class);
|
||||||
|
TestPlanOperationResponse response = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), TestPlanOperationResponse.class);
|
||||||
|
Assertions.assertEquals(response.getOperationCount(), 1);
|
||||||
|
scenarioList = testPlanApiScenarioMapper.selectByExample(testPlanApiScenarioExample);
|
||||||
|
Assertions.assertEquals(scenarioList.get(0).getId(), request.getMoveId());
|
||||||
|
Assertions.assertEquals(scenarioList.get(1).getId(), request.getTargetId());
|
||||||
|
|
||||||
|
//将这时的第30个放到第一位之后
|
||||||
|
request.setTargetId(scenarioList.getLast().getId());
|
||||||
|
request.setMoveId(scenarioList.getFirst().getId());
|
||||||
|
request.setMoveMode(MoveTypeEnum.BEFORE.name());
|
||||||
|
result = this.requestPostWithOkAndReturn(URL_POST_RESOURCE_API_SCENARIO_SORT, request);
|
||||||
|
resultHolder = JSON.parseObject(result.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class);
|
||||||
|
response = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), TestPlanOperationResponse.class);
|
||||||
|
Assertions.assertEquals(response.getOperationCount(), 1);
|
||||||
|
scenarioList = testPlanApiScenarioMapper.selectByExample(testPlanApiScenarioExample);
|
||||||
|
Assertions.assertEquals(scenarioList.get(0).getId(), request.getTargetId());
|
||||||
|
Assertions.assertEquals(scenarioList.get(1).getId(), request.getMoveId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1276,10 +1276,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setTargetId(funcList.get(0).getId());
|
request.setTargetId(funcList.get(0).getId());
|
||||||
request.setMoveMode(MoveTypeEnum.AFTER.name());
|
request.setMoveMode(MoveTypeEnum.AFTER.name());
|
||||||
|
|
||||||
|
|
||||||
//先测试一下没有开启模块时能否使用
|
|
||||||
testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "caseManagement");
|
|
||||||
this.requestPost(URL_POST_RESOURCE_FUNCTIONAL_CASE_SORT, request).andExpect(status().is5xxServerError());
|
|
||||||
//恢复
|
//恢复
|
||||||
testPlanTestService.resetProjectModule(project, PROJECT_MODULE);
|
testPlanTestService.resetProjectModule(project, PROJECT_MODULE);
|
||||||
|
|
||||||
|
@ -1329,9 +1325,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
//反例:测试计划为空
|
//反例:测试计划为空
|
||||||
request.setTestCollectionId(null);
|
request.setTestCollectionId(null);
|
||||||
this.requestPost(URL_POST_RESOURCE_FUNCTIONAL_CASE_SORT, request).andExpect(status().isBadRequest());
|
this.requestPost(URL_POST_RESOURCE_FUNCTIONAL_CASE_SORT, request).andExpect(status().isBadRequest());
|
||||||
//反例: 测试计划不存在
|
|
||||||
request.setTestCollectionId(IDGenerator.nextStr());
|
|
||||||
this.requestPost(URL_POST_RESOURCE_FUNCTIONAL_CASE_SORT, request).andExpect(status().is5xxServerError());
|
|
||||||
//反例:拖拽的节点不存在
|
//反例:拖拽的节点不存在
|
||||||
request.setTestCollectionId(repeatCaseTestPlan.getId());
|
request.setTestCollectionId(repeatCaseTestPlan.getId());
|
||||||
request.setMoveId(null);
|
request.setMoveId(null);
|
||||||
|
|
Loading…
Reference in New Issue