fix(测试跟踪): 测试计划允许重复关联用例失效

--bug=1018851 --user=陈建星 【测试跟踪】测试计划-开启“允许重复关联用例”-再次关联用例不显示已关联过的用例 https://www.tapd.cn/55049933/s/1277042
This commit is contained in:
chenjianxing 2022-10-25 18:45:44 +08:00 committed by jianxing
parent bd51abfe1f
commit 8c645523f2
15 changed files with 259 additions and 27 deletions

View File

@ -550,9 +550,6 @@
)
)
</if>
<if test="request.repeatCase">
and api_definition.case_total is not null and api_definition.case_total > 0
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="api_definition"/>
</include>

View File

@ -73,7 +73,6 @@ public class TestPlanApiCaseController {
return testPlanApiCaseService.selectAllTableRows(request);
}
// todo request allowedRepeatCase
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
return testPlanApiCaseService.relevanceList(goPage, pageSize, request);

View File

@ -0,0 +1,21 @@
package io.metersphere.controller.remote;
import io.metersphere.plan.service.remote.api.PlanApiDefinitionService;
import io.metersphere.xpack.api.dto.request.ApiDefinitionRequest;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RequestMapping("/api/definition")
@RestController
public class TrackApiDefinitionController {
@Resource
PlanApiDefinitionService planApiDefinitionService;
@PostMapping("/list/relevance/{goPage}/{pageSize}")
public Object listRelevance(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
return planApiDefinitionService.listRelevance(request, goPage, pageSize);
}
}

View File

@ -1,13 +1,11 @@
package io.metersphere.controller.remote;
import io.metersphere.plan.dto.ApiModuleDTO;
import io.metersphere.plan.request.api.ApiTestCaseRequest;
import io.metersphere.plan.service.TestPlanProjectService;
import io.metersphere.plan.service.remote.api.PlanTestPlanApiCaseService;
import io.metersphere.service.wapper.CheckPermissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -29,4 +27,9 @@ public class TrackTestPlanApiCaseController {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
return planTestPlanApiCaseService.getNodeByPlanId(projectIds, planId, protocol);
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Object relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
return planTestPlanApiCaseService.relevanceList(goPage, pageSize, request);
}
}

View File

@ -0,0 +1,20 @@
package io.metersphere.controller.remote;
import io.metersphere.plan.request.performance.LoadCaseRequest;
import io.metersphere.plan.service.remote.performance.PlanTestPlanLoadCaseService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RequestMapping("/test/plan/load/case")
@RestController
public class TrackTestPlanLoadCaseController {
@Resource
PlanTestPlanLoadCaseService planTestPlanLoadCaseService;
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Object relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
return planTestPlanLoadCaseService.relevanceList(goPage, pageSize, request);
}
}

View File

@ -1,13 +1,11 @@
package io.metersphere.controller.remote;
import io.metersphere.plan.dto.ApiScenarioModuleDTO;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.service.TestPlanProjectService;
import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService;
import io.metersphere.service.wapper.CheckPermissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -29,4 +27,9 @@ public class TrackTestPlanScenarioCaseController {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
return planTestPlanScenarioCaseService.getNodeByPlanId(projectIds, planId);
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Object relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
return planTestPlanScenarioCaseService.relevanceList(request, goPage, pageSize);
}
}

View File

@ -1,13 +1,11 @@
package io.metersphere.controller.remote;
import io.metersphere.dto.ModuleNodeDTO;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.service.TestPlanProjectService;
import io.metersphere.plan.service.remote.ui.PlanTestPlanUiScenarioCaseService;
import io.metersphere.service.wapper.CheckPermissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@ -29,4 +27,9 @@ public class TrackTestPlanUiScenarioCaseController {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
return planTestPlanUiScenarioCaseService.getNodeByPlanId(projectIds, planId);
}
@PostMapping("/relevance/list/{goPage}/{pageSize}")
public Object relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
return planTestPlanUiScenarioCaseService.relevanceList(request, goPage, pageSize);
}
}

View File

@ -0,0 +1,39 @@
package io.metersphere.plan.request.api;
import io.metersphere.request.BaseQueryRequest;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ApiScenarioRequest extends BaseQueryRequest {
private String id;
private String excludeId;
private String moduleId;
private String name;
private String userId;
private String planId;
private boolean recent = false;
private boolean isSelectThisWeedData;
private long createTime = 0;
private long scheduleCreateTime = 0;
private String executeStatus;
private String selectDataType;
private boolean notInTestPlan;
private String reviewId;
private String versionId;
private String refId;
private Boolean allowedRepeatCase = false;
//操作人
private String operator;
//操作时间
private Long operationTime;
/**
* 是否需要查询环境字段
*/
private boolean selectEnvironment = false;
//测试计划关联场景过滤掉步骤为0的场景
private String stepTotal;
}

View File

@ -0,0 +1,79 @@
package io.metersphere.plan.request.api;
import io.metersphere.request.ApiSyncCaseRequest;
import io.metersphere.request.BaseQueryRequest;
import io.metersphere.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class ApiTestCaseRequest extends BaseQueryRequest {
private String id;
private List<String> ids;
private String planId;
private String projectId;
private String priority;
private String name;
private String environmentId;
private String workspaceId;
private String apiDefinitionId;
private String status;
private String protocol;
private String moduleId;
private List<String> moduleIds;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
private Map<String, Object> combine;
private boolean isSelectThisWeedData;
private long createTime = 0;
private long updateTime = 0;
private String reviewId;
private String deleteUserId;
private long deleteTime;
private Boolean allowedRepeatCase = false;
/**
* 检查待更新的近三天有更新的或者状态为error的
*/
private boolean toUpdate;
/**
* 是否进入待更新列表
*/
private boolean toBeUpdated;
/**
* 当前时间减去进入待更新的时间
*/
private Long toBeUpdateTime;
/**
* 进入待更新列表用例状态集合
*/
private List<String> statusList;
/**
* 不需要查用例状态
*/
private boolean noSearchStatus;
/**
* 是否需要查询环境字段
*/
private boolean selectEnvironment = false;
/**
* 查询排除一些接口
*/
private List<String> notInIds;
//页面跳转时附带的过滤条件
private String redirectFilter;
//同步配置
private ApiSyncCaseRequest syncConfig;
//全选
private boolean selectAll;
}

View File

@ -0,0 +1,26 @@
package io.metersphere.plan.service.remote.api;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.xpack.api.dto.request.ApiDefinitionRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class PlanApiDefinitionService extends ApiTestService {
private static final String BASE_UEL = "/api/definition";
@Resource
@Lazy
TestPlanService testPlanService;
public Object listRelevance(ApiDefinitionRequest request, int pageNum, int pageSize) {
if (StringUtils.isNotBlank(request.getPlanId()) && testPlanService.isAllowedRepeatCase(request.getPlanId())) {
request.setRepeatCase(true);
}
return microService.postForData(serviceName, BASE_UEL + String.format("/list/relevance/%s/%s", pageNum, pageSize), request);
}
}

View File

@ -4,8 +4,11 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.*;
import io.metersphere.plan.dto.*;
import io.metersphere.plan.request.api.ApiTestCaseRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.utils.TestPlanStatusCalculator;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@ -21,6 +24,9 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
@Resource
PlanApiDefinitionExecResultService planApiDefinitionExecResultService;
@Resource
@Lazy
TestPlanService testPlanService;
/**
* 计算测试计划中接口用例的相关数据
@ -65,7 +71,7 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
}
public List<String> getExecResultByPlanId(String planId) {
return (List<String>) microService.getForData(serviceName, BASE_UEL + "/plan/exec/result/" + planId);
return (List<String>) microService.getForData(serviceName, BASE_UEL + "/plan/exec/result/" + planId);
}
public List<TestPlanApiCaseDTO> listByPlanId(String planId) {
@ -85,7 +91,7 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
}
public RunModeConfigDTO setApiCaseEnv(String planId, RunModeConfigDTO runModeConfig) {
return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class);
return microService.postForData(serviceName, BASE_UEL + "/set/env/" + planId, runModeConfig, RunModeConfigDTO.class);
}
@Transactional(propagation = Propagation.NOT_SUPPORTED)
@ -139,4 +145,9 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
public List<TestPlanFailureApiDTO> buildResponse(List<TestPlanFailureApiDTO> apiAllCases) {
return microService.postForDataArray(serviceName, BASE_UEL + "/build/response", apiAllCases, TestPlanFailureApiDTO.class);
}
public Object relevanceList(int pageNum, int pageSize, ApiTestCaseRequest request) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId()));
return microService.postForData(serviceName, BASE_UEL + String.format("/relevance/list/%s/%s", pageNum, pageSize), request);
}
}

View File

@ -7,8 +7,11 @@ import io.metersphere.dto.*;
import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.*;
import io.metersphere.plan.request.api.ApiPlanReportRequest;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.utils.TestPlanStatusCalculator;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -20,6 +23,10 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
private static final String BASE_UEL = "/test/plan/scenario/case";
@Resource
@Lazy
TestPlanService testPlanService;
@Resource
PlanApiScenarioReportService planApiScenarioReportService;
@ -166,4 +173,9 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
public List<TestPlanFailureScenarioDTO> buildResponse(List<TestPlanFailureScenarioDTO> scenarioCases) {
return microService.postForDataArray(serviceName, BASE_UEL + "/build/response", scenarioCases, TestPlanFailureScenarioDTO.class);
}
public Object relevanceList(ApiScenarioRequest request, int pageNum, int pageSize) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId()));
return microService.postForData(serviceName, BASE_UEL + String.format("/relevance/list/%s/%s", pageNum, pageSize), request);
}
}

View File

@ -11,10 +11,10 @@ import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
import io.metersphere.plan.request.api.ApiPlanReportRequest;
import io.metersphere.plan.request.performance.LoadCaseRequest;
import io.metersphere.plan.request.performance.LoadPlanReportDTO;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.utils.TestPlanStatusCalculator;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -29,6 +29,9 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
@Resource
private PlanLoadTestReportService planLoadTestReportService;
@Resource
@Lazy
private TestPlanService testPlanService;
public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) {
try {
@ -117,4 +120,9 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
public List<TestPlanLoadCaseDTO> buildResponse(List<TestPlanLoadCaseDTO> loadCases) {
return microService.postForDataArray(serviceName, BASE_UEL + "/build/response", loadCases, TestPlanLoadCaseDTO.class);
}
public Object relevanceList(int pageNum, int pageSize, LoadCaseRequest request) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getTestPlanId()));
return microService.postForData(serviceName, BASE_UEL + String.format("/relevance/list/%s/%s", pageNum, pageSize), request);
}
}

View File

@ -10,10 +10,13 @@ import io.metersphere.plan.dto.TestPlanScenarioStepCountSimpleDTO;
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
import io.metersphere.plan.dto.UiPlanReportDTO;
import io.metersphere.plan.request.api.ApiPlanReportRequest;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService;
import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService;
import io.metersphere.plan.utils.TestPlanStatusCalculator;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -29,6 +32,9 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService {
@Resource
private PlanUiScenarioReportService planUiScenarioReportService;
@Resource
@Lazy
TestPlanService testPlanService;
public List<String> getExecResultByPlanId(String planId) {
return (List<String>) microService.getForData(serviceName, BASE_UEL + "/plan/exec/result/" + planId);
@ -125,4 +131,9 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService {
public List<TestPlanUiScenarioDTO> buildResponse(List<TestPlanUiScenarioDTO> uiCases) {
return microService.postForDataArray(serviceName, BASE_UEL + "/build/response", uiCases, TestPlanUiScenarioDTO.class);
}
public Object relevanceList(ApiScenarioRequest request, int pageNum, int pageSize) {
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getPlanId()));
return microService.postForData(serviceName, BASE_UEL + String.format("/relevance/list/%s/%s", pageNum, pageSize), request);
}
}

View File

@ -30,6 +30,7 @@ import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.track.TestCaseReference;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.service.TestPlanTestCaseService;
import io.metersphere.request.OrderRequest;
import io.metersphere.request.ProjectVersionRequest;
@ -155,9 +156,9 @@ public class TestCaseService {
// private PerformanceTestService performanceTestService;
@Resource
private TestCaseFollowMapper testCaseFollowMapper;
// @Resource
// @Lazy
// private TestPlanService testPlanService;
@Resource
@Lazy
private TestPlanService testPlanService;
@Resource
private MinderExtraNodeService minderExtraNodeService;
@Resource
@ -884,10 +885,9 @@ public class TestCaseService {
request.getOrders().forEach(order -> {
order.setPrefix("test_case");
});
// todo
// if (testPlanService.isAllowedRepeatCase(request.getPlanId())) {
// request.setRepeatCase(true);
// }
if (testPlanService.isAllowedRepeatCase(request.getPlanId())) {
request.setRepeatCase(true);
}
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, getTestCaseByNotInPlan(request));
}